From ce625d172cc42fdc07411259c2637d50554456d5 Mon Sep 17 00:00:00 2001 From: hc-github-team-tf-azure <> Date: Fri, 1 Mar 2024 08:55:11 +0000 Subject: [PATCH] Updating based on 5e86ea25 --- .../batch/2024-02-01/application/README.md | 111 ++ .../batch/2024-02-01/application/client.go | 26 + .../2024-02-01/application/id_application.go | 134 +++ .../application/id_application_test.go | 327 ++++++ .../2024-02-01/application/id_batchaccount.go | 125 ++ .../application/id_batchaccount_test.go | 282 +++++ .../2024-02-01/application/method_create.go | 58 + .../2024-02-01/application/method_delete.go | 47 + .../2024-02-01/application/method_get.go | 54 + .../2024-02-01/application/method_list.go | 119 ++ .../2024-02-01/application/method_update.go | 58 + .../application/model_application.go | 12 + .../model_applicationproperties.go | 10 + .../2024-02-01/application/predicates.go | 32 + .../batch/2024-02-01/application/version.go | 12 + .../2024-02-01/applicationpackage/README.md | 111 ++ .../2024-02-01/applicationpackage/client.go | 26 + .../applicationpackage/constants.go | 51 + .../applicationpackage/id_application.go | 134 +++ .../applicationpackage/id_application_test.go | 327 ++++++ .../applicationpackage/id_version.go | 143 +++ .../applicationpackage/id_version_test.go | 372 ++++++ .../applicationpackage/method_activate.go | 59 + .../applicationpackage/method_create.go | 58 + .../applicationpackage/method_delete.go | 47 + .../applicationpackage/method_get.go | 54 + .../applicationpackage/method_list.go | 119 ++ ...el_activateapplicationpackageparameters.go | 8 + .../model_applicationpackage.go | 12 + .../model_applicationpackageproperties.go | 42 + .../applicationpackage/predicates.go | 32 + .../2024-02-01/applicationpackage/version.go | 12 + .../batch/2024-02-01/batchaccount/README.md | 191 ++++ .../batch/2024-02-01/batchaccount/client.go | 26 + .../2024-02-01/batchaccount/constants.go | 491 ++++++++ .../batchaccount/id_batchaccount.go | 125 ++ .../batchaccount/id_batchaccount_test.go | 282 +++++ .../2024-02-01/batchaccount/method_create.go | 75 ++ .../2024-02-01/batchaccount/method_delete.go | 71 ++ .../2024-02-01/batchaccount/method_get.go | 54 + .../2024-02-01/batchaccount/method_getkeys.go | 55 + .../2024-02-01/batchaccount/method_list.go | 92 ++ .../method_listbyresourcegroup.go | 92 ++ ...istoutboundnetworkdependenciesendpoints.go | 91 ++ .../batchaccount/method_regeneratekey.go | 59 + .../method_synchronizeautostoragekeys.go | 47 + .../2024-02-01/batchaccount/method_update.go | 58 + .../model_autostoragebaseproperties.go | 10 + .../model_autostorageproperties.go | 26 + .../batchaccount/model_batchaccount.go | 18 + .../model_batchaccountcreateparameters.go | 15 + .../model_batchaccountcreateproperties.go | 14 + .../batchaccount/model_batchaccountkeys.go | 10 + .../model_batchaccountproperties.go | 24 + ...del_batchaccountregeneratekeyparameters.go | 8 + .../model_batchaccountupdateparameters.go | 14 + .../model_batchaccountupdateproperties.go | 12 + .../model_computenodeidentityreference.go | 8 + .../model_encryptionproperties.go | 9 + .../model_endpointaccessprofile.go | 9 + .../batchaccount/model_endpointdependency.go | 10 + .../batchaccount/model_endpointdetail.go | 8 + .../2024-02-01/batchaccount/model_iprule.go | 9 + .../batchaccount/model_keyvaultproperties.go | 8 + .../batchaccount/model_keyvaultreference.go | 9 + .../batchaccount/model_networkprofile.go | 9 + .../model_outboundenvironmentendpoint.go | 9 + .../batchaccount/model_privateendpoint.go | 8 + .../model_privateendpointconnection.go | 12 + ...del_privateendpointconnectionproperties.go | 11 + ...model_privatelinkserviceconnectionstate.go | 10 + .../model_virtualmachinefamilycorequota.go | 9 + .../2024-02-01/batchaccount/predicates.go | 45 + .../batch/2024-02-01/batchaccount/version.go | 12 + .../2024-02-01/batchmanagements/README.md | 74 ++ .../2024-02-01/batchmanagements/client.go | 26 + .../2024-02-01/batchmanagements/constants.go | 89 ++ .../batchmanagements/id_batchaccount.go | 125 ++ .../batchmanagements/id_batchaccount_test.go | 282 +++++ .../batchmanagements/id_detector.go | 134 +++ .../batchmanagements/id_detector_test.go | 327 ++++++ .../batchmanagements/id_location.go | 116 ++ .../batchmanagements/id_location_test.go | 237 ++++ .../method_batchaccountgetdetector.go | 54 + .../method_batchaccountlistdetectors.go | 91 ++ .../method_locationchecknameavailability.go | 59 + .../model_checknameavailabilityparameters.go | 9 + .../model_checknameavailabilityresult.go | 10 + .../model_detectorresponse.go | 12 + .../model_detectorresponseproperties.go | 8 + .../2024-02-01/batchmanagements/predicates.go | 32 + .../2024-02-01/batchmanagements/version.go | 12 + .../batch/2024-02-01/certificate/README.md | 123 ++ .../batch/2024-02-01/certificate/client.go | 26 + .../batch/2024-02-01/certificate/constants.go | 95 ++ .../2024-02-01/certificate/id_batchaccount.go | 125 ++ .../certificate/id_batchaccount_test.go | 282 +++++ .../2024-02-01/certificate/id_certificate.go | 134 +++ .../certificate/id_certificate_test.go | 327 ++++++ .../certificate/method_canceldeletion.go | 55 + .../2024-02-01/certificate/method_create.go | 91 ++ .../2024-02-01/certificate/method_delete.go | 71 ++ .../2024-02-01/certificate/method_get.go | 54 + .../certificate/method_listbybatchaccount.go | 127 +++ .../2024-02-01/certificate/method_update.go | 87 ++ .../certificate/model_certificate.go | 12 + ...del_certificatecreateorupdateparameters.go | 12 + ...del_certificatecreateorupdateproperties.go | 12 + .../model_certificateproperties.go | 46 + .../model_deletecertificateerror.go | 11 + .../2024-02-01/certificate/predicates.go | 32 + .../batch/2024-02-01/certificate/version.go | 12 + resource-manager/batch/2024-02-01/client.go | 100 ++ .../batch/2024-02-01/location/README.md | 70 ++ .../batch/2024-02-01/location/client.go | 26 + .../batch/2024-02-01/location/id_location.go | 116 ++ .../2024-02-01/location/id_location_test.go | 237 ++++ .../2024-02-01/location/method_getquotas.go | 55 + .../method_listsupportedcloudserviceskus.go | 123 ++ .../method_listsupportedvirtualmachineskus.go | 123 ++ .../location/model_batchlocationquota.go | 8 + .../location/model_skucapability.go | 9 + .../2024-02-01/location/model_supportedsku.go | 29 + .../batch/2024-02-01/location/predicates.go | 27 + .../batch/2024-02-01/location/version.go | 12 + .../batch/2024-02-01/pool/README.md | 139 +++ .../batch/2024-02-01/pool/client.go | 26 + .../batch/2024-02-01/pool/constants.go | 1015 +++++++++++++++++ .../batch/2024-02-01/pool/id_batchaccount.go | 125 ++ .../2024-02-01/pool/id_batchaccount_test.go | 282 +++++ .../batch/2024-02-01/pool/id_pool.go | 134 +++ .../batch/2024-02-01/pool/id_pool_test.go | 327 ++++++ .../batch/2024-02-01/pool/method_create.go | 91 ++ .../batch/2024-02-01/pool/method_delete.go | 71 ++ .../pool/method_disableautoscale.go | 55 + .../batch/2024-02-01/pool/method_get.go | 54 + .../pool/method_listbybatchaccount.go | 127 +++ .../2024-02-01/pool/method_stopresize.go | 55 + .../batch/2024-02-01/pool/method_update.go | 87 ++ .../pool/model_applicationpackagereference.go | 9 + .../pool/model_automaticosupgradepolicy.go | 11 + .../2024-02-01/pool/model_autoscalerun.go | 25 + .../pool/model_autoscalerunerror.go | 10 + .../pool/model_autoscalesettings.go | 9 + .../pool/model_autouserspecification.go | 9 + .../model_azureblobfilesystemconfiguration.go | 14 + .../pool/model_azurefileshareconfiguration.go | 12 + .../pool/model_certificatereference.go | 11 + .../pool/model_cifsmountconfiguration.go | 12 + .../pool/model_cloudserviceconfiguration.go | 9 + .../model_computenodeidentityreference.go | 8 + .../pool/model_containerconfiguration.go | 10 + .../pool/model_containerregistry.go | 11 + .../batch/2024-02-01/pool/model_datadisk.go | 11 + .../pool/model_deploymentconfiguration.go | 9 + .../2024-02-01/pool/model_diffdisksettings.go | 8 + .../pool/model_diskencryptionconfiguration.go | 8 + .../pool/model_environmentsetting.go | 9 + .../pool/model_fixedscalesettings.go | 11 + .../2024-02-01/pool/model_imagereference.go | 12 + .../2024-02-01/pool/model_inboundnatpool.go | 13 + .../pool/model_linuxuserconfiguration.go | 10 + .../2024-02-01/pool/model_manageddisk.go | 8 + .../2024-02-01/pool/model_metadataitem.go | 9 + .../pool/model_mountconfiguration.go | 11 + .../pool/model_networkconfiguration.go | 12 + .../pool/model_networksecuritygrouprule.go | 11 + .../pool/model_nfsmountconfiguration.go | 10 + .../pool/model_nodeplacementconfiguration.go | 8 + .../batch/2024-02-01/pool/model_osdisk.go | 12 + .../batch/2024-02-01/pool/model_pool.go | 17 + .../pool/model_poolendpointconfiguration.go | 8 + .../2024-02-01/pool/model_poolproperties.go | 90 ++ .../model_publicipaddressconfiguration.go | 9 + .../2024-02-01/pool/model_resizeerror.go | 10 + .../pool/model_resizeoperationstatus.go | 31 + .../2024-02-01/pool/model_resourcefile.go | 14 + .../pool/model_rollingupgradepolicy.go | 14 + .../2024-02-01/pool/model_scalesettings.go | 9 + .../2024-02-01/pool/model_securityprofile.go | 10 + .../pool/model_serviceartifactreference.go | 8 + .../batch/2024-02-01/pool/model_starttask.go | 14 + .../pool/model_taskcontainersettings.go | 11 + .../pool/model_taskschedulingpolicy.go | 8 + .../2024-02-01/pool/model_uefisettings.go | 9 + .../2024-02-01/pool/model_upgradepolicy.go | 10 + .../2024-02-01/pool/model_useraccount.go | 12 + .../2024-02-01/pool/model_useridentity.go | 9 + .../pool/model_virtualmachineconfiguration.go | 19 + .../2024-02-01/pool/model_vmextension.go | 16 + .../pool/model_windowsconfiguration.go | 8 + .../pool/model_windowsuserconfiguration.go | 8 + .../batch/2024-02-01/pool/predicates.go | 32 + .../batch/2024-02-01/pool/version.go | 12 + .../privateendpointconnection/README.md | 82 ++ .../privateendpointconnection/client.go | 26 + .../privateendpointconnection/constants.go | 110 ++ .../id_batchaccount.go | 125 ++ .../id_batchaccount_test.go | 282 +++++ .../id_privateendpointconnection.go | 134 +++ .../id_privateendpointconnection_test.go | 327 ++++++ .../method_delete.go | 70 ++ .../privateendpointconnection/method_get.go | 54 + .../method_listbybatchaccount.go | 119 ++ .../method_update.go | 103 ++ .../model_privateendpoint.go | 8 + .../model_privateendpointconnection.go | 12 + ...del_privateendpointconnectionproperties.go | 11 + ...model_privatelinkserviceconnectionstate.go | 10 + .../privateendpointconnection/predicates.go | 32 + .../privateendpointconnection/version.go | 12 + .../2024-02-01/privatelinkresource/README.md | 53 + .../2024-02-01/privatelinkresource/client.go | 26 + .../privatelinkresource/id_batchaccount.go | 125 ++ .../id_batchaccount_test.go | 282 +++++ .../id_privatelinkresource.go | 134 +++ .../id_privatelinkresource_test.go | 327 ++++++ .../privatelinkresource/method_get.go | 54 + .../method_listbybatchaccount.go | 119 ++ .../model_privatelinkresource.go | 12 + .../model_privatelinkresourceproperties.go | 10 + .../privatelinkresource/predicates.go | 32 + .../2024-02-01/privatelinkresource/version.go | 12 + 223 files changed, 15546 insertions(+) create mode 100644 resource-manager/batch/2024-02-01/application/README.md create mode 100644 resource-manager/batch/2024-02-01/application/client.go create mode 100644 resource-manager/batch/2024-02-01/application/id_application.go create mode 100644 resource-manager/batch/2024-02-01/application/id_application_test.go create mode 100644 resource-manager/batch/2024-02-01/application/id_batchaccount.go create mode 100644 resource-manager/batch/2024-02-01/application/id_batchaccount_test.go create mode 100644 resource-manager/batch/2024-02-01/application/method_create.go create mode 100644 resource-manager/batch/2024-02-01/application/method_delete.go create mode 100644 resource-manager/batch/2024-02-01/application/method_get.go create mode 100644 resource-manager/batch/2024-02-01/application/method_list.go create mode 100644 resource-manager/batch/2024-02-01/application/method_update.go create mode 100644 resource-manager/batch/2024-02-01/application/model_application.go create mode 100644 resource-manager/batch/2024-02-01/application/model_applicationproperties.go create mode 100644 resource-manager/batch/2024-02-01/application/predicates.go create mode 100644 resource-manager/batch/2024-02-01/application/version.go create mode 100644 resource-manager/batch/2024-02-01/applicationpackage/README.md create mode 100644 resource-manager/batch/2024-02-01/applicationpackage/client.go create mode 100644 resource-manager/batch/2024-02-01/applicationpackage/constants.go create mode 100644 resource-manager/batch/2024-02-01/applicationpackage/id_application.go create mode 100644 resource-manager/batch/2024-02-01/applicationpackage/id_application_test.go create mode 100644 resource-manager/batch/2024-02-01/applicationpackage/id_version.go create mode 100644 resource-manager/batch/2024-02-01/applicationpackage/id_version_test.go create mode 100644 resource-manager/batch/2024-02-01/applicationpackage/method_activate.go create mode 100644 resource-manager/batch/2024-02-01/applicationpackage/method_create.go create mode 100644 resource-manager/batch/2024-02-01/applicationpackage/method_delete.go create mode 100644 resource-manager/batch/2024-02-01/applicationpackage/method_get.go create mode 100644 resource-manager/batch/2024-02-01/applicationpackage/method_list.go create mode 100644 resource-manager/batch/2024-02-01/applicationpackage/model_activateapplicationpackageparameters.go create mode 100644 resource-manager/batch/2024-02-01/applicationpackage/model_applicationpackage.go create mode 100644 resource-manager/batch/2024-02-01/applicationpackage/model_applicationpackageproperties.go create mode 100644 resource-manager/batch/2024-02-01/applicationpackage/predicates.go create mode 100644 resource-manager/batch/2024-02-01/applicationpackage/version.go create mode 100644 resource-manager/batch/2024-02-01/batchaccount/README.md create mode 100644 resource-manager/batch/2024-02-01/batchaccount/client.go create mode 100644 resource-manager/batch/2024-02-01/batchaccount/constants.go create mode 100644 resource-manager/batch/2024-02-01/batchaccount/id_batchaccount.go create mode 100644 resource-manager/batch/2024-02-01/batchaccount/id_batchaccount_test.go create mode 100644 resource-manager/batch/2024-02-01/batchaccount/method_create.go create mode 100644 resource-manager/batch/2024-02-01/batchaccount/method_delete.go create mode 100644 resource-manager/batch/2024-02-01/batchaccount/method_get.go create mode 100644 resource-manager/batch/2024-02-01/batchaccount/method_getkeys.go create mode 100644 resource-manager/batch/2024-02-01/batchaccount/method_list.go create mode 100644 resource-manager/batch/2024-02-01/batchaccount/method_listbyresourcegroup.go create mode 100644 resource-manager/batch/2024-02-01/batchaccount/method_listoutboundnetworkdependenciesendpoints.go create mode 100644 resource-manager/batch/2024-02-01/batchaccount/method_regeneratekey.go create mode 100644 resource-manager/batch/2024-02-01/batchaccount/method_synchronizeautostoragekeys.go create mode 100644 resource-manager/batch/2024-02-01/batchaccount/method_update.go create mode 100644 resource-manager/batch/2024-02-01/batchaccount/model_autostoragebaseproperties.go create mode 100644 resource-manager/batch/2024-02-01/batchaccount/model_autostorageproperties.go create mode 100644 resource-manager/batch/2024-02-01/batchaccount/model_batchaccount.go create mode 100644 resource-manager/batch/2024-02-01/batchaccount/model_batchaccountcreateparameters.go create mode 100644 resource-manager/batch/2024-02-01/batchaccount/model_batchaccountcreateproperties.go create mode 100644 resource-manager/batch/2024-02-01/batchaccount/model_batchaccountkeys.go create mode 100644 resource-manager/batch/2024-02-01/batchaccount/model_batchaccountproperties.go create mode 100644 resource-manager/batch/2024-02-01/batchaccount/model_batchaccountregeneratekeyparameters.go create mode 100644 resource-manager/batch/2024-02-01/batchaccount/model_batchaccountupdateparameters.go create mode 100644 resource-manager/batch/2024-02-01/batchaccount/model_batchaccountupdateproperties.go create mode 100644 resource-manager/batch/2024-02-01/batchaccount/model_computenodeidentityreference.go create mode 100644 resource-manager/batch/2024-02-01/batchaccount/model_encryptionproperties.go create mode 100644 resource-manager/batch/2024-02-01/batchaccount/model_endpointaccessprofile.go create mode 100644 resource-manager/batch/2024-02-01/batchaccount/model_endpointdependency.go create mode 100644 resource-manager/batch/2024-02-01/batchaccount/model_endpointdetail.go create mode 100644 resource-manager/batch/2024-02-01/batchaccount/model_iprule.go create mode 100644 resource-manager/batch/2024-02-01/batchaccount/model_keyvaultproperties.go create mode 100644 resource-manager/batch/2024-02-01/batchaccount/model_keyvaultreference.go create mode 100644 resource-manager/batch/2024-02-01/batchaccount/model_networkprofile.go create mode 100644 resource-manager/batch/2024-02-01/batchaccount/model_outboundenvironmentendpoint.go create mode 100644 resource-manager/batch/2024-02-01/batchaccount/model_privateendpoint.go create mode 100644 resource-manager/batch/2024-02-01/batchaccount/model_privateendpointconnection.go create mode 100644 resource-manager/batch/2024-02-01/batchaccount/model_privateendpointconnectionproperties.go create mode 100644 resource-manager/batch/2024-02-01/batchaccount/model_privatelinkserviceconnectionstate.go create mode 100644 resource-manager/batch/2024-02-01/batchaccount/model_virtualmachinefamilycorequota.go create mode 100644 resource-manager/batch/2024-02-01/batchaccount/predicates.go create mode 100644 resource-manager/batch/2024-02-01/batchaccount/version.go create mode 100644 resource-manager/batch/2024-02-01/batchmanagements/README.md create mode 100644 resource-manager/batch/2024-02-01/batchmanagements/client.go create mode 100644 resource-manager/batch/2024-02-01/batchmanagements/constants.go create mode 100644 resource-manager/batch/2024-02-01/batchmanagements/id_batchaccount.go create mode 100644 resource-manager/batch/2024-02-01/batchmanagements/id_batchaccount_test.go create mode 100644 resource-manager/batch/2024-02-01/batchmanagements/id_detector.go create mode 100644 resource-manager/batch/2024-02-01/batchmanagements/id_detector_test.go create mode 100644 resource-manager/batch/2024-02-01/batchmanagements/id_location.go create mode 100644 resource-manager/batch/2024-02-01/batchmanagements/id_location_test.go create mode 100644 resource-manager/batch/2024-02-01/batchmanagements/method_batchaccountgetdetector.go create mode 100644 resource-manager/batch/2024-02-01/batchmanagements/method_batchaccountlistdetectors.go create mode 100644 resource-manager/batch/2024-02-01/batchmanagements/method_locationchecknameavailability.go create mode 100644 resource-manager/batch/2024-02-01/batchmanagements/model_checknameavailabilityparameters.go create mode 100644 resource-manager/batch/2024-02-01/batchmanagements/model_checknameavailabilityresult.go create mode 100644 resource-manager/batch/2024-02-01/batchmanagements/model_detectorresponse.go create mode 100644 resource-manager/batch/2024-02-01/batchmanagements/model_detectorresponseproperties.go create mode 100644 resource-manager/batch/2024-02-01/batchmanagements/predicates.go create mode 100644 resource-manager/batch/2024-02-01/batchmanagements/version.go create mode 100644 resource-manager/batch/2024-02-01/certificate/README.md create mode 100644 resource-manager/batch/2024-02-01/certificate/client.go create mode 100644 resource-manager/batch/2024-02-01/certificate/constants.go create mode 100644 resource-manager/batch/2024-02-01/certificate/id_batchaccount.go create mode 100644 resource-manager/batch/2024-02-01/certificate/id_batchaccount_test.go create mode 100644 resource-manager/batch/2024-02-01/certificate/id_certificate.go create mode 100644 resource-manager/batch/2024-02-01/certificate/id_certificate_test.go create mode 100644 resource-manager/batch/2024-02-01/certificate/method_canceldeletion.go create mode 100644 resource-manager/batch/2024-02-01/certificate/method_create.go create mode 100644 resource-manager/batch/2024-02-01/certificate/method_delete.go create mode 100644 resource-manager/batch/2024-02-01/certificate/method_get.go create mode 100644 resource-manager/batch/2024-02-01/certificate/method_listbybatchaccount.go create mode 100644 resource-manager/batch/2024-02-01/certificate/method_update.go create mode 100644 resource-manager/batch/2024-02-01/certificate/model_certificate.go create mode 100644 resource-manager/batch/2024-02-01/certificate/model_certificatecreateorupdateparameters.go create mode 100644 resource-manager/batch/2024-02-01/certificate/model_certificatecreateorupdateproperties.go create mode 100644 resource-manager/batch/2024-02-01/certificate/model_certificateproperties.go create mode 100644 resource-manager/batch/2024-02-01/certificate/model_deletecertificateerror.go create mode 100644 resource-manager/batch/2024-02-01/certificate/predicates.go create mode 100644 resource-manager/batch/2024-02-01/certificate/version.go create mode 100644 resource-manager/batch/2024-02-01/client.go create mode 100644 resource-manager/batch/2024-02-01/location/README.md create mode 100644 resource-manager/batch/2024-02-01/location/client.go create mode 100644 resource-manager/batch/2024-02-01/location/id_location.go create mode 100644 resource-manager/batch/2024-02-01/location/id_location_test.go create mode 100644 resource-manager/batch/2024-02-01/location/method_getquotas.go create mode 100644 resource-manager/batch/2024-02-01/location/method_listsupportedcloudserviceskus.go create mode 100644 resource-manager/batch/2024-02-01/location/method_listsupportedvirtualmachineskus.go create mode 100644 resource-manager/batch/2024-02-01/location/model_batchlocationquota.go create mode 100644 resource-manager/batch/2024-02-01/location/model_skucapability.go create mode 100644 resource-manager/batch/2024-02-01/location/model_supportedsku.go create mode 100644 resource-manager/batch/2024-02-01/location/predicates.go create mode 100644 resource-manager/batch/2024-02-01/location/version.go create mode 100644 resource-manager/batch/2024-02-01/pool/README.md create mode 100644 resource-manager/batch/2024-02-01/pool/client.go create mode 100644 resource-manager/batch/2024-02-01/pool/constants.go create mode 100644 resource-manager/batch/2024-02-01/pool/id_batchaccount.go create mode 100644 resource-manager/batch/2024-02-01/pool/id_batchaccount_test.go create mode 100644 resource-manager/batch/2024-02-01/pool/id_pool.go create mode 100644 resource-manager/batch/2024-02-01/pool/id_pool_test.go create mode 100644 resource-manager/batch/2024-02-01/pool/method_create.go create mode 100644 resource-manager/batch/2024-02-01/pool/method_delete.go create mode 100644 resource-manager/batch/2024-02-01/pool/method_disableautoscale.go create mode 100644 resource-manager/batch/2024-02-01/pool/method_get.go create mode 100644 resource-manager/batch/2024-02-01/pool/method_listbybatchaccount.go create mode 100644 resource-manager/batch/2024-02-01/pool/method_stopresize.go create mode 100644 resource-manager/batch/2024-02-01/pool/method_update.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_applicationpackagereference.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_automaticosupgradepolicy.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_autoscalerun.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_autoscalerunerror.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_autoscalesettings.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_autouserspecification.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_azureblobfilesystemconfiguration.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_azurefileshareconfiguration.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_certificatereference.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_cifsmountconfiguration.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_cloudserviceconfiguration.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_computenodeidentityreference.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_containerconfiguration.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_containerregistry.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_datadisk.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_deploymentconfiguration.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_diffdisksettings.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_diskencryptionconfiguration.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_environmentsetting.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_fixedscalesettings.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_imagereference.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_inboundnatpool.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_linuxuserconfiguration.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_manageddisk.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_metadataitem.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_mountconfiguration.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_networkconfiguration.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_networksecuritygrouprule.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_nfsmountconfiguration.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_nodeplacementconfiguration.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_osdisk.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_pool.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_poolendpointconfiguration.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_poolproperties.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_publicipaddressconfiguration.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_resizeerror.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_resizeoperationstatus.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_resourcefile.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_rollingupgradepolicy.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_scalesettings.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_securityprofile.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_serviceartifactreference.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_starttask.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_taskcontainersettings.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_taskschedulingpolicy.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_uefisettings.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_upgradepolicy.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_useraccount.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_useridentity.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_virtualmachineconfiguration.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_vmextension.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_windowsconfiguration.go create mode 100644 resource-manager/batch/2024-02-01/pool/model_windowsuserconfiguration.go create mode 100644 resource-manager/batch/2024-02-01/pool/predicates.go create mode 100644 resource-manager/batch/2024-02-01/pool/version.go create mode 100644 resource-manager/batch/2024-02-01/privateendpointconnection/README.md create mode 100644 resource-manager/batch/2024-02-01/privateendpointconnection/client.go create mode 100644 resource-manager/batch/2024-02-01/privateendpointconnection/constants.go create mode 100644 resource-manager/batch/2024-02-01/privateendpointconnection/id_batchaccount.go create mode 100644 resource-manager/batch/2024-02-01/privateendpointconnection/id_batchaccount_test.go create mode 100644 resource-manager/batch/2024-02-01/privateendpointconnection/id_privateendpointconnection.go create mode 100644 resource-manager/batch/2024-02-01/privateendpointconnection/id_privateendpointconnection_test.go create mode 100644 resource-manager/batch/2024-02-01/privateendpointconnection/method_delete.go create mode 100644 resource-manager/batch/2024-02-01/privateendpointconnection/method_get.go create mode 100644 resource-manager/batch/2024-02-01/privateendpointconnection/method_listbybatchaccount.go create mode 100644 resource-manager/batch/2024-02-01/privateendpointconnection/method_update.go create mode 100644 resource-manager/batch/2024-02-01/privateendpointconnection/model_privateendpoint.go create mode 100644 resource-manager/batch/2024-02-01/privateendpointconnection/model_privateendpointconnection.go create mode 100644 resource-manager/batch/2024-02-01/privateendpointconnection/model_privateendpointconnectionproperties.go create mode 100644 resource-manager/batch/2024-02-01/privateendpointconnection/model_privatelinkserviceconnectionstate.go create mode 100644 resource-manager/batch/2024-02-01/privateendpointconnection/predicates.go create mode 100644 resource-manager/batch/2024-02-01/privateendpointconnection/version.go create mode 100644 resource-manager/batch/2024-02-01/privatelinkresource/README.md create mode 100644 resource-manager/batch/2024-02-01/privatelinkresource/client.go create mode 100644 resource-manager/batch/2024-02-01/privatelinkresource/id_batchaccount.go create mode 100644 resource-manager/batch/2024-02-01/privatelinkresource/id_batchaccount_test.go create mode 100644 resource-manager/batch/2024-02-01/privatelinkresource/id_privatelinkresource.go create mode 100644 resource-manager/batch/2024-02-01/privatelinkresource/id_privatelinkresource_test.go create mode 100644 resource-manager/batch/2024-02-01/privatelinkresource/method_get.go create mode 100644 resource-manager/batch/2024-02-01/privatelinkresource/method_listbybatchaccount.go create mode 100644 resource-manager/batch/2024-02-01/privatelinkresource/model_privatelinkresource.go create mode 100644 resource-manager/batch/2024-02-01/privatelinkresource/model_privatelinkresourceproperties.go create mode 100644 resource-manager/batch/2024-02-01/privatelinkresource/predicates.go create mode 100644 resource-manager/batch/2024-02-01/privatelinkresource/version.go diff --git a/resource-manager/batch/2024-02-01/application/README.md b/resource-manager/batch/2024-02-01/application/README.md new file mode 100644 index 00000000000..e0a6988f9d6 --- /dev/null +++ b/resource-manager/batch/2024-02-01/application/README.md @@ -0,0 +1,111 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/batch/2024-02-01/application` Documentation + +The `application` SDK allows for interaction with the Azure Resource Manager Service `batch` (API Version `2024-02-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/batch/2024-02-01/application" +``` + + +### Client Initialization + +```go +client := application.NewApplicationClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ApplicationClient.Create` + +```go +ctx := context.TODO() +id := application.NewApplicationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue", "applicationValue") + +payload := application.Application{ + // ... +} + + +read, err := client.Create(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ApplicationClient.Delete` + +```go +ctx := context.TODO() +id := application.NewApplicationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue", "applicationValue") + +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: `ApplicationClient.Get` + +```go +ctx := context.TODO() +id := application.NewApplicationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue", "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.NewBatchAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue") + +// alternatively `client.List(ctx, id, application.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, application.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ApplicationClient.Update` + +```go +ctx := context.TODO() +id := application.NewApplicationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue", "applicationValue") + +payload := application.Application{ + // ... +} + + +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/batch/2024-02-01/application/client.go b/resource-manager/batch/2024-02-01/application/client.go new file mode 100644 index 00000000000..c87320630e0 --- /dev/null +++ b/resource-manager/batch/2024-02-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/batch/2024-02-01/application/id_application.go b/resource-manager/batch/2024-02-01/application/id_application.go new file mode 100644 index 00000000000..bfb6e43d732 --- /dev/null +++ b/resource-manager/batch/2024-02-01/application/id_application.go @@ -0,0 +1,134 @@ +package application + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ApplicationId{} + +// ApplicationId is a struct representing the Resource ID for a Application +type ApplicationId struct { + SubscriptionId string + ResourceGroupName string + BatchAccountName string + ApplicationName string +} + +// NewApplicationID returns a new ApplicationId struct +func NewApplicationID(subscriptionId string, resourceGroupName string, batchAccountName string, applicationName string) ApplicationId { + return ApplicationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + BatchAccountName: batchAccountName, + 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.BatchAccountName, ok = input.Parsed["batchAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "batchAccountName", 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.Batch/batchAccounts/%s/applications/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.BatchAccountName, 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("staticMicrosoftBatch", "Microsoft.Batch", "Microsoft.Batch"), + resourceids.StaticSegment("staticBatchAccounts", "batchAccounts", "batchAccounts"), + resourceids.UserSpecifiedSegment("batchAccountName", "batchAccountValue"), + 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("Batch Account Name: %q", id.BatchAccountName), + fmt.Sprintf("Application Name: %q", id.ApplicationName), + } + return fmt.Sprintf("Application (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/batch/2024-02-01/application/id_application_test.go b/resource-manager/batch/2024-02-01/application/id_application_test.go new file mode 100644 index 00000000000..b6d3eb033c0 --- /dev/null +++ b/resource-manager/batch/2024-02-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", "batchAccountValue", "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.BatchAccountName != "batchAccountValue" { + t.Fatalf("Expected %q but got %q for Segment 'BatchAccountName'", id.BatchAccountName, "batchAccountValue") + } + + 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", "batchAccountValue", "applicationValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/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.Batch", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/applications", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/applications/applicationValue", + Expected: &ApplicationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BatchAccountName: "batchAccountValue", + ApplicationName: "applicationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/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.BatchAccountName != v.Expected.BatchAccountName { + t.Fatalf("Expected %q but got %q for BatchAccountName", v.Expected.BatchAccountName, actual.BatchAccountName) + } + + 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.Batch", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs/bAtChAcCoUnTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/applications", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs/bAtChAcCoUnTvAlUe/aPpLiCaTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/applications/applicationValue", + Expected: &ApplicationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BatchAccountName: "batchAccountValue", + ApplicationName: "applicationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/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.bAtCh/bAtChAcCoUnTs/bAtChAcCoUnTvAlUe/aPpLiCaTiOnS/aPpLiCaTiOnVaLuE", + Expected: &ApplicationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + BatchAccountName: "bAtChAcCoUnTvAlUe", + 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.bAtCh/bAtChAcCoUnTs/bAtChAcCoUnTvAlUe/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.BatchAccountName != v.Expected.BatchAccountName { + t.Fatalf("Expected %q but got %q for BatchAccountName", v.Expected.BatchAccountName, actual.BatchAccountName) + } + + 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/batch/2024-02-01/application/id_batchaccount.go b/resource-manager/batch/2024-02-01/application/id_batchaccount.go new file mode 100644 index 00000000000..818f50c55ed --- /dev/null +++ b/resource-manager/batch/2024-02-01/application/id_batchaccount.go @@ -0,0 +1,125 @@ +package application + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &BatchAccountId{} + +// BatchAccountId is a struct representing the Resource ID for a Batch Account +type BatchAccountId struct { + SubscriptionId string + ResourceGroupName string + BatchAccountName string +} + +// NewBatchAccountID returns a new BatchAccountId struct +func NewBatchAccountID(subscriptionId string, resourceGroupName string, batchAccountName string) BatchAccountId { + return BatchAccountId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + BatchAccountName: batchAccountName, + } +} + +// ParseBatchAccountID parses 'input' into a BatchAccountId +func ParseBatchAccountID(input string) (*BatchAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&BatchAccountId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BatchAccountId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBatchAccountIDInsensitively parses 'input' case-insensitively into a BatchAccountId +// note: this method should only be used for API response data and not user input +func ParseBatchAccountIDInsensitively(input string) (*BatchAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&BatchAccountId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BatchAccountId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BatchAccountId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.BatchAccountName, ok = input.Parsed["batchAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "batchAccountName", input) + } + + return nil +} + +// ValidateBatchAccountID checks that 'input' can be parsed as a Batch Account ID +func ValidateBatchAccountID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseBatchAccountID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Batch Account ID +func (id BatchAccountId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Batch/batchAccounts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.BatchAccountName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Batch Account ID +func (id BatchAccountId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftBatch", "Microsoft.Batch", "Microsoft.Batch"), + resourceids.StaticSegment("staticBatchAccounts", "batchAccounts", "batchAccounts"), + resourceids.UserSpecifiedSegment("batchAccountName", "batchAccountValue"), + } +} + +// String returns a human-readable description of this Batch Account ID +func (id BatchAccountId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Batch Account Name: %q", id.BatchAccountName), + } + return fmt.Sprintf("Batch Account (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/batch/2024-02-01/application/id_batchaccount_test.go b/resource-manager/batch/2024-02-01/application/id_batchaccount_test.go new file mode 100644 index 00000000000..fe9d02cd6f9 --- /dev/null +++ b/resource-manager/batch/2024-02-01/application/id_batchaccount_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 = &BatchAccountId{} + +func TestNewBatchAccountID(t *testing.T) { + id := NewBatchAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.BatchAccountName != "batchAccountValue" { + t.Fatalf("Expected %q but got %q for Segment 'BatchAccountName'", id.BatchAccountName, "batchAccountValue") + } +} + +func TestFormatBatchAccountID(t *testing.T) { + actual := NewBatchAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBatchAccountID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BatchAccountId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue", + Expected: &BatchAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BatchAccountName: "batchAccountValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBatchAccountID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BatchAccountName != v.Expected.BatchAccountName { + t.Fatalf("Expected %q but got %q for BatchAccountName", v.Expected.BatchAccountName, actual.BatchAccountName) + } + + } +} + +func TestParseBatchAccountIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BatchAccountId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue", + Expected: &BatchAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BatchAccountName: "batchAccountValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs/bAtChAcCoUnTvAlUe", + Expected: &BatchAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + BatchAccountName: "bAtChAcCoUnTvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs/bAtChAcCoUnTvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBatchAccountIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BatchAccountName != v.Expected.BatchAccountName { + t.Fatalf("Expected %q but got %q for BatchAccountName", v.Expected.BatchAccountName, actual.BatchAccountName) + } + + } +} + +func TestSegmentsForBatchAccountId(t *testing.T) { + segments := BatchAccountId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BatchAccountId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/batch/2024-02-01/application/method_create.go b/resource-manager/batch/2024-02-01/application/method_create.go new file mode 100644 index 00000000000..969b8c3f01e --- /dev/null +++ b/resource-manager/batch/2024-02-01/application/method_create.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 CreateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Application +} + +// Create ... +func (c ApplicationClient) Create(ctx context.Context, id ApplicationId, input Application) (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 Application + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/batch/2024-02-01/application/method_delete.go b/resource-manager/batch/2024-02-01/application/method_delete.go new file mode 100644 index 00000000000..37bef666ec7 --- /dev/null +++ b/resource-manager/batch/2024-02-01/application/method_delete.go @@ -0,0 +1,47 @@ +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 DeleteOperationResponse struct { + 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.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/batch/2024-02-01/application/method_get.go b/resource-manager/batch/2024-02-01/application/method_get.go new file mode 100644 index 00000000000..4098c587ba5 --- /dev/null +++ b/resource-manager/batch/2024-02-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 *Application +} + +// 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 Application + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/batch/2024-02-01/application/method_list.go b/resource-manager/batch/2024-02-01/application/method_list.go new file mode 100644 index 00000000000..8ffdc21baba --- /dev/null +++ b/resource-manager/batch/2024-02-01/application/method_list.go @@ -0,0 +1,119 @@ +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 *[]Application +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Application +} + +type ListOperationOptions struct { + Maxresults *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.Maxresults != nil { + out.Append("maxresults", fmt.Sprintf("%v", *o.Maxresults)) + } + return &out +} + +// List ... +func (c ApplicationClient) List(ctx context.Context, id BatchAccountId, 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/applications", 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 *[]Application `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 BatchAccountId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, ApplicationOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApplicationClient) ListCompleteMatchingPredicate(ctx context.Context, id BatchAccountId, options ListOperationOptions, predicate ApplicationOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Application, 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/batch/2024-02-01/application/method_update.go b/resource-manager/batch/2024-02-01/application/method_update.go new file mode 100644 index 00000000000..f70ac75de33 --- /dev/null +++ b/resource-manager/batch/2024-02-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 *Application +} + +// Update ... +func (c ApplicationClient) Update(ctx context.Context, id ApplicationId, input Application) (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 Application + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/batch/2024-02-01/application/model_application.go b/resource-manager/batch/2024-02-01/application/model_application.go new file mode 100644 index 00000000000..0d89670c2c7 --- /dev/null +++ b/resource-manager/batch/2024-02-01/application/model_application.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 Application struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/application/model_applicationproperties.go b/resource-manager/batch/2024-02-01/application/model_applicationproperties.go new file mode 100644 index 00000000000..976af8379d8 --- /dev/null +++ b/resource-manager/batch/2024-02-01/application/model_applicationproperties.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 ApplicationProperties struct { + AllowUpdates *bool `json:"allowUpdates,omitempty"` + DefaultVersion *string `json:"defaultVersion,omitempty"` + DisplayName *string `json:"displayName,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/application/predicates.go b/resource-manager/batch/2024-02-01/application/predicates.go new file mode 100644 index 00000000000..07f37439788 --- /dev/null +++ b/resource-manager/batch/2024-02-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 ApplicationOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p ApplicationOperationPredicate) Matches(input Application) 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.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/batch/2024-02-01/application/version.go b/resource-manager/batch/2024-02-01/application/version.go new file mode 100644 index 00000000000..3e95f1248e9 --- /dev/null +++ b/resource-manager/batch/2024-02-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-02-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/application/%s", defaultApiVersion) +} diff --git a/resource-manager/batch/2024-02-01/applicationpackage/README.md b/resource-manager/batch/2024-02-01/applicationpackage/README.md new file mode 100644 index 00000000000..c4699501362 --- /dev/null +++ b/resource-manager/batch/2024-02-01/applicationpackage/README.md @@ -0,0 +1,111 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/batch/2024-02-01/applicationpackage` Documentation + +The `applicationpackage` SDK allows for interaction with the Azure Resource Manager Service `batch` (API Version `2024-02-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/batch/2024-02-01/applicationpackage" +``` + + +### Client Initialization + +```go +client := applicationpackage.NewApplicationPackageClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ApplicationPackageClient.Activate` + +```go +ctx := context.TODO() +id := applicationpackage.NewVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue", "applicationValue", "versionValue") + +payload := applicationpackage.ActivateApplicationPackageParameters{ + // ... +} + + +read, err := client.Activate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ApplicationPackageClient.Create` + +```go +ctx := context.TODO() +id := applicationpackage.NewVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue", "applicationValue", "versionValue") + +payload := applicationpackage.ApplicationPackage{ + // ... +} + + +read, err := client.Create(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ApplicationPackageClient.Delete` + +```go +ctx := context.TODO() +id := applicationpackage.NewVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue", "applicationValue", "versionValue") + +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: `ApplicationPackageClient.Get` + +```go +ctx := context.TODO() +id := applicationpackage.NewVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue", "applicationValue", "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: `ApplicationPackageClient.List` + +```go +ctx := context.TODO() +id := applicationpackage.NewApplicationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue", "applicationValue") + +// alternatively `client.List(ctx, id, applicationpackage.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, applicationpackage.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/batch/2024-02-01/applicationpackage/client.go b/resource-manager/batch/2024-02-01/applicationpackage/client.go new file mode 100644 index 00000000000..94884d9d83e --- /dev/null +++ b/resource-manager/batch/2024-02-01/applicationpackage/client.go @@ -0,0 +1,26 @@ +package applicationpackage + +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 ApplicationPackageClient struct { + Client *resourcemanager.Client +} + +func NewApplicationPackageClientWithBaseURI(sdkApi sdkEnv.Api) (*ApplicationPackageClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "applicationpackage", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApplicationPackageClient: %+v", err) + } + + return &ApplicationPackageClient{ + Client: client, + }, nil +} diff --git a/resource-manager/batch/2024-02-01/applicationpackage/constants.go b/resource-manager/batch/2024-02-01/applicationpackage/constants.go new file mode 100644 index 00000000000..f994c2729ac --- /dev/null +++ b/resource-manager/batch/2024-02-01/applicationpackage/constants.go @@ -0,0 +1,51 @@ +package applicationpackage + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PackageState string + +const ( + PackageStateActive PackageState = "Active" + PackageStatePending PackageState = "Pending" +) + +func PossibleValuesForPackageState() []string { + return []string{ + string(PackageStateActive), + string(PackageStatePending), + } +} + +func (s *PackageState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePackageState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePackageState(input string) (*PackageState, error) { + vals := map[string]PackageState{ + "active": PackageStateActive, + "pending": PackageStatePending, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PackageState(input) + return &out, nil +} diff --git a/resource-manager/batch/2024-02-01/applicationpackage/id_application.go b/resource-manager/batch/2024-02-01/applicationpackage/id_application.go new file mode 100644 index 00000000000..1e5afa32750 --- /dev/null +++ b/resource-manager/batch/2024-02-01/applicationpackage/id_application.go @@ -0,0 +1,134 @@ +package applicationpackage + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ApplicationId{} + +// ApplicationId is a struct representing the Resource ID for a Application +type ApplicationId struct { + SubscriptionId string + ResourceGroupName string + BatchAccountName string + ApplicationName string +} + +// NewApplicationID returns a new ApplicationId struct +func NewApplicationID(subscriptionId string, resourceGroupName string, batchAccountName string, applicationName string) ApplicationId { + return ApplicationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + BatchAccountName: batchAccountName, + 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.BatchAccountName, ok = input.Parsed["batchAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "batchAccountName", 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.Batch/batchAccounts/%s/applications/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.BatchAccountName, 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("staticMicrosoftBatch", "Microsoft.Batch", "Microsoft.Batch"), + resourceids.StaticSegment("staticBatchAccounts", "batchAccounts", "batchAccounts"), + resourceids.UserSpecifiedSegment("batchAccountName", "batchAccountValue"), + 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("Batch Account Name: %q", id.BatchAccountName), + fmt.Sprintf("Application Name: %q", id.ApplicationName), + } + return fmt.Sprintf("Application (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/batch/2024-02-01/applicationpackage/id_application_test.go b/resource-manager/batch/2024-02-01/applicationpackage/id_application_test.go new file mode 100644 index 00000000000..d60db362bf3 --- /dev/null +++ b/resource-manager/batch/2024-02-01/applicationpackage/id_application_test.go @@ -0,0 +1,327 @@ +package applicationpackage + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (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", "batchAccountValue", "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.BatchAccountName != "batchAccountValue" { + t.Fatalf("Expected %q but got %q for Segment 'BatchAccountName'", id.BatchAccountName, "batchAccountValue") + } + + 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", "batchAccountValue", "applicationValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/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.Batch", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/applications", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/applications/applicationValue", + Expected: &ApplicationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BatchAccountName: "batchAccountValue", + ApplicationName: "applicationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/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.BatchAccountName != v.Expected.BatchAccountName { + t.Fatalf("Expected %q but got %q for BatchAccountName", v.Expected.BatchAccountName, actual.BatchAccountName) + } + + 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.Batch", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs/bAtChAcCoUnTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/applications", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs/bAtChAcCoUnTvAlUe/aPpLiCaTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/applications/applicationValue", + Expected: &ApplicationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BatchAccountName: "batchAccountValue", + ApplicationName: "applicationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/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.bAtCh/bAtChAcCoUnTs/bAtChAcCoUnTvAlUe/aPpLiCaTiOnS/aPpLiCaTiOnVaLuE", + Expected: &ApplicationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + BatchAccountName: "bAtChAcCoUnTvAlUe", + 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.bAtCh/bAtChAcCoUnTs/bAtChAcCoUnTvAlUe/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.BatchAccountName != v.Expected.BatchAccountName { + t.Fatalf("Expected %q but got %q for BatchAccountName", v.Expected.BatchAccountName, actual.BatchAccountName) + } + + 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/batch/2024-02-01/applicationpackage/id_version.go b/resource-manager/batch/2024-02-01/applicationpackage/id_version.go new file mode 100644 index 00000000000..ab92247b2ca --- /dev/null +++ b/resource-manager/batch/2024-02-01/applicationpackage/id_version.go @@ -0,0 +1,143 @@ +package applicationpackage + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VersionId{} + +// VersionId is a struct representing the Resource ID for a Version +type VersionId struct { + SubscriptionId string + ResourceGroupName string + BatchAccountName string + ApplicationName string + VersionName string +} + +// NewVersionID returns a new VersionId struct +func NewVersionID(subscriptionId string, resourceGroupName string, batchAccountName string, applicationName string, versionName string) VersionId { + return VersionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + BatchAccountName: batchAccountName, + ApplicationName: applicationName, + 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.BatchAccountName, ok = input.Parsed["batchAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "batchAccountName", input) + } + + if id.ApplicationName, ok = input.Parsed["applicationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "applicationName", 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.Batch/batchAccounts/%s/applications/%s/versions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.BatchAccountName, id.ApplicationName, 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("staticMicrosoftBatch", "Microsoft.Batch", "Microsoft.Batch"), + resourceids.StaticSegment("staticBatchAccounts", "batchAccounts", "batchAccounts"), + resourceids.UserSpecifiedSegment("batchAccountName", "batchAccountValue"), + resourceids.StaticSegment("staticApplications", "applications", "applications"), + resourceids.UserSpecifiedSegment("applicationName", "applicationValue"), + 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("Batch Account Name: %q", id.BatchAccountName), + fmt.Sprintf("Application Name: %q", id.ApplicationName), + fmt.Sprintf("Version Name: %q", id.VersionName), + } + return fmt.Sprintf("Version (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/batch/2024-02-01/applicationpackage/id_version_test.go b/resource-manager/batch/2024-02-01/applicationpackage/id_version_test.go new file mode 100644 index 00000000000..8bf9f46e066 --- /dev/null +++ b/resource-manager/batch/2024-02-01/applicationpackage/id_version_test.go @@ -0,0 +1,372 @@ +package applicationpackage + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (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", "batchAccountValue", "applicationValue", "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.BatchAccountName != "batchAccountValue" { + t.Fatalf("Expected %q but got %q for Segment 'BatchAccountName'", id.BatchAccountName, "batchAccountValue") + } + + if id.ApplicationName != "applicationValue" { + t.Fatalf("Expected %q but got %q for Segment 'ApplicationName'", id.ApplicationName, "applicationValue") + } + + 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", "batchAccountValue", "applicationValue", "versionValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/applications/applicationValue/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.Batch", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/applications", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/applications/applicationValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/applications/applicationValue/versions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/applications/applicationValue/versions/versionValue", + Expected: &VersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BatchAccountName: "batchAccountValue", + ApplicationName: "applicationValue", + VersionName: "versionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/applications/applicationValue/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.BatchAccountName != v.Expected.BatchAccountName { + t.Fatalf("Expected %q but got %q for BatchAccountName", v.Expected.BatchAccountName, actual.BatchAccountName) + } + + if actual.ApplicationName != v.Expected.ApplicationName { + t.Fatalf("Expected %q but got %q for ApplicationName", v.Expected.ApplicationName, actual.ApplicationName) + } + + 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.Batch", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs/bAtChAcCoUnTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/applications", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs/bAtChAcCoUnTvAlUe/aPpLiCaTiOnS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/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.bAtCh/bAtChAcCoUnTs/bAtChAcCoUnTvAlUe/aPpLiCaTiOnS/aPpLiCaTiOnVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/applications/applicationValue/versions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs/bAtChAcCoUnTvAlUe/aPpLiCaTiOnS/aPpLiCaTiOnVaLuE/vErSiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/applications/applicationValue/versions/versionValue", + Expected: &VersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BatchAccountName: "batchAccountValue", + ApplicationName: "applicationValue", + VersionName: "versionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/applications/applicationValue/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.bAtCh/bAtChAcCoUnTs/bAtChAcCoUnTvAlUe/aPpLiCaTiOnS/aPpLiCaTiOnVaLuE/vErSiOnS/vErSiOnVaLuE", + Expected: &VersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + BatchAccountName: "bAtChAcCoUnTvAlUe", + ApplicationName: "aPpLiCaTiOnVaLuE", + 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.bAtCh/bAtChAcCoUnTs/bAtChAcCoUnTvAlUe/aPpLiCaTiOnS/aPpLiCaTiOnVaLuE/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.BatchAccountName != v.Expected.BatchAccountName { + t.Fatalf("Expected %q but got %q for BatchAccountName", v.Expected.BatchAccountName, actual.BatchAccountName) + } + + if actual.ApplicationName != v.Expected.ApplicationName { + t.Fatalf("Expected %q but got %q for ApplicationName", v.Expected.ApplicationName, actual.ApplicationName) + } + + 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/batch/2024-02-01/applicationpackage/method_activate.go b/resource-manager/batch/2024-02-01/applicationpackage/method_activate.go new file mode 100644 index 00000000000..75fc8bc3cb3 --- /dev/null +++ b/resource-manager/batch/2024-02-01/applicationpackage/method_activate.go @@ -0,0 +1,59 @@ +package applicationpackage + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ActivateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApplicationPackage +} + +// Activate ... +func (c ApplicationPackageClient) Activate(ctx context.Context, id VersionId, input ActivateApplicationPackageParameters) (result ActivateOperationResponse, 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 + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ApplicationPackage + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/batch/2024-02-01/applicationpackage/method_create.go b/resource-manager/batch/2024-02-01/applicationpackage/method_create.go new file mode 100644 index 00000000000..9bfa7c8bf2d --- /dev/null +++ b/resource-manager/batch/2024-02-01/applicationpackage/method_create.go @@ -0,0 +1,58 @@ +package applicationpackage + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *ApplicationPackage +} + +// Create ... +func (c ApplicationPackageClient) Create(ctx context.Context, id VersionId, input ApplicationPackage) (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 ApplicationPackage + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/batch/2024-02-01/applicationpackage/method_delete.go b/resource-manager/batch/2024-02-01/applicationpackage/method_delete.go new file mode 100644 index 00000000000..577f63a0a6f --- /dev/null +++ b/resource-manager/batch/2024-02-01/applicationpackage/method_delete.go @@ -0,0 +1,47 @@ +package applicationpackage + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 ApplicationPackageClient) Delete(ctx context.Context, id VersionId) (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/batch/2024-02-01/applicationpackage/method_get.go b/resource-manager/batch/2024-02-01/applicationpackage/method_get.go new file mode 100644 index 00000000000..580541d6477 --- /dev/null +++ b/resource-manager/batch/2024-02-01/applicationpackage/method_get.go @@ -0,0 +1,54 @@ +package applicationpackage + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *ApplicationPackage +} + +// Get ... +func (c ApplicationPackageClient) 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 ApplicationPackage + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/batch/2024-02-01/applicationpackage/method_list.go b/resource-manager/batch/2024-02-01/applicationpackage/method_list.go new file mode 100644 index 00000000000..068d0e046c8 --- /dev/null +++ b/resource-manager/batch/2024-02-01/applicationpackage/method_list.go @@ -0,0 +1,119 @@ +package applicationpackage + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]ApplicationPackage +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ApplicationPackage +} + +type ListOperationOptions struct { + Maxresults *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.Maxresults != nil { + out.Append("maxresults", fmt.Sprintf("%v", *o.Maxresults)) + } + return &out +} + +// List ... +func (c ApplicationPackageClient) List(ctx context.Context, id ApplicationId, 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 *[]ApplicationPackage `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 ApplicationPackageClient) ListComplete(ctx context.Context, id ApplicationId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, ApplicationPackageOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApplicationPackageClient) ListCompleteMatchingPredicate(ctx context.Context, id ApplicationId, options ListOperationOptions, predicate ApplicationPackageOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ApplicationPackage, 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/batch/2024-02-01/applicationpackage/model_activateapplicationpackageparameters.go b/resource-manager/batch/2024-02-01/applicationpackage/model_activateapplicationpackageparameters.go new file mode 100644 index 00000000000..9b2f15b1238 --- /dev/null +++ b/resource-manager/batch/2024-02-01/applicationpackage/model_activateapplicationpackageparameters.go @@ -0,0 +1,8 @@ +package applicationpackage + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ActivateApplicationPackageParameters struct { + Format string `json:"format"` +} diff --git a/resource-manager/batch/2024-02-01/applicationpackage/model_applicationpackage.go b/resource-manager/batch/2024-02-01/applicationpackage/model_applicationpackage.go new file mode 100644 index 00000000000..848cc05d6d1 --- /dev/null +++ b/resource-manager/batch/2024-02-01/applicationpackage/model_applicationpackage.go @@ -0,0 +1,12 @@ +package applicationpackage + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationPackage struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationPackageProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/applicationpackage/model_applicationpackageproperties.go b/resource-manager/batch/2024-02-01/applicationpackage/model_applicationpackageproperties.go new file mode 100644 index 00000000000..e49cd1f1a80 --- /dev/null +++ b/resource-manager/batch/2024-02-01/applicationpackage/model_applicationpackageproperties.go @@ -0,0 +1,42 @@ +package applicationpackage + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationPackageProperties struct { + Format *string `json:"format,omitempty"` + LastActivationTime *string `json:"lastActivationTime,omitempty"` + State *PackageState `json:"state,omitempty"` + StorageUrl *string `json:"storageUrl,omitempty"` + StorageUrlExpiry *string `json:"storageUrlExpiry,omitempty"` +} + +func (o *ApplicationPackageProperties) GetLastActivationTimeAsTime() (*time.Time, error) { + if o.LastActivationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastActivationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ApplicationPackageProperties) SetLastActivationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastActivationTime = &formatted +} + +func (o *ApplicationPackageProperties) GetStorageUrlExpiryAsTime() (*time.Time, error) { + if o.StorageUrlExpiry == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StorageUrlExpiry, "2006-01-02T15:04:05Z07:00") +} + +func (o *ApplicationPackageProperties) SetStorageUrlExpiryAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StorageUrlExpiry = &formatted +} diff --git a/resource-manager/batch/2024-02-01/applicationpackage/predicates.go b/resource-manager/batch/2024-02-01/applicationpackage/predicates.go new file mode 100644 index 00000000000..8841aed23a6 --- /dev/null +++ b/resource-manager/batch/2024-02-01/applicationpackage/predicates.go @@ -0,0 +1,32 @@ +package applicationpackage + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationPackageOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p ApplicationPackageOperationPredicate) Matches(input ApplicationPackage) 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.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/batch/2024-02-01/applicationpackage/version.go b/resource-manager/batch/2024-02-01/applicationpackage/version.go new file mode 100644 index 00000000000..b9d20ad928e --- /dev/null +++ b/resource-manager/batch/2024-02-01/applicationpackage/version.go @@ -0,0 +1,12 @@ +package applicationpackage + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-02-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/applicationpackage/%s", defaultApiVersion) +} diff --git a/resource-manager/batch/2024-02-01/batchaccount/README.md b/resource-manager/batch/2024-02-01/batchaccount/README.md new file mode 100644 index 00000000000..9d5db7c8fc2 --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchaccount/README.md @@ -0,0 +1,191 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/batch/2024-02-01/batchaccount` Documentation + +The `batchaccount` SDK allows for interaction with the Azure Resource Manager Service `batch` (API Version `2024-02-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/batch/2024-02-01/batchaccount" +``` + + +### Client Initialization + +```go +client := batchaccount.NewBatchAccountClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `BatchAccountClient.Create` + +```go +ctx := context.TODO() +id := batchaccount.NewBatchAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue") + +payload := batchaccount.BatchAccountCreateParameters{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `BatchAccountClient.Delete` + +```go +ctx := context.TODO() +id := batchaccount.NewBatchAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `BatchAccountClient.Get` + +```go +ctx := context.TODO() +id := batchaccount.NewBatchAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue") + +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: `BatchAccountClient.GetKeys` + +```go +ctx := context.TODO() +id := batchaccount.NewBatchAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue") + +read, err := client.GetKeys(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `BatchAccountClient.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: `BatchAccountClient.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: `BatchAccountClient.ListOutboundNetworkDependenciesEndpoints` + +```go +ctx := context.TODO() +id := batchaccount.NewBatchAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue") + +// alternatively `client.ListOutboundNetworkDependenciesEndpoints(ctx, id)` can be used to do batched pagination +items, err := client.ListOutboundNetworkDependenciesEndpointsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `BatchAccountClient.RegenerateKey` + +```go +ctx := context.TODO() +id := batchaccount.NewBatchAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue") + +payload := batchaccount.BatchAccountRegenerateKeyParameters{ + // ... +} + + +read, err := client.RegenerateKey(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `BatchAccountClient.SynchronizeAutoStorageKeys` + +```go +ctx := context.TODO() +id := batchaccount.NewBatchAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue") + +read, err := client.SynchronizeAutoStorageKeys(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `BatchAccountClient.Update` + +```go +ctx := context.TODO() +id := batchaccount.NewBatchAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue") + +payload := batchaccount.BatchAccountUpdateParameters{ + // ... +} + + +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/batch/2024-02-01/batchaccount/client.go b/resource-manager/batch/2024-02-01/batchaccount/client.go new file mode 100644 index 00000000000..607b46b2603 --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchaccount/client.go @@ -0,0 +1,26 @@ +package batchaccount + +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 BatchAccountClient struct { + Client *resourcemanager.Client +} + +func NewBatchAccountClientWithBaseURI(sdkApi sdkEnv.Api) (*BatchAccountClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "batchaccount", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating BatchAccountClient: %+v", err) + } + + return &BatchAccountClient{ + Client: client, + }, nil +} diff --git a/resource-manager/batch/2024-02-01/batchaccount/constants.go b/resource-manager/batch/2024-02-01/batchaccount/constants.go new file mode 100644 index 00000000000..ad2dba69e1a --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchaccount/constants.go @@ -0,0 +1,491 @@ +package batchaccount + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AccountKeyType string + +const ( + AccountKeyTypePrimary AccountKeyType = "Primary" + AccountKeyTypeSecondary AccountKeyType = "Secondary" +) + +func PossibleValuesForAccountKeyType() []string { + return []string{ + string(AccountKeyTypePrimary), + string(AccountKeyTypeSecondary), + } +} + +func (s *AccountKeyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAccountKeyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAccountKeyType(input string) (*AccountKeyType, error) { + vals := map[string]AccountKeyType{ + "primary": AccountKeyTypePrimary, + "secondary": AccountKeyTypeSecondary, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AccountKeyType(input) + return &out, nil +} + +type AuthenticationMode string + +const ( + AuthenticationModeAAD AuthenticationMode = "AAD" + AuthenticationModeSharedKey AuthenticationMode = "SharedKey" + AuthenticationModeTaskAuthenticationToken AuthenticationMode = "TaskAuthenticationToken" +) + +func PossibleValuesForAuthenticationMode() []string { + return []string{ + string(AuthenticationModeAAD), + string(AuthenticationModeSharedKey), + string(AuthenticationModeTaskAuthenticationToken), + } +} + +func (s *AuthenticationMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAuthenticationMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAuthenticationMode(input string) (*AuthenticationMode, error) { + vals := map[string]AuthenticationMode{ + "aad": AuthenticationModeAAD, + "sharedkey": AuthenticationModeSharedKey, + "taskauthenticationtoken": AuthenticationModeTaskAuthenticationToken, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AuthenticationMode(input) + return &out, nil +} + +type AutoStorageAuthenticationMode string + +const ( + AutoStorageAuthenticationModeBatchAccountManagedIdentity AutoStorageAuthenticationMode = "BatchAccountManagedIdentity" + AutoStorageAuthenticationModeStorageKeys AutoStorageAuthenticationMode = "StorageKeys" +) + +func PossibleValuesForAutoStorageAuthenticationMode() []string { + return []string{ + string(AutoStorageAuthenticationModeBatchAccountManagedIdentity), + string(AutoStorageAuthenticationModeStorageKeys), + } +} + +func (s *AutoStorageAuthenticationMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutoStorageAuthenticationMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutoStorageAuthenticationMode(input string) (*AutoStorageAuthenticationMode, error) { + vals := map[string]AutoStorageAuthenticationMode{ + "batchaccountmanagedidentity": AutoStorageAuthenticationModeBatchAccountManagedIdentity, + "storagekeys": AutoStorageAuthenticationModeStorageKeys, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutoStorageAuthenticationMode(input) + return &out, nil +} + +type EndpointAccessDefaultAction string + +const ( + EndpointAccessDefaultActionAllow EndpointAccessDefaultAction = "Allow" + EndpointAccessDefaultActionDeny EndpointAccessDefaultAction = "Deny" +) + +func PossibleValuesForEndpointAccessDefaultAction() []string { + return []string{ + string(EndpointAccessDefaultActionAllow), + string(EndpointAccessDefaultActionDeny), + } +} + +func (s *EndpointAccessDefaultAction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEndpointAccessDefaultAction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEndpointAccessDefaultAction(input string) (*EndpointAccessDefaultAction, error) { + vals := map[string]EndpointAccessDefaultAction{ + "allow": EndpointAccessDefaultActionAllow, + "deny": EndpointAccessDefaultActionDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EndpointAccessDefaultAction(input) + return &out, nil +} + +type IPRuleAction string + +const ( + IPRuleActionAllow IPRuleAction = "Allow" +) + +func PossibleValuesForIPRuleAction() []string { + return []string{ + string(IPRuleActionAllow), + } +} + +func (s *IPRuleAction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPRuleAction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPRuleAction(input string) (*IPRuleAction, error) { + vals := map[string]IPRuleAction{ + "allow": IPRuleActionAllow, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPRuleAction(input) + return &out, nil +} + +type KeySource string + +const ( + KeySourceMicrosoftPointBatch KeySource = "Microsoft.Batch" + KeySourceMicrosoftPointKeyVault KeySource = "Microsoft.KeyVault" +) + +func PossibleValuesForKeySource() []string { + return []string{ + string(KeySourceMicrosoftPointBatch), + string(KeySourceMicrosoftPointKeyVault), + } +} + +func (s *KeySource) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKeySource(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKeySource(input string) (*KeySource, error) { + vals := map[string]KeySource{ + "microsoft.batch": KeySourceMicrosoftPointBatch, + "microsoft.keyvault": KeySourceMicrosoftPointKeyVault, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KeySource(input) + return &out, nil +} + +type PoolAllocationMode string + +const ( + PoolAllocationModeBatchService PoolAllocationMode = "BatchService" + PoolAllocationModeUserSubscription PoolAllocationMode = "UserSubscription" +) + +func PossibleValuesForPoolAllocationMode() []string { + return []string{ + string(PoolAllocationModeBatchService), + string(PoolAllocationModeUserSubscription), + } +} + +func (s *PoolAllocationMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePoolAllocationMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePoolAllocationMode(input string) (*PoolAllocationMode, error) { + vals := map[string]PoolAllocationMode{ + "batchservice": PoolAllocationModeBatchService, + "usersubscription": PoolAllocationModeUserSubscription, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PoolAllocationMode(input) + return &out, nil +} + +type PrivateEndpointConnectionProvisioningState string + +const ( + PrivateEndpointConnectionProvisioningStateCancelled PrivateEndpointConnectionProvisioningState = "Cancelled" + PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" + PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" + PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" + PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" + PrivateEndpointConnectionProvisioningStateUpdating PrivateEndpointConnectionProvisioningState = "Updating" +) + +func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { + return []string{ + string(PrivateEndpointConnectionProvisioningStateCancelled), + string(PrivateEndpointConnectionProvisioningStateCreating), + string(PrivateEndpointConnectionProvisioningStateDeleting), + string(PrivateEndpointConnectionProvisioningStateFailed), + string(PrivateEndpointConnectionProvisioningStateSucceeded), + string(PrivateEndpointConnectionProvisioningStateUpdating), + } +} + +func (s *PrivateEndpointConnectionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointConnectionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { + vals := map[string]PrivateEndpointConnectionProvisioningState{ + "cancelled": PrivateEndpointConnectionProvisioningStateCancelled, + "creating": PrivateEndpointConnectionProvisioningStateCreating, + "deleting": PrivateEndpointConnectionProvisioningStateDeleting, + "failed": PrivateEndpointConnectionProvisioningStateFailed, + "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, + "updating": PrivateEndpointConnectionProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointConnectionProvisioningState(input) + return &out, nil +} + +type PrivateLinkServiceConnectionStatus string + +const ( + PrivateLinkServiceConnectionStatusApproved PrivateLinkServiceConnectionStatus = "Approved" + PrivateLinkServiceConnectionStatusDisconnected PrivateLinkServiceConnectionStatus = "Disconnected" + PrivateLinkServiceConnectionStatusPending PrivateLinkServiceConnectionStatus = "Pending" + PrivateLinkServiceConnectionStatusRejected PrivateLinkServiceConnectionStatus = "Rejected" +) + +func PossibleValuesForPrivateLinkServiceConnectionStatus() []string { + return []string{ + string(PrivateLinkServiceConnectionStatusApproved), + string(PrivateLinkServiceConnectionStatusDisconnected), + string(PrivateLinkServiceConnectionStatusPending), + string(PrivateLinkServiceConnectionStatusRejected), + } +} + +func (s *PrivateLinkServiceConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateLinkServiceConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateLinkServiceConnectionStatus(input string) (*PrivateLinkServiceConnectionStatus, error) { + vals := map[string]PrivateLinkServiceConnectionStatus{ + "approved": PrivateLinkServiceConnectionStatusApproved, + "disconnected": PrivateLinkServiceConnectionStatusDisconnected, + "pending": PrivateLinkServiceConnectionStatusPending, + "rejected": PrivateLinkServiceConnectionStatusRejected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateLinkServiceConnectionStatus(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCancelled ProvisioningState = "Cancelled" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateInvalid ProvisioningState = "Invalid" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCancelled), + string(ProvisioningStateCreating), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateInvalid), + 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{ + "cancelled": ProvisioningStateCancelled, + "creating": ProvisioningStateCreating, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "invalid": ProvisioningStateInvalid, + "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 PublicNetworkAccessType string + +const ( + PublicNetworkAccessTypeDisabled PublicNetworkAccessType = "Disabled" + PublicNetworkAccessTypeEnabled PublicNetworkAccessType = "Enabled" +) + +func PossibleValuesForPublicNetworkAccessType() []string { + return []string{ + string(PublicNetworkAccessTypeDisabled), + string(PublicNetworkAccessTypeEnabled), + } +} + +func (s *PublicNetworkAccessType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicNetworkAccessType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicNetworkAccessType(input string) (*PublicNetworkAccessType, error) { + vals := map[string]PublicNetworkAccessType{ + "disabled": PublicNetworkAccessTypeDisabled, + "enabled": PublicNetworkAccessTypeEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicNetworkAccessType(input) + return &out, nil +} diff --git a/resource-manager/batch/2024-02-01/batchaccount/id_batchaccount.go b/resource-manager/batch/2024-02-01/batchaccount/id_batchaccount.go new file mode 100644 index 00000000000..f80c12a7456 --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchaccount/id_batchaccount.go @@ -0,0 +1,125 @@ +package batchaccount + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &BatchAccountId{} + +// BatchAccountId is a struct representing the Resource ID for a Batch Account +type BatchAccountId struct { + SubscriptionId string + ResourceGroupName string + BatchAccountName string +} + +// NewBatchAccountID returns a new BatchAccountId struct +func NewBatchAccountID(subscriptionId string, resourceGroupName string, batchAccountName string) BatchAccountId { + return BatchAccountId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + BatchAccountName: batchAccountName, + } +} + +// ParseBatchAccountID parses 'input' into a BatchAccountId +func ParseBatchAccountID(input string) (*BatchAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&BatchAccountId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BatchAccountId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBatchAccountIDInsensitively parses 'input' case-insensitively into a BatchAccountId +// note: this method should only be used for API response data and not user input +func ParseBatchAccountIDInsensitively(input string) (*BatchAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&BatchAccountId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BatchAccountId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BatchAccountId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.BatchAccountName, ok = input.Parsed["batchAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "batchAccountName", input) + } + + return nil +} + +// ValidateBatchAccountID checks that 'input' can be parsed as a Batch Account ID +func ValidateBatchAccountID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseBatchAccountID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Batch Account ID +func (id BatchAccountId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Batch/batchAccounts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.BatchAccountName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Batch Account ID +func (id BatchAccountId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftBatch", "Microsoft.Batch", "Microsoft.Batch"), + resourceids.StaticSegment("staticBatchAccounts", "batchAccounts", "batchAccounts"), + resourceids.UserSpecifiedSegment("batchAccountName", "batchAccountValue"), + } +} + +// String returns a human-readable description of this Batch Account ID +func (id BatchAccountId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Batch Account Name: %q", id.BatchAccountName), + } + return fmt.Sprintf("Batch Account (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/batch/2024-02-01/batchaccount/id_batchaccount_test.go b/resource-manager/batch/2024-02-01/batchaccount/id_batchaccount_test.go new file mode 100644 index 00000000000..a8a9d0863f8 --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchaccount/id_batchaccount_test.go @@ -0,0 +1,282 @@ +package batchaccount + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &BatchAccountId{} + +func TestNewBatchAccountID(t *testing.T) { + id := NewBatchAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.BatchAccountName != "batchAccountValue" { + t.Fatalf("Expected %q but got %q for Segment 'BatchAccountName'", id.BatchAccountName, "batchAccountValue") + } +} + +func TestFormatBatchAccountID(t *testing.T) { + actual := NewBatchAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBatchAccountID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BatchAccountId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue", + Expected: &BatchAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BatchAccountName: "batchAccountValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBatchAccountID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BatchAccountName != v.Expected.BatchAccountName { + t.Fatalf("Expected %q but got %q for BatchAccountName", v.Expected.BatchAccountName, actual.BatchAccountName) + } + + } +} + +func TestParseBatchAccountIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BatchAccountId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue", + Expected: &BatchAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BatchAccountName: "batchAccountValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs/bAtChAcCoUnTvAlUe", + Expected: &BatchAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + BatchAccountName: "bAtChAcCoUnTvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs/bAtChAcCoUnTvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBatchAccountIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BatchAccountName != v.Expected.BatchAccountName { + t.Fatalf("Expected %q but got %q for BatchAccountName", v.Expected.BatchAccountName, actual.BatchAccountName) + } + + } +} + +func TestSegmentsForBatchAccountId(t *testing.T) { + segments := BatchAccountId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BatchAccountId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/batch/2024-02-01/batchaccount/method_create.go b/resource-manager/batch/2024-02-01/batchaccount/method_create.go new file mode 100644 index 00000000000..49dab1c2481 --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchaccount/method_create.go @@ -0,0 +1,75 @@ +package batchaccount + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *BatchAccount +} + +// Create ... +func (c BatchAccountClient) Create(ctx context.Context, id BatchAccountId, input BatchAccountCreateParameters) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateThenPoll performs Create then polls until it's completed +func (c BatchAccountClient) CreateThenPoll(ctx context.Context, id BatchAccountId, input BatchAccountCreateParameters) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/batch/2024-02-01/batchaccount/method_delete.go b/resource-manager/batch/2024-02-01/batchaccount/method_delete.go new file mode 100644 index 00000000000..5d89af89b99 --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchaccount/method_delete.go @@ -0,0 +1,71 @@ +package batchaccount + +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 BatchAccountClient) Delete(ctx context.Context, id BatchAccountId) (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 BatchAccountClient) DeleteThenPoll(ctx context.Context, id BatchAccountId) 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/batch/2024-02-01/batchaccount/method_get.go b/resource-manager/batch/2024-02-01/batchaccount/method_get.go new file mode 100644 index 00000000000..6dc844ee91a --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchaccount/method_get.go @@ -0,0 +1,54 @@ +package batchaccount + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *BatchAccount +} + +// Get ... +func (c BatchAccountClient) Get(ctx context.Context, id BatchAccountId) (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 BatchAccount + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/batch/2024-02-01/batchaccount/method_getkeys.go b/resource-manager/batch/2024-02-01/batchaccount/method_getkeys.go new file mode 100644 index 00000000000..70dd5c8da37 --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchaccount/method_getkeys.go @@ -0,0 +1,55 @@ +package batchaccount + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BatchAccountKeys +} + +// GetKeys ... +func (c BatchAccountClient) GetKeys(ctx context.Context, id BatchAccountId) (result GetKeysOperationResponse, 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 BatchAccountKeys + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/batch/2024-02-01/batchaccount/method_list.go b/resource-manager/batch/2024-02-01/batchaccount/method_list.go new file mode 100644 index 00000000000..d06a3d264a3 --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchaccount/method_list.go @@ -0,0 +1,92 @@ +package batchaccount + +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 *[]BatchAccount +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []BatchAccount +} + +// List ... +func (c BatchAccountClient) 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.Batch/batchAccounts", 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 *[]BatchAccount `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 BatchAccountClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, BatchAccountOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c BatchAccountClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate BatchAccountOperationPredicate) (result ListCompleteResult, err error) { + items := make([]BatchAccount, 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/batch/2024-02-01/batchaccount/method_listbyresourcegroup.go b/resource-manager/batch/2024-02-01/batchaccount/method_listbyresourcegroup.go new file mode 100644 index 00000000000..6ef9429fd10 --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchaccount/method_listbyresourcegroup.go @@ -0,0 +1,92 @@ +package batchaccount + +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 *[]BatchAccount +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []BatchAccount +} + +// ListByResourceGroup ... +func (c BatchAccountClient) 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.Batch/batchAccounts", 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 *[]BatchAccount `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 BatchAccountClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, BatchAccountOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c BatchAccountClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate BatchAccountOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]BatchAccount, 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/batch/2024-02-01/batchaccount/method_listoutboundnetworkdependenciesendpoints.go b/resource-manager/batch/2024-02-01/batchaccount/method_listoutboundnetworkdependenciesendpoints.go new file mode 100644 index 00000000000..2b71f03163b --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchaccount/method_listoutboundnetworkdependenciesendpoints.go @@ -0,0 +1,91 @@ +package batchaccount + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOutboundNetworkDependenciesEndpointsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]OutboundEnvironmentEndpoint +} + +type ListOutboundNetworkDependenciesEndpointsCompleteResult struct { + LatestHttpResponse *http.Response + Items []OutboundEnvironmentEndpoint +} + +// ListOutboundNetworkDependenciesEndpoints ... +func (c BatchAccountClient) ListOutboundNetworkDependenciesEndpoints(ctx context.Context, id BatchAccountId) (result ListOutboundNetworkDependenciesEndpointsOperationResponse, 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 +} + +// ListOutboundNetworkDependenciesEndpointsComplete retrieves all the results into a single object +func (c BatchAccountClient) ListOutboundNetworkDependenciesEndpointsComplete(ctx context.Context, id BatchAccountId) (ListOutboundNetworkDependenciesEndpointsCompleteResult, error) { + return c.ListOutboundNetworkDependenciesEndpointsCompleteMatchingPredicate(ctx, id, OutboundEnvironmentEndpointOperationPredicate{}) +} + +// ListOutboundNetworkDependenciesEndpointsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c BatchAccountClient) ListOutboundNetworkDependenciesEndpointsCompleteMatchingPredicate(ctx context.Context, id BatchAccountId, predicate OutboundEnvironmentEndpointOperationPredicate) (result ListOutboundNetworkDependenciesEndpointsCompleteResult, err error) { + items := make([]OutboundEnvironmentEndpoint, 0) + + resp, err := c.ListOutboundNetworkDependenciesEndpoints(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 = ListOutboundNetworkDependenciesEndpointsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/batch/2024-02-01/batchaccount/method_regeneratekey.go b/resource-manager/batch/2024-02-01/batchaccount/method_regeneratekey.go new file mode 100644 index 00000000000..6c8bd2c4f6c --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchaccount/method_regeneratekey.go @@ -0,0 +1,59 @@ +package batchaccount + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegenerateKeyOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BatchAccountKeys +} + +// RegenerateKey ... +func (c BatchAccountClient) RegenerateKey(ctx context.Context, id BatchAccountId, input BatchAccountRegenerateKeyParameters) (result RegenerateKeyOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/regenerateKeys", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model BatchAccountKeys + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/batch/2024-02-01/batchaccount/method_synchronizeautostoragekeys.go b/resource-manager/batch/2024-02-01/batchaccount/method_synchronizeautostoragekeys.go new file mode 100644 index 00000000000..7afe29d9c93 --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchaccount/method_synchronizeautostoragekeys.go @@ -0,0 +1,47 @@ +package batchaccount + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SynchronizeAutoStorageKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// SynchronizeAutoStorageKeys ... +func (c BatchAccountClient) SynchronizeAutoStorageKeys(ctx context.Context, id BatchAccountId) (result SynchronizeAutoStorageKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/syncAutoStorageKeys", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + 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/batch/2024-02-01/batchaccount/method_update.go b/resource-manager/batch/2024-02-01/batchaccount/method_update.go new file mode 100644 index 00000000000..8776d09247a --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchaccount/method_update.go @@ -0,0 +1,58 @@ +package batchaccount + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *BatchAccount +} + +// Update ... +func (c BatchAccountClient) Update(ctx context.Context, id BatchAccountId, input BatchAccountUpdateParameters) (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 BatchAccount + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/batch/2024-02-01/batchaccount/model_autostoragebaseproperties.go b/resource-manager/batch/2024-02-01/batchaccount/model_autostoragebaseproperties.go new file mode 100644 index 00000000000..00c73ad2996 --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchaccount/model_autostoragebaseproperties.go @@ -0,0 +1,10 @@ +package batchaccount + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoStorageBaseProperties struct { + AuthenticationMode *AutoStorageAuthenticationMode `json:"authenticationMode,omitempty"` + NodeIdentityReference *ComputeNodeIdentityReference `json:"nodeIdentityReference,omitempty"` + StorageAccountId string `json:"storageAccountId"` +} diff --git a/resource-manager/batch/2024-02-01/batchaccount/model_autostorageproperties.go b/resource-manager/batch/2024-02-01/batchaccount/model_autostorageproperties.go new file mode 100644 index 00000000000..a0da8c8ba39 --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchaccount/model_autostorageproperties.go @@ -0,0 +1,26 @@ +package batchaccount + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoStorageProperties struct { + AuthenticationMode *AutoStorageAuthenticationMode `json:"authenticationMode,omitempty"` + LastKeySync string `json:"lastKeySync"` + NodeIdentityReference *ComputeNodeIdentityReference `json:"nodeIdentityReference,omitempty"` + StorageAccountId string `json:"storageAccountId"` +} + +func (o *AutoStorageProperties) GetLastKeySyncAsTime() (*time.Time, error) { + return dates.ParseAsFormat(&o.LastKeySync, "2006-01-02T15:04:05Z07:00") +} + +func (o *AutoStorageProperties) SetLastKeySyncAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastKeySync = formatted +} diff --git a/resource-manager/batch/2024-02-01/batchaccount/model_batchaccount.go b/resource-manager/batch/2024-02-01/batchaccount/model_batchaccount.go new file mode 100644 index 00000000000..aa017d4a243 --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchaccount/model_batchaccount.go @@ -0,0 +1,18 @@ +package batchaccount + +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 BatchAccount struct { + Id *string `json:"id,omitempty"` + Identity *identity.SystemOrUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BatchAccountProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/batchaccount/model_batchaccountcreateparameters.go b/resource-manager/batch/2024-02-01/batchaccount/model_batchaccountcreateparameters.go new file mode 100644 index 00000000000..d4f973e727a --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchaccount/model_batchaccountcreateparameters.go @@ -0,0 +1,15 @@ +package batchaccount + +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 BatchAccountCreateParameters struct { + Identity *identity.SystemOrUserAssignedMap `json:"identity,omitempty"` + Location string `json:"location"` + Properties *BatchAccountCreateProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/batchaccount/model_batchaccountcreateproperties.go b/resource-manager/batch/2024-02-01/batchaccount/model_batchaccountcreateproperties.go new file mode 100644 index 00000000000..7d9f8b7c00d --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchaccount/model_batchaccountcreateproperties.go @@ -0,0 +1,14 @@ +package batchaccount + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BatchAccountCreateProperties struct { + AllowedAuthenticationModes *[]AuthenticationMode `json:"allowedAuthenticationModes,omitempty"` + AutoStorage *AutoStorageBaseProperties `json:"autoStorage,omitempty"` + Encryption *EncryptionProperties `json:"encryption,omitempty"` + KeyVaultReference *KeyVaultReference `json:"keyVaultReference,omitempty"` + NetworkProfile *NetworkProfile `json:"networkProfile,omitempty"` + PoolAllocationMode *PoolAllocationMode `json:"poolAllocationMode,omitempty"` + PublicNetworkAccess *PublicNetworkAccessType `json:"publicNetworkAccess,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/batchaccount/model_batchaccountkeys.go b/resource-manager/batch/2024-02-01/batchaccount/model_batchaccountkeys.go new file mode 100644 index 00000000000..791eda711d8 --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchaccount/model_batchaccountkeys.go @@ -0,0 +1,10 @@ +package batchaccount + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BatchAccountKeys struct { + AccountName *string `json:"accountName,omitempty"` + Primary *string `json:"primary,omitempty"` + Secondary *string `json:"secondary,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/batchaccount/model_batchaccountproperties.go b/resource-manager/batch/2024-02-01/batchaccount/model_batchaccountproperties.go new file mode 100644 index 00000000000..b488c2767cc --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchaccount/model_batchaccountproperties.go @@ -0,0 +1,24 @@ +package batchaccount + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BatchAccountProperties struct { + AccountEndpoint *string `json:"accountEndpoint,omitempty"` + ActiveJobAndJobScheduleQuota *int64 `json:"activeJobAndJobScheduleQuota,omitempty"` + AllowedAuthenticationModes *[]AuthenticationMode `json:"allowedAuthenticationModes,omitempty"` + AutoStorage *AutoStorageProperties `json:"autoStorage,omitempty"` + DedicatedCoreQuota *int64 `json:"dedicatedCoreQuota,omitempty"` + DedicatedCoreQuotaPerVMFamily *[]VirtualMachineFamilyCoreQuota `json:"dedicatedCoreQuotaPerVMFamily,omitempty"` + DedicatedCoreQuotaPerVMFamilyEnforced *bool `json:"dedicatedCoreQuotaPerVMFamilyEnforced,omitempty"` + Encryption *EncryptionProperties `json:"encryption,omitempty"` + KeyVaultReference *KeyVaultReference `json:"keyVaultReference,omitempty"` + LowPriorityCoreQuota *int64 `json:"lowPriorityCoreQuota,omitempty"` + NetworkProfile *NetworkProfile `json:"networkProfile,omitempty"` + NodeManagementEndpoint *string `json:"nodeManagementEndpoint,omitempty"` + PoolAllocationMode *PoolAllocationMode `json:"poolAllocationMode,omitempty"` + PoolQuota *int64 `json:"poolQuota,omitempty"` + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicNetworkAccess *PublicNetworkAccessType `json:"publicNetworkAccess,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/batchaccount/model_batchaccountregeneratekeyparameters.go b/resource-manager/batch/2024-02-01/batchaccount/model_batchaccountregeneratekeyparameters.go new file mode 100644 index 00000000000..1eea03ff5f2 --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchaccount/model_batchaccountregeneratekeyparameters.go @@ -0,0 +1,8 @@ +package batchaccount + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BatchAccountRegenerateKeyParameters struct { + KeyName AccountKeyType `json:"keyName"` +} diff --git a/resource-manager/batch/2024-02-01/batchaccount/model_batchaccountupdateparameters.go b/resource-manager/batch/2024-02-01/batchaccount/model_batchaccountupdateparameters.go new file mode 100644 index 00000000000..90422490141 --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchaccount/model_batchaccountupdateparameters.go @@ -0,0 +1,14 @@ +package batchaccount + +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 BatchAccountUpdateParameters struct { + Identity *identity.SystemOrUserAssignedMap `json:"identity,omitempty"` + Properties *BatchAccountUpdateProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/batchaccount/model_batchaccountupdateproperties.go b/resource-manager/batch/2024-02-01/batchaccount/model_batchaccountupdateproperties.go new file mode 100644 index 00000000000..e664f06d6a4 --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchaccount/model_batchaccountupdateproperties.go @@ -0,0 +1,12 @@ +package batchaccount + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BatchAccountUpdateProperties struct { + AllowedAuthenticationModes *[]AuthenticationMode `json:"allowedAuthenticationModes,omitempty"` + AutoStorage *AutoStorageBaseProperties `json:"autoStorage,omitempty"` + Encryption *EncryptionProperties `json:"encryption,omitempty"` + NetworkProfile *NetworkProfile `json:"networkProfile,omitempty"` + PublicNetworkAccess *PublicNetworkAccessType `json:"publicNetworkAccess,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/batchaccount/model_computenodeidentityreference.go b/resource-manager/batch/2024-02-01/batchaccount/model_computenodeidentityreference.go new file mode 100644 index 00000000000..99f063c16b7 --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchaccount/model_computenodeidentityreference.go @@ -0,0 +1,8 @@ +package batchaccount + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeNodeIdentityReference struct { + ResourceId *string `json:"resourceId,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/batchaccount/model_encryptionproperties.go b/resource-manager/batch/2024-02-01/batchaccount/model_encryptionproperties.go new file mode 100644 index 00000000000..018f83c27e5 --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchaccount/model_encryptionproperties.go @@ -0,0 +1,9 @@ +package batchaccount + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EncryptionProperties struct { + KeySource *KeySource `json:"keySource,omitempty"` + KeyVaultProperties *KeyVaultProperties `json:"keyVaultProperties,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/batchaccount/model_endpointaccessprofile.go b/resource-manager/batch/2024-02-01/batchaccount/model_endpointaccessprofile.go new file mode 100644 index 00000000000..756fe99665b --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchaccount/model_endpointaccessprofile.go @@ -0,0 +1,9 @@ +package batchaccount + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EndpointAccessProfile struct { + DefaultAction EndpointAccessDefaultAction `json:"defaultAction"` + IPRules *[]IPRule `json:"ipRules,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/batchaccount/model_endpointdependency.go b/resource-manager/batch/2024-02-01/batchaccount/model_endpointdependency.go new file mode 100644 index 00000000000..2b0ee92ad27 --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchaccount/model_endpointdependency.go @@ -0,0 +1,10 @@ +package batchaccount + +// 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 { + Description *string `json:"description,omitempty"` + DomainName *string `json:"domainName,omitempty"` + EndpointDetails *[]EndpointDetail `json:"endpointDetails,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/batchaccount/model_endpointdetail.go b/resource-manager/batch/2024-02-01/batchaccount/model_endpointdetail.go new file mode 100644 index 00000000000..521a439d6be --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchaccount/model_endpointdetail.go @@ -0,0 +1,8 @@ +package batchaccount + +// 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 { + Port *int64 `json:"port,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/batchaccount/model_iprule.go b/resource-manager/batch/2024-02-01/batchaccount/model_iprule.go new file mode 100644 index 00000000000..b6c1c8c381f --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchaccount/model_iprule.go @@ -0,0 +1,9 @@ +package batchaccount + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPRule struct { + Action IPRuleAction `json:"action"` + Value string `json:"value"` +} diff --git a/resource-manager/batch/2024-02-01/batchaccount/model_keyvaultproperties.go b/resource-manager/batch/2024-02-01/batchaccount/model_keyvaultproperties.go new file mode 100644 index 00000000000..b11e9e9ec8c --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchaccount/model_keyvaultproperties.go @@ -0,0 +1,8 @@ +package batchaccount + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyVaultProperties struct { + KeyIdentifier *string `json:"keyIdentifier,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/batchaccount/model_keyvaultreference.go b/resource-manager/batch/2024-02-01/batchaccount/model_keyvaultreference.go new file mode 100644 index 00000000000..e3d275bac71 --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchaccount/model_keyvaultreference.go @@ -0,0 +1,9 @@ +package batchaccount + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyVaultReference struct { + Id string `json:"id"` + Url string `json:"url"` +} diff --git a/resource-manager/batch/2024-02-01/batchaccount/model_networkprofile.go b/resource-manager/batch/2024-02-01/batchaccount/model_networkprofile.go new file mode 100644 index 00000000000..7c3c4792e91 --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchaccount/model_networkprofile.go @@ -0,0 +1,9 @@ +package batchaccount + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkProfile struct { + AccountAccess *EndpointAccessProfile `json:"accountAccess,omitempty"` + NodeManagementAccess *EndpointAccessProfile `json:"nodeManagementAccess,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/batchaccount/model_outboundenvironmentendpoint.go b/resource-manager/batch/2024-02-01/batchaccount/model_outboundenvironmentendpoint.go new file mode 100644 index 00000000000..b0d7c922f54 --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchaccount/model_outboundenvironmentendpoint.go @@ -0,0 +1,9 @@ +package batchaccount + +// 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/batch/2024-02-01/batchaccount/model_privateendpoint.go b/resource-manager/batch/2024-02-01/batchaccount/model_privateendpoint.go new file mode 100644 index 00000000000..e60387e8f83 --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchaccount/model_privateendpoint.go @@ -0,0 +1,8 @@ +package batchaccount + +// 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/batch/2024-02-01/batchaccount/model_privateendpointconnection.go b/resource-manager/batch/2024-02-01/batchaccount/model_privateendpointconnection.go new file mode 100644 index 00000000000..282e1765739 --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchaccount/model_privateendpointconnection.go @@ -0,0 +1,12 @@ +package batchaccount + +// 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 { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/batchaccount/model_privateendpointconnectionproperties.go b/resource-manager/batch/2024-02-01/batchaccount/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..dea3e1094fb --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchaccount/model_privateendpointconnectionproperties.go @@ -0,0 +1,11 @@ +package batchaccount + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + GroupIds *[]string `json:"groupIds,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/batchaccount/model_privatelinkserviceconnectionstate.go b/resource-manager/batch/2024-02-01/batchaccount/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..54d4125bcc3 --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchaccount/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package batchaccount + +// 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 PrivateLinkServiceConnectionStatus `json:"status"` +} diff --git a/resource-manager/batch/2024-02-01/batchaccount/model_virtualmachinefamilycorequota.go b/resource-manager/batch/2024-02-01/batchaccount/model_virtualmachinefamilycorequota.go new file mode 100644 index 00000000000..f1812c2636e --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchaccount/model_virtualmachinefamilycorequota.go @@ -0,0 +1,9 @@ +package batchaccount + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineFamilyCoreQuota struct { + CoreQuota *int64 `json:"coreQuota,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/batchaccount/predicates.go b/resource-manager/batch/2024-02-01/batchaccount/predicates.go new file mode 100644 index 00000000000..30739ec3997 --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchaccount/predicates.go @@ -0,0 +1,45 @@ +package batchaccount + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BatchAccountOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p BatchAccountOperationPredicate) Matches(input BatchAccount) 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 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 +} diff --git a/resource-manager/batch/2024-02-01/batchaccount/version.go b/resource-manager/batch/2024-02-01/batchaccount/version.go new file mode 100644 index 00000000000..03dabdbb3ea --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchaccount/version.go @@ -0,0 +1,12 @@ +package batchaccount + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-02-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/batchaccount/%s", defaultApiVersion) +} diff --git a/resource-manager/batch/2024-02-01/batchmanagements/README.md b/resource-manager/batch/2024-02-01/batchmanagements/README.md new file mode 100644 index 00000000000..9ba147da01f --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchmanagements/README.md @@ -0,0 +1,74 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/batch/2024-02-01/batchmanagements` Documentation + +The `batchmanagements` SDK allows for interaction with the Azure Resource Manager Service `batch` (API Version `2024-02-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/batch/2024-02-01/batchmanagements" +``` + + +### Client Initialization + +```go +client := batchmanagements.NewBatchManagementsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `BatchManagementsClient.BatchAccountGetDetector` + +```go +ctx := context.TODO() +id := batchmanagements.NewDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue", "detectorIdValue") + +read, err := client.BatchAccountGetDetector(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `BatchManagementsClient.BatchAccountListDetectors` + +```go +ctx := context.TODO() +id := batchmanagements.NewBatchAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue") + +// alternatively `client.BatchAccountListDetectors(ctx, id)` can be used to do batched pagination +items, err := client.BatchAccountListDetectorsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `BatchManagementsClient.LocationCheckNameAvailability` + +```go +ctx := context.TODO() +id := batchmanagements.NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + +payload := batchmanagements.CheckNameAvailabilityParameters{ + // ... +} + + +read, err := client.LocationCheckNameAvailability(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/batch/2024-02-01/batchmanagements/client.go b/resource-manager/batch/2024-02-01/batchmanagements/client.go new file mode 100644 index 00000000000..e909e6a24f4 --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchmanagements/client.go @@ -0,0 +1,26 @@ +package batchmanagements + +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 BatchManagementsClient struct { + Client *resourcemanager.Client +} + +func NewBatchManagementsClientWithBaseURI(sdkApi sdkEnv.Api) (*BatchManagementsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "batchmanagements", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating BatchManagementsClient: %+v", err) + } + + return &BatchManagementsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/batch/2024-02-01/batchmanagements/constants.go b/resource-manager/batch/2024-02-01/batchmanagements/constants.go new file mode 100644 index 00000000000..67472b3c5ae --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchmanagements/constants.go @@ -0,0 +1,89 @@ +package batchmanagements + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NameAvailabilityReason string + +const ( + NameAvailabilityReasonAlreadyExists NameAvailabilityReason = "AlreadyExists" + NameAvailabilityReasonInvalid NameAvailabilityReason = "Invalid" +) + +func PossibleValuesForNameAvailabilityReason() []string { + return []string{ + string(NameAvailabilityReasonAlreadyExists), + string(NameAvailabilityReasonInvalid), + } +} + +func (s *NameAvailabilityReason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNameAvailabilityReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNameAvailabilityReason(input string) (*NameAvailabilityReason, error) { + vals := map[string]NameAvailabilityReason{ + "alreadyexists": NameAvailabilityReasonAlreadyExists, + "invalid": NameAvailabilityReasonInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NameAvailabilityReason(input) + return &out, nil +} + +type ResourceType string + +const ( + ResourceTypeMicrosoftPointBatchBatchAccounts ResourceType = "Microsoft.Batch/batchAccounts" +) + +func PossibleValuesForResourceType() []string { + return []string{ + string(ResourceTypeMicrosoftPointBatchBatchAccounts), + } +} + +func (s *ResourceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResourceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseResourceType(input string) (*ResourceType, error) { + vals := map[string]ResourceType{ + "microsoft.batch/batchaccounts": ResourceTypeMicrosoftPointBatchBatchAccounts, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResourceType(input) + return &out, nil +} diff --git a/resource-manager/batch/2024-02-01/batchmanagements/id_batchaccount.go b/resource-manager/batch/2024-02-01/batchmanagements/id_batchaccount.go new file mode 100644 index 00000000000..e49d647b807 --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchmanagements/id_batchaccount.go @@ -0,0 +1,125 @@ +package batchmanagements + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &BatchAccountId{} + +// BatchAccountId is a struct representing the Resource ID for a Batch Account +type BatchAccountId struct { + SubscriptionId string + ResourceGroupName string + BatchAccountName string +} + +// NewBatchAccountID returns a new BatchAccountId struct +func NewBatchAccountID(subscriptionId string, resourceGroupName string, batchAccountName string) BatchAccountId { + return BatchAccountId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + BatchAccountName: batchAccountName, + } +} + +// ParseBatchAccountID parses 'input' into a BatchAccountId +func ParseBatchAccountID(input string) (*BatchAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&BatchAccountId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BatchAccountId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBatchAccountIDInsensitively parses 'input' case-insensitively into a BatchAccountId +// note: this method should only be used for API response data and not user input +func ParseBatchAccountIDInsensitively(input string) (*BatchAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&BatchAccountId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BatchAccountId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BatchAccountId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.BatchAccountName, ok = input.Parsed["batchAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "batchAccountName", input) + } + + return nil +} + +// ValidateBatchAccountID checks that 'input' can be parsed as a Batch Account ID +func ValidateBatchAccountID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseBatchAccountID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Batch Account ID +func (id BatchAccountId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Batch/batchAccounts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.BatchAccountName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Batch Account ID +func (id BatchAccountId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftBatch", "Microsoft.Batch", "Microsoft.Batch"), + resourceids.StaticSegment("staticBatchAccounts", "batchAccounts", "batchAccounts"), + resourceids.UserSpecifiedSegment("batchAccountName", "batchAccountValue"), + } +} + +// String returns a human-readable description of this Batch Account ID +func (id BatchAccountId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Batch Account Name: %q", id.BatchAccountName), + } + return fmt.Sprintf("Batch Account (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/batch/2024-02-01/batchmanagements/id_batchaccount_test.go b/resource-manager/batch/2024-02-01/batchmanagements/id_batchaccount_test.go new file mode 100644 index 00000000000..c7f30e83eec --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchmanagements/id_batchaccount_test.go @@ -0,0 +1,282 @@ +package batchmanagements + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &BatchAccountId{} + +func TestNewBatchAccountID(t *testing.T) { + id := NewBatchAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.BatchAccountName != "batchAccountValue" { + t.Fatalf("Expected %q but got %q for Segment 'BatchAccountName'", id.BatchAccountName, "batchAccountValue") + } +} + +func TestFormatBatchAccountID(t *testing.T) { + actual := NewBatchAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBatchAccountID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BatchAccountId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue", + Expected: &BatchAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BatchAccountName: "batchAccountValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBatchAccountID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BatchAccountName != v.Expected.BatchAccountName { + t.Fatalf("Expected %q but got %q for BatchAccountName", v.Expected.BatchAccountName, actual.BatchAccountName) + } + + } +} + +func TestParseBatchAccountIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BatchAccountId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue", + Expected: &BatchAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BatchAccountName: "batchAccountValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs/bAtChAcCoUnTvAlUe", + Expected: &BatchAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + BatchAccountName: "bAtChAcCoUnTvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs/bAtChAcCoUnTvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBatchAccountIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BatchAccountName != v.Expected.BatchAccountName { + t.Fatalf("Expected %q but got %q for BatchAccountName", v.Expected.BatchAccountName, actual.BatchAccountName) + } + + } +} + +func TestSegmentsForBatchAccountId(t *testing.T) { + segments := BatchAccountId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BatchAccountId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/batch/2024-02-01/batchmanagements/id_detector.go b/resource-manager/batch/2024-02-01/batchmanagements/id_detector.go new file mode 100644 index 00000000000..fd106793c7f --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchmanagements/id_detector.go @@ -0,0 +1,134 @@ +package batchmanagements + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &DetectorId{} + +// DetectorId is a struct representing the Resource ID for a Detector +type DetectorId struct { + SubscriptionId string + ResourceGroupName string + BatchAccountName string + DetectorId string +} + +// NewDetectorID returns a new DetectorId struct +func NewDetectorID(subscriptionId string, resourceGroupName string, batchAccountName string, detectorId string) DetectorId { + return DetectorId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + BatchAccountName: batchAccountName, + DetectorId: detectorId, + } +} + +// 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.BatchAccountName, ok = input.Parsed["batchAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "batchAccountName", input) + } + + if id.DetectorId, ok = input.Parsed["detectorId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "detectorId", 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.Batch/batchAccounts/%s/detectors/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.BatchAccountName, id.DetectorId) +} + +// 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("staticMicrosoftBatch", "Microsoft.Batch", "Microsoft.Batch"), + resourceids.StaticSegment("staticBatchAccounts", "batchAccounts", "batchAccounts"), + resourceids.UserSpecifiedSegment("batchAccountName", "batchAccountValue"), + resourceids.StaticSegment("staticDetectors", "detectors", "detectors"), + resourceids.UserSpecifiedSegment("detectorId", "detectorIdValue"), + } +} + +// 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("Batch Account Name: %q", id.BatchAccountName), + fmt.Sprintf("Detector: %q", id.DetectorId), + } + return fmt.Sprintf("Detector (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/batch/2024-02-01/batchmanagements/id_detector_test.go b/resource-manager/batch/2024-02-01/batchmanagements/id_detector_test.go new file mode 100644 index 00000000000..a6e906959e2 --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchmanagements/id_detector_test.go @@ -0,0 +1,327 @@ +package batchmanagements + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (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", "batchAccountValue", "detectorIdValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.BatchAccountName != "batchAccountValue" { + t.Fatalf("Expected %q but got %q for Segment 'BatchAccountName'", id.BatchAccountName, "batchAccountValue") + } + + if id.DetectorId != "detectorIdValue" { + t.Fatalf("Expected %q but got %q for Segment 'DetectorId'", id.DetectorId, "detectorIdValue") + } +} + +func TestFormatDetectorID(t *testing.T) { + actual := NewDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue", "detectorIdValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/detectors/detectorIdValue" + 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.Batch", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/detectors", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/detectors/detectorIdValue", + Expected: &DetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BatchAccountName: "batchAccountValue", + DetectorId: "detectorIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/detectors/detectorIdValue/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.BatchAccountName != v.Expected.BatchAccountName { + t.Fatalf("Expected %q but got %q for BatchAccountName", v.Expected.BatchAccountName, actual.BatchAccountName) + } + + if actual.DetectorId != v.Expected.DetectorId { + t.Fatalf("Expected %q but got %q for DetectorId", v.Expected.DetectorId, actual.DetectorId) + } + + } +} + +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.Batch", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs/bAtChAcCoUnTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/detectors", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs/bAtChAcCoUnTvAlUe/dEtEcToRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/detectors/detectorIdValue", + Expected: &DetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BatchAccountName: "batchAccountValue", + DetectorId: "detectorIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/detectors/detectorIdValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs/bAtChAcCoUnTvAlUe/dEtEcToRs/dEtEcToRiDvAlUe", + Expected: &DetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + BatchAccountName: "bAtChAcCoUnTvAlUe", + DetectorId: "dEtEcToRiDvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs/bAtChAcCoUnTvAlUe/dEtEcToRs/dEtEcToRiDvAlUe/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.BatchAccountName != v.Expected.BatchAccountName { + t.Fatalf("Expected %q but got %q for BatchAccountName", v.Expected.BatchAccountName, actual.BatchAccountName) + } + + if actual.DetectorId != v.Expected.DetectorId { + t.Fatalf("Expected %q but got %q for DetectorId", v.Expected.DetectorId, actual.DetectorId) + } + + } +} + +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/batch/2024-02-01/batchmanagements/id_location.go b/resource-manager/batch/2024-02-01/batchmanagements/id_location.go new file mode 100644 index 00000000000..864db08d02b --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchmanagements/id_location.go @@ -0,0 +1,116 @@ +package batchmanagements + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + SubscriptionId string + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(subscriptionId string, locationName string) LocationId { + return LocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Batch/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("staticMicrosoftBatch", "Microsoft.Batch", "Microsoft.Batch"), + 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/batch/2024-02-01/batchmanagements/id_location_test.go b/resource-manager/batch/2024-02-01/batchmanagements/id_location_test.go new file mode 100644 index 00000000000..bc0c981cae4 --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchmanagements/id_location_test.go @@ -0,0 +1,237 @@ +package batchmanagements + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (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.Batch/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.Batch", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Batch/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Batch/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.Batch/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.Batch", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.bAtCh", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Batch/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.bAtCh/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Batch/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.Batch/locations/locationValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.bAtCh/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.bAtCh/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/batch/2024-02-01/batchmanagements/method_batchaccountgetdetector.go b/resource-manager/batch/2024-02-01/batchmanagements/method_batchaccountgetdetector.go new file mode 100644 index 00000000000..f8cbbd9ff4d --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchmanagements/method_batchaccountgetdetector.go @@ -0,0 +1,54 @@ +package batchmanagements + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BatchAccountGetDetectorOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DetectorResponse +} + +// BatchAccountGetDetector ... +func (c BatchManagementsClient) BatchAccountGetDetector(ctx context.Context, id DetectorId) (result BatchAccountGetDetectorOperationResponse, 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 DetectorResponse + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/batch/2024-02-01/batchmanagements/method_batchaccountlistdetectors.go b/resource-manager/batch/2024-02-01/batchmanagements/method_batchaccountlistdetectors.go new file mode 100644 index 00000000000..70dbb1ef789 --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchmanagements/method_batchaccountlistdetectors.go @@ -0,0 +1,91 @@ +package batchmanagements + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BatchAccountListDetectorsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DetectorResponse +} + +type BatchAccountListDetectorsCompleteResult struct { + LatestHttpResponse *http.Response + Items []DetectorResponse +} + +// BatchAccountListDetectors ... +func (c BatchManagementsClient) BatchAccountListDetectors(ctx context.Context, id BatchAccountId) (result BatchAccountListDetectorsOperationResponse, 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 +} + +// BatchAccountListDetectorsComplete retrieves all the results into a single object +func (c BatchManagementsClient) BatchAccountListDetectorsComplete(ctx context.Context, id BatchAccountId) (BatchAccountListDetectorsCompleteResult, error) { + return c.BatchAccountListDetectorsCompleteMatchingPredicate(ctx, id, DetectorResponseOperationPredicate{}) +} + +// BatchAccountListDetectorsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c BatchManagementsClient) BatchAccountListDetectorsCompleteMatchingPredicate(ctx context.Context, id BatchAccountId, predicate DetectorResponseOperationPredicate) (result BatchAccountListDetectorsCompleteResult, err error) { + items := make([]DetectorResponse, 0) + + resp, err := c.BatchAccountListDetectors(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 = BatchAccountListDetectorsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/batch/2024-02-01/batchmanagements/method_locationchecknameavailability.go b/resource-manager/batch/2024-02-01/batchmanagements/method_locationchecknameavailability.go new file mode 100644 index 00000000000..12ba043133e --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchmanagements/method_locationchecknameavailability.go @@ -0,0 +1,59 @@ +package batchmanagements + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LocationCheckNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CheckNameAvailabilityResult +} + +// LocationCheckNameAvailability ... +func (c BatchManagementsClient) LocationCheckNameAvailability(ctx context.Context, id LocationId, input CheckNameAvailabilityParameters) (result LocationCheckNameAvailabilityOperationResponse, 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/batch/2024-02-01/batchmanagements/model_checknameavailabilityparameters.go b/resource-manager/batch/2024-02-01/batchmanagements/model_checknameavailabilityparameters.go new file mode 100644 index 00000000000..0284319e80b --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchmanagements/model_checknameavailabilityparameters.go @@ -0,0 +1,9 @@ +package batchmanagements + +// 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"` + Type ResourceType `json:"type"` +} diff --git a/resource-manager/batch/2024-02-01/batchmanagements/model_checknameavailabilityresult.go b/resource-manager/batch/2024-02-01/batchmanagements/model_checknameavailabilityresult.go new file mode 100644 index 00000000000..4ce56422e16 --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchmanagements/model_checknameavailabilityresult.go @@ -0,0 +1,10 @@ +package batchmanagements + +// 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 *NameAvailabilityReason `json:"reason,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/batchmanagements/model_detectorresponse.go b/resource-manager/batch/2024-02-01/batchmanagements/model_detectorresponse.go new file mode 100644 index 00000000000..3137c834cab --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchmanagements/model_detectorresponse.go @@ -0,0 +1,12 @@ +package batchmanagements + +// 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 { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DetectorResponseProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/batchmanagements/model_detectorresponseproperties.go b/resource-manager/batch/2024-02-01/batchmanagements/model_detectorresponseproperties.go new file mode 100644 index 00000000000..55bb4c0284f --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchmanagements/model_detectorresponseproperties.go @@ -0,0 +1,8 @@ +package batchmanagements + +// 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 { + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/batchmanagements/predicates.go b/resource-manager/batch/2024-02-01/batchmanagements/predicates.go new file mode 100644 index 00000000000..a38aabd4183 --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchmanagements/predicates.go @@ -0,0 +1,32 @@ +package batchmanagements + +// 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 { + Etag *string + Id *string + Name *string + Type *string +} + +func (p DetectorResponseOperationPredicate) Matches(input DetectorResponse) 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.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/batch/2024-02-01/batchmanagements/version.go b/resource-manager/batch/2024-02-01/batchmanagements/version.go new file mode 100644 index 00000000000..7bcaaf115f1 --- /dev/null +++ b/resource-manager/batch/2024-02-01/batchmanagements/version.go @@ -0,0 +1,12 @@ +package batchmanagements + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-02-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/batchmanagements/%s", defaultApiVersion) +} diff --git a/resource-manager/batch/2024-02-01/certificate/README.md b/resource-manager/batch/2024-02-01/certificate/README.md new file mode 100644 index 00000000000..91763c309ed --- /dev/null +++ b/resource-manager/batch/2024-02-01/certificate/README.md @@ -0,0 +1,123 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/batch/2024-02-01/certificate` Documentation + +The `certificate` SDK allows for interaction with the Azure Resource Manager Service `batch` (API Version `2024-02-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/batch/2024-02-01/certificate" +``` + + +### Client Initialization + +```go +client := certificate.NewCertificateClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `CertificateClient.CancelDeletion` + +```go +ctx := context.TODO() +id := certificate.NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue", "certificateValue") + +read, err := client.CancelDeletion(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CertificateClient.Create` + +```go +ctx := context.TODO() +id := certificate.NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue", "certificateValue") + +payload := certificate.CertificateCreateOrUpdateParameters{ + // ... +} + + +read, err := client.Create(ctx, id, payload, certificate.DefaultCreateOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CertificateClient.Delete` + +```go +ctx := context.TODO() +id := certificate.NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue", "certificateValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CertificateClient.Get` + +```go +ctx := context.TODO() +id := certificate.NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue", "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: `CertificateClient.ListByBatchAccount` + +```go +ctx := context.TODO() +id := certificate.NewBatchAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue") + +// alternatively `client.ListByBatchAccount(ctx, id, certificate.DefaultListByBatchAccountOperationOptions())` can be used to do batched pagination +items, err := client.ListByBatchAccountComplete(ctx, id, certificate.DefaultListByBatchAccountOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `CertificateClient.Update` + +```go +ctx := context.TODO() +id := certificate.NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue", "certificateValue") + +payload := certificate.CertificateCreateOrUpdateParameters{ + // ... +} + + +read, err := client.Update(ctx, id, payload, certificate.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/batch/2024-02-01/certificate/client.go b/resource-manager/batch/2024-02-01/certificate/client.go new file mode 100644 index 00000000000..9c7a6885362 --- /dev/null +++ b/resource-manager/batch/2024-02-01/certificate/client.go @@ -0,0 +1,26 @@ +package certificate + +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 CertificateClient struct { + Client *resourcemanager.Client +} + +func NewCertificateClientWithBaseURI(sdkApi sdkEnv.Api) (*CertificateClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "certificate", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CertificateClient: %+v", err) + } + + return &CertificateClient{ + Client: client, + }, nil +} diff --git a/resource-manager/batch/2024-02-01/certificate/constants.go b/resource-manager/batch/2024-02-01/certificate/constants.go new file mode 100644 index 00000000000..d92e157ed61 --- /dev/null +++ b/resource-manager/batch/2024-02-01/certificate/constants.go @@ -0,0 +1,95 @@ +package certificate + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificateFormat string + +const ( + CertificateFormatCer CertificateFormat = "Cer" + CertificateFormatPfx CertificateFormat = "Pfx" +) + +func PossibleValuesForCertificateFormat() []string { + return []string{ + string(CertificateFormatCer), + string(CertificateFormatPfx), + } +} + +func (s *CertificateFormat) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCertificateFormat(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCertificateFormat(input string) (*CertificateFormat, error) { + vals := map[string]CertificateFormat{ + "cer": CertificateFormatCer, + "pfx": CertificateFormatPfx, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CertificateFormat(input) + return &out, nil +} + +type CertificateProvisioningState string + +const ( + CertificateProvisioningStateDeleting CertificateProvisioningState = "Deleting" + CertificateProvisioningStateFailed CertificateProvisioningState = "Failed" + CertificateProvisioningStateSucceeded CertificateProvisioningState = "Succeeded" +) + +func PossibleValuesForCertificateProvisioningState() []string { + return []string{ + string(CertificateProvisioningStateDeleting), + string(CertificateProvisioningStateFailed), + 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{ + "deleting": CertificateProvisioningStateDeleting, + "failed": CertificateProvisioningStateFailed, + "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/batch/2024-02-01/certificate/id_batchaccount.go b/resource-manager/batch/2024-02-01/certificate/id_batchaccount.go new file mode 100644 index 00000000000..65d827ec28e --- /dev/null +++ b/resource-manager/batch/2024-02-01/certificate/id_batchaccount.go @@ -0,0 +1,125 @@ +package certificate + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &BatchAccountId{} + +// BatchAccountId is a struct representing the Resource ID for a Batch Account +type BatchAccountId struct { + SubscriptionId string + ResourceGroupName string + BatchAccountName string +} + +// NewBatchAccountID returns a new BatchAccountId struct +func NewBatchAccountID(subscriptionId string, resourceGroupName string, batchAccountName string) BatchAccountId { + return BatchAccountId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + BatchAccountName: batchAccountName, + } +} + +// ParseBatchAccountID parses 'input' into a BatchAccountId +func ParseBatchAccountID(input string) (*BatchAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&BatchAccountId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BatchAccountId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBatchAccountIDInsensitively parses 'input' case-insensitively into a BatchAccountId +// note: this method should only be used for API response data and not user input +func ParseBatchAccountIDInsensitively(input string) (*BatchAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&BatchAccountId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BatchAccountId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BatchAccountId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.BatchAccountName, ok = input.Parsed["batchAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "batchAccountName", input) + } + + return nil +} + +// ValidateBatchAccountID checks that 'input' can be parsed as a Batch Account ID +func ValidateBatchAccountID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseBatchAccountID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Batch Account ID +func (id BatchAccountId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Batch/batchAccounts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.BatchAccountName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Batch Account ID +func (id BatchAccountId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftBatch", "Microsoft.Batch", "Microsoft.Batch"), + resourceids.StaticSegment("staticBatchAccounts", "batchAccounts", "batchAccounts"), + resourceids.UserSpecifiedSegment("batchAccountName", "batchAccountValue"), + } +} + +// String returns a human-readable description of this Batch Account ID +func (id BatchAccountId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Batch Account Name: %q", id.BatchAccountName), + } + return fmt.Sprintf("Batch Account (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/batch/2024-02-01/certificate/id_batchaccount_test.go b/resource-manager/batch/2024-02-01/certificate/id_batchaccount_test.go new file mode 100644 index 00000000000..d746fc8ffba --- /dev/null +++ b/resource-manager/batch/2024-02-01/certificate/id_batchaccount_test.go @@ -0,0 +1,282 @@ +package certificate + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &BatchAccountId{} + +func TestNewBatchAccountID(t *testing.T) { + id := NewBatchAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.BatchAccountName != "batchAccountValue" { + t.Fatalf("Expected %q but got %q for Segment 'BatchAccountName'", id.BatchAccountName, "batchAccountValue") + } +} + +func TestFormatBatchAccountID(t *testing.T) { + actual := NewBatchAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBatchAccountID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BatchAccountId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue", + Expected: &BatchAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BatchAccountName: "batchAccountValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBatchAccountID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BatchAccountName != v.Expected.BatchAccountName { + t.Fatalf("Expected %q but got %q for BatchAccountName", v.Expected.BatchAccountName, actual.BatchAccountName) + } + + } +} + +func TestParseBatchAccountIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BatchAccountId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue", + Expected: &BatchAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BatchAccountName: "batchAccountValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs/bAtChAcCoUnTvAlUe", + Expected: &BatchAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + BatchAccountName: "bAtChAcCoUnTvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs/bAtChAcCoUnTvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBatchAccountIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BatchAccountName != v.Expected.BatchAccountName { + t.Fatalf("Expected %q but got %q for BatchAccountName", v.Expected.BatchAccountName, actual.BatchAccountName) + } + + } +} + +func TestSegmentsForBatchAccountId(t *testing.T) { + segments := BatchAccountId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BatchAccountId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/batch/2024-02-01/certificate/id_certificate.go b/resource-manager/batch/2024-02-01/certificate/id_certificate.go new file mode 100644 index 00000000000..31457086a2b --- /dev/null +++ b/resource-manager/batch/2024-02-01/certificate/id_certificate.go @@ -0,0 +1,134 @@ +package certificate + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &CertificateId{} + +// CertificateId is a struct representing the Resource ID for a Certificate +type CertificateId struct { + SubscriptionId string + ResourceGroupName string + BatchAccountName string + CertificateName string +} + +// NewCertificateID returns a new CertificateId struct +func NewCertificateID(subscriptionId string, resourceGroupName string, batchAccountName string, certificateName string) CertificateId { + return CertificateId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + BatchAccountName: batchAccountName, + 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.BatchAccountName, ok = input.Parsed["batchAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "batchAccountName", 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.Batch/batchAccounts/%s/certificates/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.BatchAccountName, 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("staticMicrosoftBatch", "Microsoft.Batch", "Microsoft.Batch"), + resourceids.StaticSegment("staticBatchAccounts", "batchAccounts", "batchAccounts"), + resourceids.UserSpecifiedSegment("batchAccountName", "batchAccountValue"), + 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("Batch Account Name: %q", id.BatchAccountName), + fmt.Sprintf("Certificate Name: %q", id.CertificateName), + } + return fmt.Sprintf("Certificate (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/batch/2024-02-01/certificate/id_certificate_test.go b/resource-manager/batch/2024-02-01/certificate/id_certificate_test.go new file mode 100644 index 00000000000..26b300bb22b --- /dev/null +++ b/resource-manager/batch/2024-02-01/certificate/id_certificate_test.go @@ -0,0 +1,327 @@ +package certificate + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (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", "batchAccountValue", "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.BatchAccountName != "batchAccountValue" { + t.Fatalf("Expected %q but got %q for Segment 'BatchAccountName'", id.BatchAccountName, "batchAccountValue") + } + + 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", "batchAccountValue", "certificateValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/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.Batch", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/certificates", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/certificates/certificateValue", + Expected: &CertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BatchAccountName: "batchAccountValue", + CertificateName: "certificateValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/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.BatchAccountName != v.Expected.BatchAccountName { + t.Fatalf("Expected %q but got %q for BatchAccountName", v.Expected.BatchAccountName, actual.BatchAccountName) + } + + 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.Batch", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs/bAtChAcCoUnTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/certificates", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs/bAtChAcCoUnTvAlUe/cErTiFiCaTeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/certificates/certificateValue", + Expected: &CertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BatchAccountName: "batchAccountValue", + CertificateName: "certificateValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/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.bAtCh/bAtChAcCoUnTs/bAtChAcCoUnTvAlUe/cErTiFiCaTeS/cErTiFiCaTeVaLuE", + Expected: &CertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + BatchAccountName: "bAtChAcCoUnTvAlUe", + 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.bAtCh/bAtChAcCoUnTs/bAtChAcCoUnTvAlUe/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.BatchAccountName != v.Expected.BatchAccountName { + t.Fatalf("Expected %q but got %q for BatchAccountName", v.Expected.BatchAccountName, actual.BatchAccountName) + } + + 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/batch/2024-02-01/certificate/method_canceldeletion.go b/resource-manager/batch/2024-02-01/certificate/method_canceldeletion.go new file mode 100644 index 00000000000..2e4dcf0a15b --- /dev/null +++ b/resource-manager/batch/2024-02-01/certificate/method_canceldeletion.go @@ -0,0 +1,55 @@ +package certificate + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CancelDeletionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Certificate +} + +// CancelDeletion ... +func (c CertificateClient) CancelDeletion(ctx context.Context, id CertificateId) (result CancelDeletionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/cancelDelete", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *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/batch/2024-02-01/certificate/method_create.go b/resource-manager/batch/2024-02-01/certificate/method_create.go new file mode 100644 index 00000000000..47c406ced4e --- /dev/null +++ b/resource-manager/batch/2024-02-01/certificate/method_create.go @@ -0,0 +1,91 @@ +package certificate + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *Certificate +} + +type CreateOperationOptions struct { + IfMatch *string + IfNoneMatch *string +} + +func DefaultCreateOperationOptions() CreateOperationOptions { + return CreateOperationOptions{} +} + +func (o CreateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + if o.IfNoneMatch != nil { + out.Append("If-None-Match", fmt.Sprintf("%v", *o.IfNoneMatch)) + } + return &out +} + +func (o CreateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Create ... +func (c CertificateClient) Create(ctx context.Context, id CertificateId, input CertificateCreateOrUpdateParameters, options CreateOperationOptions) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model Certificate + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/batch/2024-02-01/certificate/method_delete.go b/resource-manager/batch/2024-02-01/certificate/method_delete.go new file mode 100644 index 00000000000..436364e39c6 --- /dev/null +++ b/resource-manager/batch/2024-02-01/certificate/method_delete.go @@ -0,0 +1,71 @@ +package certificate + +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 CertificateClient) Delete(ctx context.Context, id CertificateId) (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 CertificateClient) DeleteThenPoll(ctx context.Context, id CertificateId) 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/batch/2024-02-01/certificate/method_get.go b/resource-manager/batch/2024-02-01/certificate/method_get.go new file mode 100644 index 00000000000..171381cc239 --- /dev/null +++ b/resource-manager/batch/2024-02-01/certificate/method_get.go @@ -0,0 +1,54 @@ +package certificate + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 CertificateClient) 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/batch/2024-02-01/certificate/method_listbybatchaccount.go b/resource-manager/batch/2024-02-01/certificate/method_listbybatchaccount.go new file mode 100644 index 00000000000..7cbf36b334f --- /dev/null +++ b/resource-manager/batch/2024-02-01/certificate/method_listbybatchaccount.go @@ -0,0 +1,127 @@ +package certificate + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByBatchAccountOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Certificate +} + +type ListByBatchAccountCompleteResult struct { + LatestHttpResponse *http.Response + Items []Certificate +} + +type ListByBatchAccountOperationOptions struct { + Filter *string + Maxresults *int64 + Select *string +} + +func DefaultListByBatchAccountOperationOptions() ListByBatchAccountOperationOptions { + return ListByBatchAccountOperationOptions{} +} + +func (o ListByBatchAccountOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByBatchAccountOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByBatchAccountOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Maxresults != nil { + out.Append("maxresults", fmt.Sprintf("%v", *o.Maxresults)) + } + if o.Select != nil { + out.Append("$select", fmt.Sprintf("%v", *o.Select)) + } + return &out +} + +// ListByBatchAccount ... +func (c CertificateClient) ListByBatchAccount(ctx context.Context, id BatchAccountId, options ListByBatchAccountOperationOptions) (result ListByBatchAccountOperationResponse, 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()), + 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 +} + +// ListByBatchAccountComplete retrieves all the results into a single object +func (c CertificateClient) ListByBatchAccountComplete(ctx context.Context, id BatchAccountId, options ListByBatchAccountOperationOptions) (ListByBatchAccountCompleteResult, error) { + return c.ListByBatchAccountCompleteMatchingPredicate(ctx, id, options, CertificateOperationPredicate{}) +} + +// ListByBatchAccountCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CertificateClient) ListByBatchAccountCompleteMatchingPredicate(ctx context.Context, id BatchAccountId, options ListByBatchAccountOperationOptions, predicate CertificateOperationPredicate) (result ListByBatchAccountCompleteResult, err error) { + items := make([]Certificate, 0) + + resp, err := c.ListByBatchAccount(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 = ListByBatchAccountCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/batch/2024-02-01/certificate/method_update.go b/resource-manager/batch/2024-02-01/certificate/method_update.go new file mode 100644 index 00000000000..0532d6c644d --- /dev/null +++ b/resource-manager/batch/2024-02-01/certificate/method_update.go @@ -0,0 +1,87 @@ +package certificate + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + 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 CertificateClient) Update(ctx context.Context, id CertificateId, input CertificateCreateOrUpdateParameters, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model Certificate + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/batch/2024-02-01/certificate/model_certificate.go b/resource-manager/batch/2024-02-01/certificate/model_certificate.go new file mode 100644 index 00000000000..5218b0449e6 --- /dev/null +++ b/resource-manager/batch/2024-02-01/certificate/model_certificate.go @@ -0,0 +1,12 @@ +package certificate + +// 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 { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *CertificateProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/certificate/model_certificatecreateorupdateparameters.go b/resource-manager/batch/2024-02-01/certificate/model_certificatecreateorupdateparameters.go new file mode 100644 index 00000000000..1d50bc058ad --- /dev/null +++ b/resource-manager/batch/2024-02-01/certificate/model_certificatecreateorupdateparameters.go @@ -0,0 +1,12 @@ +package certificate + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificateCreateOrUpdateParameters struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *CertificateCreateOrUpdateProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/certificate/model_certificatecreateorupdateproperties.go b/resource-manager/batch/2024-02-01/certificate/model_certificatecreateorupdateproperties.go new file mode 100644 index 00000000000..5af96095ec4 --- /dev/null +++ b/resource-manager/batch/2024-02-01/certificate/model_certificatecreateorupdateproperties.go @@ -0,0 +1,12 @@ +package certificate + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificateCreateOrUpdateProperties struct { + Data string `json:"data"` + Format *CertificateFormat `json:"format,omitempty"` + Password *string `json:"password,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` + ThumbprintAlgorithm *string `json:"thumbprintAlgorithm,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/certificate/model_certificateproperties.go b/resource-manager/batch/2024-02-01/certificate/model_certificateproperties.go new file mode 100644 index 00000000000..01b0c5dc127 --- /dev/null +++ b/resource-manager/batch/2024-02-01/certificate/model_certificateproperties.go @@ -0,0 +1,46 @@ +package certificate + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/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 { + DeleteCertificateError *DeleteCertificateError `json:"deleteCertificateError,omitempty"` + Format *CertificateFormat `json:"format,omitempty"` + PreviousProvisioningState *CertificateProvisioningState `json:"previousProvisioningState,omitempty"` + PreviousProvisioningStateTransitionTime *string `json:"previousProvisioningStateTransitionTime,omitempty"` + ProvisioningState *CertificateProvisioningState `json:"provisioningState,omitempty"` + ProvisioningStateTransitionTime *string `json:"provisioningStateTransitionTime,omitempty"` + PublicData *string `json:"publicData,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` + ThumbprintAlgorithm *string `json:"thumbprintAlgorithm,omitempty"` +} + +func (o *CertificateProperties) GetPreviousProvisioningStateTransitionTimeAsTime() (*time.Time, error) { + if o.PreviousProvisioningStateTransitionTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.PreviousProvisioningStateTransitionTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *CertificateProperties) SetPreviousProvisioningStateTransitionTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.PreviousProvisioningStateTransitionTime = &formatted +} + +func (o *CertificateProperties) GetProvisioningStateTransitionTimeAsTime() (*time.Time, error) { + if o.ProvisioningStateTransitionTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ProvisioningStateTransitionTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *CertificateProperties) SetProvisioningStateTransitionTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ProvisioningStateTransitionTime = &formatted +} diff --git a/resource-manager/batch/2024-02-01/certificate/model_deletecertificateerror.go b/resource-manager/batch/2024-02-01/certificate/model_deletecertificateerror.go new file mode 100644 index 00000000000..1e12424fff4 --- /dev/null +++ b/resource-manager/batch/2024-02-01/certificate/model_deletecertificateerror.go @@ -0,0 +1,11 @@ +package certificate + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteCertificateError struct { + Code string `json:"code"` + Details *[]DeleteCertificateError `json:"details,omitempty"` + Message string `json:"message"` + Target *string `json:"target,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/certificate/predicates.go b/resource-manager/batch/2024-02-01/certificate/predicates.go new file mode 100644 index 00000000000..e1663bf2b07 --- /dev/null +++ b/resource-manager/batch/2024-02-01/certificate/predicates.go @@ -0,0 +1,32 @@ +package certificate + +// 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 { + Etag *string + Id *string + Name *string + Type *string +} + +func (p CertificateOperationPredicate) Matches(input Certificate) 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.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/batch/2024-02-01/certificate/version.go b/resource-manager/batch/2024-02-01/certificate/version.go new file mode 100644 index 00000000000..897434b4dbd --- /dev/null +++ b/resource-manager/batch/2024-02-01/certificate/version.go @@ -0,0 +1,12 @@ +package certificate + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-02-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/certificate/%s", defaultApiVersion) +} diff --git a/resource-manager/batch/2024-02-01/client.go b/resource-manager/batch/2024-02-01/client.go new file mode 100644 index 00000000000..c9bcaf68807 --- /dev/null +++ b/resource-manager/batch/2024-02-01/client.go @@ -0,0 +1,100 @@ +package v2024_02_01 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/resource-manager/batch/2024-02-01/application" + "github.com/hashicorp/go-azure-sdk/resource-manager/batch/2024-02-01/applicationpackage" + "github.com/hashicorp/go-azure-sdk/resource-manager/batch/2024-02-01/batchaccount" + "github.com/hashicorp/go-azure-sdk/resource-manager/batch/2024-02-01/batchmanagements" + "github.com/hashicorp/go-azure-sdk/resource-manager/batch/2024-02-01/certificate" + "github.com/hashicorp/go-azure-sdk/resource-manager/batch/2024-02-01/location" + "github.com/hashicorp/go-azure-sdk/resource-manager/batch/2024-02-01/pool" + "github.com/hashicorp/go-azure-sdk/resource-manager/batch/2024-02-01/privateendpointconnection" + "github.com/hashicorp/go-azure-sdk/resource-manager/batch/2024-02-01/privatelinkresource" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + Application *application.ApplicationClient + ApplicationPackage *applicationpackage.ApplicationPackageClient + BatchAccount *batchaccount.BatchAccountClient + BatchManagements *batchmanagements.BatchManagementsClient + Certificate *certificate.CertificateClient + Location *location.LocationClient + Pool *pool.PoolClient + PrivateEndpointConnection *privateendpointconnection.PrivateEndpointConnectionClient + PrivateLinkResource *privatelinkresource.PrivateLinkResourceClient +} + +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) + + applicationPackageClient, err := applicationpackage.NewApplicationPackageClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ApplicationPackage client: %+v", err) + } + configureFunc(applicationPackageClient.Client) + + batchAccountClient, err := batchaccount.NewBatchAccountClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building BatchAccount client: %+v", err) + } + configureFunc(batchAccountClient.Client) + + batchManagementsClient, err := batchmanagements.NewBatchManagementsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building BatchManagements client: %+v", err) + } + configureFunc(batchManagementsClient.Client) + + certificateClient, err := certificate.NewCertificateClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Certificate client: %+v", err) + } + configureFunc(certificateClient.Client) + + locationClient, err := location.NewLocationClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Location client: %+v", err) + } + configureFunc(locationClient.Client) + + poolClient, err := pool.NewPoolClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Pool client: %+v", err) + } + configureFunc(poolClient.Client) + + privateEndpointConnectionClient, err := privateendpointconnection.NewPrivateEndpointConnectionClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building PrivateEndpointConnection client: %+v", err) + } + configureFunc(privateEndpointConnectionClient.Client) + + privateLinkResourceClient, err := privatelinkresource.NewPrivateLinkResourceClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building PrivateLinkResource client: %+v", err) + } + configureFunc(privateLinkResourceClient.Client) + + return &Client{ + Application: applicationClient, + ApplicationPackage: applicationPackageClient, + BatchAccount: batchAccountClient, + BatchManagements: batchManagementsClient, + Certificate: certificateClient, + Location: locationClient, + Pool: poolClient, + PrivateEndpointConnection: privateEndpointConnectionClient, + PrivateLinkResource: privateLinkResourceClient, + }, nil +} diff --git a/resource-manager/batch/2024-02-01/location/README.md b/resource-manager/batch/2024-02-01/location/README.md new file mode 100644 index 00000000000..1a550ff9e6c --- /dev/null +++ b/resource-manager/batch/2024-02-01/location/README.md @@ -0,0 +1,70 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/batch/2024-02-01/location` Documentation + +The `location` SDK allows for interaction with the Azure Resource Manager Service `batch` (API Version `2024-02-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/batch/2024-02-01/location" +``` + + +### Client Initialization + +```go +client := location.NewLocationClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `LocationClient.GetQuotas` + +```go +ctx := context.TODO() +id := location.NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + +read, err := client.GetQuotas(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `LocationClient.ListSupportedCloudServiceSkus` + +```go +ctx := context.TODO() +id := location.NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + +// alternatively `client.ListSupportedCloudServiceSkus(ctx, id, location.DefaultListSupportedCloudServiceSkusOperationOptions())` can be used to do batched pagination +items, err := client.ListSupportedCloudServiceSkusComplete(ctx, id, location.DefaultListSupportedCloudServiceSkusOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `LocationClient.ListSupportedVirtualMachineSkus` + +```go +ctx := context.TODO() +id := location.NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + +// alternatively `client.ListSupportedVirtualMachineSkus(ctx, id, location.DefaultListSupportedVirtualMachineSkusOperationOptions())` can be used to do batched pagination +items, err := client.ListSupportedVirtualMachineSkusComplete(ctx, id, location.DefaultListSupportedVirtualMachineSkusOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/batch/2024-02-01/location/client.go b/resource-manager/batch/2024-02-01/location/client.go new file mode 100644 index 00000000000..14480a4f2e8 --- /dev/null +++ b/resource-manager/batch/2024-02-01/location/client.go @@ -0,0 +1,26 @@ +package location + +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 LocationClient struct { + Client *resourcemanager.Client +} + +func NewLocationClientWithBaseURI(sdkApi sdkEnv.Api) (*LocationClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "location", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating LocationClient: %+v", err) + } + + return &LocationClient{ + Client: client, + }, nil +} diff --git a/resource-manager/batch/2024-02-01/location/id_location.go b/resource-manager/batch/2024-02-01/location/id_location.go new file mode 100644 index 00000000000..443f55106f3 --- /dev/null +++ b/resource-manager/batch/2024-02-01/location/id_location.go @@ -0,0 +1,116 @@ +package location + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + SubscriptionId string + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(subscriptionId string, locationName string) LocationId { + return LocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Batch/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("staticMicrosoftBatch", "Microsoft.Batch", "Microsoft.Batch"), + 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/batch/2024-02-01/location/id_location_test.go b/resource-manager/batch/2024-02-01/location/id_location_test.go new file mode 100644 index 00000000000..4b5744e2801 --- /dev/null +++ b/resource-manager/batch/2024-02-01/location/id_location_test.go @@ -0,0 +1,237 @@ +package location + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (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.Batch/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.Batch", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Batch/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Batch/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.Batch/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.Batch", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.bAtCh", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Batch/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.bAtCh/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Batch/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.Batch/locations/locationValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.bAtCh/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.bAtCh/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/batch/2024-02-01/location/method_getquotas.go b/resource-manager/batch/2024-02-01/location/method_getquotas.go new file mode 100644 index 00000000000..5bf4b3b66d4 --- /dev/null +++ b/resource-manager/batch/2024-02-01/location/method_getquotas.go @@ -0,0 +1,55 @@ +package location + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetQuotasOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BatchLocationQuota +} + +// GetQuotas ... +func (c LocationClient) GetQuotas(ctx context.Context, id LocationId) (result GetQuotasOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/quotas", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model BatchLocationQuota + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/batch/2024-02-01/location/method_listsupportedcloudserviceskus.go b/resource-manager/batch/2024-02-01/location/method_listsupportedcloudserviceskus.go new file mode 100644 index 00000000000..ac834f8f08f --- /dev/null +++ b/resource-manager/batch/2024-02-01/location/method_listsupportedcloudserviceskus.go @@ -0,0 +1,123 @@ +package location + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListSupportedCloudServiceSkusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SupportedSku +} + +type ListSupportedCloudServiceSkusCompleteResult struct { + LatestHttpResponse *http.Response + Items []SupportedSku +} + +type ListSupportedCloudServiceSkusOperationOptions struct { + Filter *string + Maxresults *int64 +} + +func DefaultListSupportedCloudServiceSkusOperationOptions() ListSupportedCloudServiceSkusOperationOptions { + return ListSupportedCloudServiceSkusOperationOptions{} +} + +func (o ListSupportedCloudServiceSkusOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListSupportedCloudServiceSkusOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListSupportedCloudServiceSkusOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Maxresults != nil { + out.Append("maxresults", fmt.Sprintf("%v", *o.Maxresults)) + } + return &out +} + +// ListSupportedCloudServiceSkus ... +func (c LocationClient) ListSupportedCloudServiceSkus(ctx context.Context, id LocationId, options ListSupportedCloudServiceSkusOperationOptions) (result ListSupportedCloudServiceSkusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/cloudServiceSkus", 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 *[]SupportedSku `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSupportedCloudServiceSkusComplete retrieves all the results into a single object +func (c LocationClient) ListSupportedCloudServiceSkusComplete(ctx context.Context, id LocationId, options ListSupportedCloudServiceSkusOperationOptions) (ListSupportedCloudServiceSkusCompleteResult, error) { + return c.ListSupportedCloudServiceSkusCompleteMatchingPredicate(ctx, id, options, SupportedSkuOperationPredicate{}) +} + +// ListSupportedCloudServiceSkusCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c LocationClient) ListSupportedCloudServiceSkusCompleteMatchingPredicate(ctx context.Context, id LocationId, options ListSupportedCloudServiceSkusOperationOptions, predicate SupportedSkuOperationPredicate) (result ListSupportedCloudServiceSkusCompleteResult, err error) { + items := make([]SupportedSku, 0) + + resp, err := c.ListSupportedCloudServiceSkus(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 = ListSupportedCloudServiceSkusCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/batch/2024-02-01/location/method_listsupportedvirtualmachineskus.go b/resource-manager/batch/2024-02-01/location/method_listsupportedvirtualmachineskus.go new file mode 100644 index 00000000000..4e12ce271dc --- /dev/null +++ b/resource-manager/batch/2024-02-01/location/method_listsupportedvirtualmachineskus.go @@ -0,0 +1,123 @@ +package location + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListSupportedVirtualMachineSkusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SupportedSku +} + +type ListSupportedVirtualMachineSkusCompleteResult struct { + LatestHttpResponse *http.Response + Items []SupportedSku +} + +type ListSupportedVirtualMachineSkusOperationOptions struct { + Filter *string + Maxresults *int64 +} + +func DefaultListSupportedVirtualMachineSkusOperationOptions() ListSupportedVirtualMachineSkusOperationOptions { + return ListSupportedVirtualMachineSkusOperationOptions{} +} + +func (o ListSupportedVirtualMachineSkusOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListSupportedVirtualMachineSkusOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListSupportedVirtualMachineSkusOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Maxresults != nil { + out.Append("maxresults", fmt.Sprintf("%v", *o.Maxresults)) + } + return &out +} + +// ListSupportedVirtualMachineSkus ... +func (c LocationClient) ListSupportedVirtualMachineSkus(ctx context.Context, id LocationId, options ListSupportedVirtualMachineSkusOperationOptions) (result ListSupportedVirtualMachineSkusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/virtualMachineSkus", 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 *[]SupportedSku `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSupportedVirtualMachineSkusComplete retrieves all the results into a single object +func (c LocationClient) ListSupportedVirtualMachineSkusComplete(ctx context.Context, id LocationId, options ListSupportedVirtualMachineSkusOperationOptions) (ListSupportedVirtualMachineSkusCompleteResult, error) { + return c.ListSupportedVirtualMachineSkusCompleteMatchingPredicate(ctx, id, options, SupportedSkuOperationPredicate{}) +} + +// ListSupportedVirtualMachineSkusCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c LocationClient) ListSupportedVirtualMachineSkusCompleteMatchingPredicate(ctx context.Context, id LocationId, options ListSupportedVirtualMachineSkusOperationOptions, predicate SupportedSkuOperationPredicate) (result ListSupportedVirtualMachineSkusCompleteResult, err error) { + items := make([]SupportedSku, 0) + + resp, err := c.ListSupportedVirtualMachineSkus(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 = ListSupportedVirtualMachineSkusCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/batch/2024-02-01/location/model_batchlocationquota.go b/resource-manager/batch/2024-02-01/location/model_batchlocationquota.go new file mode 100644 index 00000000000..672823b7337 --- /dev/null +++ b/resource-manager/batch/2024-02-01/location/model_batchlocationquota.go @@ -0,0 +1,8 @@ +package location + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BatchLocationQuota struct { + AccountQuota *int64 `json:"accountQuota,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/location/model_skucapability.go b/resource-manager/batch/2024-02-01/location/model_skucapability.go new file mode 100644 index 00000000000..a9fbc21109c --- /dev/null +++ b/resource-manager/batch/2024-02-01/location/model_skucapability.go @@ -0,0 +1,9 @@ +package location + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SkuCapability struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/location/model_supportedsku.go b/resource-manager/batch/2024-02-01/location/model_supportedsku.go new file mode 100644 index 00000000000..3f99eba4a39 --- /dev/null +++ b/resource-manager/batch/2024-02-01/location/model_supportedsku.go @@ -0,0 +1,29 @@ +package location + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SupportedSku struct { + BatchSupportEndOfLife *string `json:"batchSupportEndOfLife,omitempty"` + Capabilities *[]SkuCapability `json:"capabilities,omitempty"` + FamilyName *string `json:"familyName,omitempty"` + Name *string `json:"name,omitempty"` +} + +func (o *SupportedSku) GetBatchSupportEndOfLifeAsTime() (*time.Time, error) { + if o.BatchSupportEndOfLife == nil { + return nil, nil + } + return dates.ParseAsFormat(o.BatchSupportEndOfLife, "2006-01-02T15:04:05Z07:00") +} + +func (o *SupportedSku) SetBatchSupportEndOfLifeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.BatchSupportEndOfLife = &formatted +} diff --git a/resource-manager/batch/2024-02-01/location/predicates.go b/resource-manager/batch/2024-02-01/location/predicates.go new file mode 100644 index 00000000000..ba59d166869 --- /dev/null +++ b/resource-manager/batch/2024-02-01/location/predicates.go @@ -0,0 +1,27 @@ +package location + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SupportedSkuOperationPredicate struct { + BatchSupportEndOfLife *string + FamilyName *string + Name *string +} + +func (p SupportedSkuOperationPredicate) Matches(input SupportedSku) bool { + + if p.BatchSupportEndOfLife != nil && (input.BatchSupportEndOfLife == nil || *p.BatchSupportEndOfLife != *input.BatchSupportEndOfLife) { + return false + } + + if p.FamilyName != nil && (input.FamilyName == nil || *p.FamilyName != *input.FamilyName) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + return true +} diff --git a/resource-manager/batch/2024-02-01/location/version.go b/resource-manager/batch/2024-02-01/location/version.go new file mode 100644 index 00000000000..b9f7aa97bdf --- /dev/null +++ b/resource-manager/batch/2024-02-01/location/version.go @@ -0,0 +1,12 @@ +package location + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-02-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/location/%s", defaultApiVersion) +} diff --git a/resource-manager/batch/2024-02-01/pool/README.md b/resource-manager/batch/2024-02-01/pool/README.md new file mode 100644 index 00000000000..a302fd12f2e --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/README.md @@ -0,0 +1,139 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/batch/2024-02-01/pool` Documentation + +The `pool` SDK allows for interaction with the Azure Resource Manager Service `batch` (API Version `2024-02-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/batch/2024-02-01/pool" +``` + + +### Client Initialization + +```go +client := pool.NewPoolClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PoolClient.Create` + +```go +ctx := context.TODO() +id := pool.NewPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue", "poolValue") + +payload := pool.Pool{ + // ... +} + + +read, err := client.Create(ctx, id, payload, pool.DefaultCreateOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PoolClient.Delete` + +```go +ctx := context.TODO() +id := pool.NewPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue", "poolValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `PoolClient.DisableAutoScale` + +```go +ctx := context.TODO() +id := pool.NewPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue", "poolValue") + +read, err := client.DisableAutoScale(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PoolClient.Get` + +```go +ctx := context.TODO() +id := pool.NewPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue", "poolValue") + +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: `PoolClient.ListByBatchAccount` + +```go +ctx := context.TODO() +id := pool.NewBatchAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue") + +// alternatively `client.ListByBatchAccount(ctx, id, pool.DefaultListByBatchAccountOperationOptions())` can be used to do batched pagination +items, err := client.ListByBatchAccountComplete(ctx, id, pool.DefaultListByBatchAccountOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PoolClient.StopResize` + +```go +ctx := context.TODO() +id := pool.NewPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue", "poolValue") + +read, err := client.StopResize(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PoolClient.Update` + +```go +ctx := context.TODO() +id := pool.NewPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue", "poolValue") + +payload := pool.Pool{ + // ... +} + + +read, err := client.Update(ctx, id, payload, pool.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/batch/2024-02-01/pool/client.go b/resource-manager/batch/2024-02-01/pool/client.go new file mode 100644 index 00000000000..dd32c3c502c --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/client.go @@ -0,0 +1,26 @@ +package pool + +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 PoolClient struct { + Client *resourcemanager.Client +} + +func NewPoolClientWithBaseURI(sdkApi sdkEnv.Api) (*PoolClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "pool", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PoolClient: %+v", err) + } + + return &PoolClient{ + Client: client, + }, nil +} diff --git a/resource-manager/batch/2024-02-01/pool/constants.go b/resource-manager/batch/2024-02-01/pool/constants.go new file mode 100644 index 00000000000..69deb64c2e6 --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/constants.go @@ -0,0 +1,1015 @@ +package pool + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AllocationState string + +const ( + AllocationStateResizing AllocationState = "Resizing" + AllocationStateSteady AllocationState = "Steady" + AllocationStateStopping AllocationState = "Stopping" +) + +func PossibleValuesForAllocationState() []string { + return []string{ + string(AllocationStateResizing), + string(AllocationStateSteady), + string(AllocationStateStopping), + } +} + +func (s *AllocationState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAllocationState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAllocationState(input string) (*AllocationState, error) { + vals := map[string]AllocationState{ + "resizing": AllocationStateResizing, + "steady": AllocationStateSteady, + "stopping": AllocationStateStopping, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AllocationState(input) + return &out, nil +} + +type AutoUserScope string + +const ( + AutoUserScopePool AutoUserScope = "Pool" + AutoUserScopeTask AutoUserScope = "Task" +) + +func PossibleValuesForAutoUserScope() []string { + return []string{ + string(AutoUserScopePool), + string(AutoUserScopeTask), + } +} + +func (s *AutoUserScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutoUserScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutoUserScope(input string) (*AutoUserScope, error) { + vals := map[string]AutoUserScope{ + "pool": AutoUserScopePool, + "task": AutoUserScopeTask, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutoUserScope(input) + return &out, nil +} + +type CachingType string + +const ( + CachingTypeNone CachingType = "None" + CachingTypeReadOnly CachingType = "ReadOnly" + CachingTypeReadWrite CachingType = "ReadWrite" +) + +func PossibleValuesForCachingType() []string { + return []string{ + string(CachingTypeNone), + string(CachingTypeReadOnly), + string(CachingTypeReadWrite), + } +} + +func (s *CachingType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCachingType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCachingType(input string) (*CachingType, error) { + vals := map[string]CachingType{ + "none": CachingTypeNone, + "readonly": CachingTypeReadOnly, + "readwrite": CachingTypeReadWrite, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CachingType(input) + return &out, nil +} + +type CertificateStoreLocation string + +const ( + CertificateStoreLocationCurrentUser CertificateStoreLocation = "CurrentUser" + CertificateStoreLocationLocalMachine CertificateStoreLocation = "LocalMachine" +) + +func PossibleValuesForCertificateStoreLocation() []string { + return []string{ + string(CertificateStoreLocationCurrentUser), + string(CertificateStoreLocationLocalMachine), + } +} + +func (s *CertificateStoreLocation) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCertificateStoreLocation(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCertificateStoreLocation(input string) (*CertificateStoreLocation, error) { + vals := map[string]CertificateStoreLocation{ + "currentuser": CertificateStoreLocationCurrentUser, + "localmachine": CertificateStoreLocationLocalMachine, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CertificateStoreLocation(input) + return &out, nil +} + +type CertificateVisibility string + +const ( + CertificateVisibilityRemoteUser CertificateVisibility = "RemoteUser" + CertificateVisibilityStartTask CertificateVisibility = "StartTask" + CertificateVisibilityTask CertificateVisibility = "Task" +) + +func PossibleValuesForCertificateVisibility() []string { + return []string{ + string(CertificateVisibilityRemoteUser), + string(CertificateVisibilityStartTask), + string(CertificateVisibilityTask), + } +} + +func (s *CertificateVisibility) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCertificateVisibility(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCertificateVisibility(input string) (*CertificateVisibility, error) { + vals := map[string]CertificateVisibility{ + "remoteuser": CertificateVisibilityRemoteUser, + "starttask": CertificateVisibilityStartTask, + "task": CertificateVisibilityTask, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CertificateVisibility(input) + return &out, nil +} + +type ComputeNodeDeallocationOption string + +const ( + ComputeNodeDeallocationOptionRequeue ComputeNodeDeallocationOption = "Requeue" + ComputeNodeDeallocationOptionRetainedData ComputeNodeDeallocationOption = "RetainedData" + ComputeNodeDeallocationOptionTaskCompletion ComputeNodeDeallocationOption = "TaskCompletion" + ComputeNodeDeallocationOptionTerminate ComputeNodeDeallocationOption = "Terminate" +) + +func PossibleValuesForComputeNodeDeallocationOption() []string { + return []string{ + string(ComputeNodeDeallocationOptionRequeue), + string(ComputeNodeDeallocationOptionRetainedData), + string(ComputeNodeDeallocationOptionTaskCompletion), + string(ComputeNodeDeallocationOptionTerminate), + } +} + +func (s *ComputeNodeDeallocationOption) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseComputeNodeDeallocationOption(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseComputeNodeDeallocationOption(input string) (*ComputeNodeDeallocationOption, error) { + vals := map[string]ComputeNodeDeallocationOption{ + "requeue": ComputeNodeDeallocationOptionRequeue, + "retaineddata": ComputeNodeDeallocationOptionRetainedData, + "taskcompletion": ComputeNodeDeallocationOptionTaskCompletion, + "terminate": ComputeNodeDeallocationOptionTerminate, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ComputeNodeDeallocationOption(input) + return &out, nil +} + +type ComputeNodeFillType string + +const ( + ComputeNodeFillTypePack ComputeNodeFillType = "Pack" + ComputeNodeFillTypeSpread ComputeNodeFillType = "Spread" +) + +func PossibleValuesForComputeNodeFillType() []string { + return []string{ + string(ComputeNodeFillTypePack), + string(ComputeNodeFillTypeSpread), + } +} + +func (s *ComputeNodeFillType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseComputeNodeFillType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseComputeNodeFillType(input string) (*ComputeNodeFillType, error) { + vals := map[string]ComputeNodeFillType{ + "pack": ComputeNodeFillTypePack, + "spread": ComputeNodeFillTypeSpread, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ComputeNodeFillType(input) + return &out, nil +} + +type ContainerType string + +const ( + ContainerTypeCriCompatible ContainerType = "CriCompatible" + ContainerTypeDockerCompatible ContainerType = "DockerCompatible" +) + +func PossibleValuesForContainerType() []string { + return []string{ + string(ContainerTypeCriCompatible), + string(ContainerTypeDockerCompatible), + } +} + +func (s *ContainerType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseContainerType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseContainerType(input string) (*ContainerType, error) { + vals := map[string]ContainerType{ + "cricompatible": ContainerTypeCriCompatible, + "dockercompatible": ContainerTypeDockerCompatible, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ContainerType(input) + return &out, nil +} + +type ContainerWorkingDirectory string + +const ( + ContainerWorkingDirectoryContainerImageDefault ContainerWorkingDirectory = "ContainerImageDefault" + ContainerWorkingDirectoryTaskWorkingDirectory ContainerWorkingDirectory = "TaskWorkingDirectory" +) + +func PossibleValuesForContainerWorkingDirectory() []string { + return []string{ + string(ContainerWorkingDirectoryContainerImageDefault), + string(ContainerWorkingDirectoryTaskWorkingDirectory), + } +} + +func (s *ContainerWorkingDirectory) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseContainerWorkingDirectory(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseContainerWorkingDirectory(input string) (*ContainerWorkingDirectory, error) { + vals := map[string]ContainerWorkingDirectory{ + "containerimagedefault": ContainerWorkingDirectoryContainerImageDefault, + "taskworkingdirectory": ContainerWorkingDirectoryTaskWorkingDirectory, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ContainerWorkingDirectory(input) + return &out, nil +} + +type DiffDiskPlacement string + +const ( + DiffDiskPlacementCacheDisk DiffDiskPlacement = "CacheDisk" +) + +func PossibleValuesForDiffDiskPlacement() []string { + return []string{ + string(DiffDiskPlacementCacheDisk), + } +} + +func (s *DiffDiskPlacement) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDiffDiskPlacement(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDiffDiskPlacement(input string) (*DiffDiskPlacement, error) { + vals := map[string]DiffDiskPlacement{ + "cachedisk": DiffDiskPlacementCacheDisk, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DiffDiskPlacement(input) + return &out, nil +} + +type DiskEncryptionTarget string + +const ( + DiskEncryptionTargetOsDisk DiskEncryptionTarget = "OsDisk" + DiskEncryptionTargetTemporaryDisk DiskEncryptionTarget = "TemporaryDisk" +) + +func PossibleValuesForDiskEncryptionTarget() []string { + return []string{ + string(DiskEncryptionTargetOsDisk), + string(DiskEncryptionTargetTemporaryDisk), + } +} + +func (s *DiskEncryptionTarget) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDiskEncryptionTarget(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDiskEncryptionTarget(input string) (*DiskEncryptionTarget, error) { + vals := map[string]DiskEncryptionTarget{ + "osdisk": DiskEncryptionTargetOsDisk, + "temporarydisk": DiskEncryptionTargetTemporaryDisk, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DiskEncryptionTarget(input) + return &out, nil +} + +type DynamicVNetAssignmentScope string + +const ( + DynamicVNetAssignmentScopeJob DynamicVNetAssignmentScope = "job" + DynamicVNetAssignmentScopeNone DynamicVNetAssignmentScope = "none" +) + +func PossibleValuesForDynamicVNetAssignmentScope() []string { + return []string{ + string(DynamicVNetAssignmentScopeJob), + string(DynamicVNetAssignmentScopeNone), + } +} + +func (s *DynamicVNetAssignmentScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDynamicVNetAssignmentScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDynamicVNetAssignmentScope(input string) (*DynamicVNetAssignmentScope, error) { + vals := map[string]DynamicVNetAssignmentScope{ + "job": DynamicVNetAssignmentScopeJob, + "none": DynamicVNetAssignmentScopeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DynamicVNetAssignmentScope(input) + return &out, nil +} + +type ElevationLevel string + +const ( + ElevationLevelAdmin ElevationLevel = "Admin" + ElevationLevelNonAdmin ElevationLevel = "NonAdmin" +) + +func PossibleValuesForElevationLevel() []string { + return []string{ + string(ElevationLevelAdmin), + string(ElevationLevelNonAdmin), + } +} + +func (s *ElevationLevel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseElevationLevel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseElevationLevel(input string) (*ElevationLevel, error) { + vals := map[string]ElevationLevel{ + "admin": ElevationLevelAdmin, + "nonadmin": ElevationLevelNonAdmin, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ElevationLevel(input) + return &out, nil +} + +type IPAddressProvisioningType string + +const ( + IPAddressProvisioningTypeBatchManaged IPAddressProvisioningType = "BatchManaged" + IPAddressProvisioningTypeNoPublicIPAddresses IPAddressProvisioningType = "NoPublicIPAddresses" + IPAddressProvisioningTypeUserManaged IPAddressProvisioningType = "UserManaged" +) + +func PossibleValuesForIPAddressProvisioningType() []string { + return []string{ + string(IPAddressProvisioningTypeBatchManaged), + string(IPAddressProvisioningTypeNoPublicIPAddresses), + string(IPAddressProvisioningTypeUserManaged), + } +} + +func (s *IPAddressProvisioningType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPAddressProvisioningType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPAddressProvisioningType(input string) (*IPAddressProvisioningType, error) { + vals := map[string]IPAddressProvisioningType{ + "batchmanaged": IPAddressProvisioningTypeBatchManaged, + "nopublicipaddresses": IPAddressProvisioningTypeNoPublicIPAddresses, + "usermanaged": IPAddressProvisioningTypeUserManaged, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPAddressProvisioningType(input) + return &out, nil +} + +type InboundEndpointProtocol string + +const ( + InboundEndpointProtocolTCP InboundEndpointProtocol = "TCP" + InboundEndpointProtocolUDP InboundEndpointProtocol = "UDP" +) + +func PossibleValuesForInboundEndpointProtocol() []string { + return []string{ + string(InboundEndpointProtocolTCP), + string(InboundEndpointProtocolUDP), + } +} + +func (s *InboundEndpointProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseInboundEndpointProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseInboundEndpointProtocol(input string) (*InboundEndpointProtocol, error) { + vals := map[string]InboundEndpointProtocol{ + "tcp": InboundEndpointProtocolTCP, + "udp": InboundEndpointProtocolUDP, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := InboundEndpointProtocol(input) + return &out, nil +} + +type InterNodeCommunicationState string + +const ( + InterNodeCommunicationStateDisabled InterNodeCommunicationState = "Disabled" + InterNodeCommunicationStateEnabled InterNodeCommunicationState = "Enabled" +) + +func PossibleValuesForInterNodeCommunicationState() []string { + return []string{ + string(InterNodeCommunicationStateDisabled), + string(InterNodeCommunicationStateEnabled), + } +} + +func (s *InterNodeCommunicationState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseInterNodeCommunicationState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseInterNodeCommunicationState(input string) (*InterNodeCommunicationState, error) { + vals := map[string]InterNodeCommunicationState{ + "disabled": InterNodeCommunicationStateDisabled, + "enabled": InterNodeCommunicationStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := InterNodeCommunicationState(input) + return &out, nil +} + +type LoginMode string + +const ( + LoginModeBatch LoginMode = "Batch" + LoginModeInteractive LoginMode = "Interactive" +) + +func PossibleValuesForLoginMode() []string { + return []string{ + string(LoginModeBatch), + string(LoginModeInteractive), + } +} + +func (s *LoginMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLoginMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLoginMode(input string) (*LoginMode, error) { + vals := map[string]LoginMode{ + "batch": LoginModeBatch, + "interactive": LoginModeInteractive, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LoginMode(input) + return &out, nil +} + +type NetworkSecurityGroupRuleAccess string + +const ( + NetworkSecurityGroupRuleAccessAllow NetworkSecurityGroupRuleAccess = "Allow" + NetworkSecurityGroupRuleAccessDeny NetworkSecurityGroupRuleAccess = "Deny" +) + +func PossibleValuesForNetworkSecurityGroupRuleAccess() []string { + return []string{ + string(NetworkSecurityGroupRuleAccessAllow), + string(NetworkSecurityGroupRuleAccessDeny), + } +} + +func (s *NetworkSecurityGroupRuleAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkSecurityGroupRuleAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkSecurityGroupRuleAccess(input string) (*NetworkSecurityGroupRuleAccess, error) { + vals := map[string]NetworkSecurityGroupRuleAccess{ + "allow": NetworkSecurityGroupRuleAccessAllow, + "deny": NetworkSecurityGroupRuleAccessDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkSecurityGroupRuleAccess(input) + return &out, nil +} + +type NodeCommunicationMode string + +const ( + NodeCommunicationModeClassic NodeCommunicationMode = "Classic" + NodeCommunicationModeDefault NodeCommunicationMode = "Default" + NodeCommunicationModeSimplified NodeCommunicationMode = "Simplified" +) + +func PossibleValuesForNodeCommunicationMode() []string { + return []string{ + string(NodeCommunicationModeClassic), + string(NodeCommunicationModeDefault), + string(NodeCommunicationModeSimplified), + } +} + +func (s *NodeCommunicationMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNodeCommunicationMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNodeCommunicationMode(input string) (*NodeCommunicationMode, error) { + vals := map[string]NodeCommunicationMode{ + "classic": NodeCommunicationModeClassic, + "default": NodeCommunicationModeDefault, + "simplified": NodeCommunicationModeSimplified, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NodeCommunicationMode(input) + return &out, nil +} + +type NodePlacementPolicyType string + +const ( + NodePlacementPolicyTypeRegional NodePlacementPolicyType = "Regional" + NodePlacementPolicyTypeZonal NodePlacementPolicyType = "Zonal" +) + +func PossibleValuesForNodePlacementPolicyType() []string { + return []string{ + string(NodePlacementPolicyTypeRegional), + string(NodePlacementPolicyTypeZonal), + } +} + +func (s *NodePlacementPolicyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNodePlacementPolicyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNodePlacementPolicyType(input string) (*NodePlacementPolicyType, error) { + vals := map[string]NodePlacementPolicyType{ + "regional": NodePlacementPolicyTypeRegional, + "zonal": NodePlacementPolicyTypeZonal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NodePlacementPolicyType(input) + return &out, nil +} + +type PoolProvisioningState string + +const ( + PoolProvisioningStateDeleting PoolProvisioningState = "Deleting" + PoolProvisioningStateSucceeded PoolProvisioningState = "Succeeded" +) + +func PossibleValuesForPoolProvisioningState() []string { + return []string{ + string(PoolProvisioningStateDeleting), + string(PoolProvisioningStateSucceeded), + } +} + +func (s *PoolProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePoolProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePoolProvisioningState(input string) (*PoolProvisioningState, error) { + vals := map[string]PoolProvisioningState{ + "deleting": PoolProvisioningStateDeleting, + "succeeded": PoolProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PoolProvisioningState(input) + return &out, nil +} + +type SecurityTypes string + +const ( + SecurityTypesTrustedLaunch SecurityTypes = "trustedLaunch" +) + +func PossibleValuesForSecurityTypes() []string { + return []string{ + string(SecurityTypesTrustedLaunch), + } +} + +func (s *SecurityTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityTypes(input string) (*SecurityTypes, error) { + vals := map[string]SecurityTypes{ + "trustedlaunch": SecurityTypesTrustedLaunch, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityTypes(input) + return &out, nil +} + +type StorageAccountType string + +const ( + StorageAccountTypePremiumLRS StorageAccountType = "Premium_LRS" + StorageAccountTypeStandardLRS StorageAccountType = "Standard_LRS" + StorageAccountTypeStandardSSDLRS StorageAccountType = "StandardSSD_LRS" +) + +func PossibleValuesForStorageAccountType() []string { + return []string{ + string(StorageAccountTypePremiumLRS), + string(StorageAccountTypeStandardLRS), + string(StorageAccountTypeStandardSSDLRS), + } +} + +func (s *StorageAccountType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStorageAccountType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStorageAccountType(input string) (*StorageAccountType, error) { + vals := map[string]StorageAccountType{ + "premium_lrs": StorageAccountTypePremiumLRS, + "standard_lrs": StorageAccountTypeStandardLRS, + "standardssd_lrs": StorageAccountTypeStandardSSDLRS, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StorageAccountType(input) + return &out, nil +} + +type UpgradeMode string + +const ( + UpgradeModeAutomatic UpgradeMode = "automatic" + UpgradeModeManual UpgradeMode = "manual" + UpgradeModeRolling UpgradeMode = "rolling" +) + +func PossibleValuesForUpgradeMode() []string { + return []string{ + string(UpgradeModeAutomatic), + string(UpgradeModeManual), + string(UpgradeModeRolling), + } +} + +func (s *UpgradeMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUpgradeMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUpgradeMode(input string) (*UpgradeMode, error) { + vals := map[string]UpgradeMode{ + "automatic": UpgradeModeAutomatic, + "manual": UpgradeModeManual, + "rolling": UpgradeModeRolling, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UpgradeMode(input) + return &out, nil +} diff --git a/resource-manager/batch/2024-02-01/pool/id_batchaccount.go b/resource-manager/batch/2024-02-01/pool/id_batchaccount.go new file mode 100644 index 00000000000..1f492ad2751 --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/id_batchaccount.go @@ -0,0 +1,125 @@ +package pool + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &BatchAccountId{} + +// BatchAccountId is a struct representing the Resource ID for a Batch Account +type BatchAccountId struct { + SubscriptionId string + ResourceGroupName string + BatchAccountName string +} + +// NewBatchAccountID returns a new BatchAccountId struct +func NewBatchAccountID(subscriptionId string, resourceGroupName string, batchAccountName string) BatchAccountId { + return BatchAccountId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + BatchAccountName: batchAccountName, + } +} + +// ParseBatchAccountID parses 'input' into a BatchAccountId +func ParseBatchAccountID(input string) (*BatchAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&BatchAccountId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BatchAccountId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBatchAccountIDInsensitively parses 'input' case-insensitively into a BatchAccountId +// note: this method should only be used for API response data and not user input +func ParseBatchAccountIDInsensitively(input string) (*BatchAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&BatchAccountId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BatchAccountId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BatchAccountId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.BatchAccountName, ok = input.Parsed["batchAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "batchAccountName", input) + } + + return nil +} + +// ValidateBatchAccountID checks that 'input' can be parsed as a Batch Account ID +func ValidateBatchAccountID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseBatchAccountID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Batch Account ID +func (id BatchAccountId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Batch/batchAccounts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.BatchAccountName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Batch Account ID +func (id BatchAccountId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftBatch", "Microsoft.Batch", "Microsoft.Batch"), + resourceids.StaticSegment("staticBatchAccounts", "batchAccounts", "batchAccounts"), + resourceids.UserSpecifiedSegment("batchAccountName", "batchAccountValue"), + } +} + +// String returns a human-readable description of this Batch Account ID +func (id BatchAccountId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Batch Account Name: %q", id.BatchAccountName), + } + return fmt.Sprintf("Batch Account (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/batch/2024-02-01/pool/id_batchaccount_test.go b/resource-manager/batch/2024-02-01/pool/id_batchaccount_test.go new file mode 100644 index 00000000000..19b9ad9d5f1 --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/id_batchaccount_test.go @@ -0,0 +1,282 @@ +package pool + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &BatchAccountId{} + +func TestNewBatchAccountID(t *testing.T) { + id := NewBatchAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.BatchAccountName != "batchAccountValue" { + t.Fatalf("Expected %q but got %q for Segment 'BatchAccountName'", id.BatchAccountName, "batchAccountValue") + } +} + +func TestFormatBatchAccountID(t *testing.T) { + actual := NewBatchAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBatchAccountID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BatchAccountId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue", + Expected: &BatchAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BatchAccountName: "batchAccountValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBatchAccountID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BatchAccountName != v.Expected.BatchAccountName { + t.Fatalf("Expected %q but got %q for BatchAccountName", v.Expected.BatchAccountName, actual.BatchAccountName) + } + + } +} + +func TestParseBatchAccountIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BatchAccountId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue", + Expected: &BatchAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BatchAccountName: "batchAccountValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs/bAtChAcCoUnTvAlUe", + Expected: &BatchAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + BatchAccountName: "bAtChAcCoUnTvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs/bAtChAcCoUnTvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBatchAccountIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BatchAccountName != v.Expected.BatchAccountName { + t.Fatalf("Expected %q but got %q for BatchAccountName", v.Expected.BatchAccountName, actual.BatchAccountName) + } + + } +} + +func TestSegmentsForBatchAccountId(t *testing.T) { + segments := BatchAccountId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BatchAccountId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/batch/2024-02-01/pool/id_pool.go b/resource-manager/batch/2024-02-01/pool/id_pool.go new file mode 100644 index 00000000000..2350f4e7811 --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/id_pool.go @@ -0,0 +1,134 @@ +package pool + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PoolId{} + +// PoolId is a struct representing the Resource ID for a Pool +type PoolId struct { + SubscriptionId string + ResourceGroupName string + BatchAccountName string + PoolName string +} + +// NewPoolID returns a new PoolId struct +func NewPoolID(subscriptionId string, resourceGroupName string, batchAccountName string, poolName string) PoolId { + return PoolId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + BatchAccountName: batchAccountName, + PoolName: poolName, + } +} + +// ParsePoolID parses 'input' into a PoolId +func ParsePoolID(input string) (*PoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&PoolId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PoolId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePoolIDInsensitively parses 'input' case-insensitively into a PoolId +// note: this method should only be used for API response data and not user input +func ParsePoolIDInsensitively(input string) (*PoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&PoolId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PoolId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PoolId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.BatchAccountName, ok = input.Parsed["batchAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "batchAccountName", input) + } + + if id.PoolName, ok = input.Parsed["poolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "poolName", input) + } + + return nil +} + +// ValidatePoolID checks that 'input' can be parsed as a Pool ID +func ValidatePoolID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParsePoolID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Pool ID +func (id PoolId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Batch/batchAccounts/%s/pools/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.BatchAccountName, id.PoolName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Pool ID +func (id PoolId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftBatch", "Microsoft.Batch", "Microsoft.Batch"), + resourceids.StaticSegment("staticBatchAccounts", "batchAccounts", "batchAccounts"), + resourceids.UserSpecifiedSegment("batchAccountName", "batchAccountValue"), + resourceids.StaticSegment("staticPools", "pools", "pools"), + resourceids.UserSpecifiedSegment("poolName", "poolValue"), + } +} + +// String returns a human-readable description of this Pool ID +func (id PoolId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Batch Account Name: %q", id.BatchAccountName), + fmt.Sprintf("Pool Name: %q", id.PoolName), + } + return fmt.Sprintf("Pool (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/batch/2024-02-01/pool/id_pool_test.go b/resource-manager/batch/2024-02-01/pool/id_pool_test.go new file mode 100644 index 00000000000..fc8fa4b6f8b --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/id_pool_test.go @@ -0,0 +1,327 @@ +package pool + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PoolId{} + +func TestNewPoolID(t *testing.T) { + id := NewPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue", "poolValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.BatchAccountName != "batchAccountValue" { + t.Fatalf("Expected %q but got %q for Segment 'BatchAccountName'", id.BatchAccountName, "batchAccountValue") + } + + if id.PoolName != "poolValue" { + t.Fatalf("Expected %q but got %q for Segment 'PoolName'", id.PoolName, "poolValue") + } +} + +func TestFormatPoolID(t *testing.T) { + actual := NewPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue", "poolValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/pools/poolValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePoolID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PoolId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/pools", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/pools/poolValue", + Expected: &PoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BatchAccountName: "batchAccountValue", + PoolName: "poolValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/pools/poolValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePoolID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BatchAccountName != v.Expected.BatchAccountName { + t.Fatalf("Expected %q but got %q for BatchAccountName", v.Expected.BatchAccountName, actual.BatchAccountName) + } + + if actual.PoolName != v.Expected.PoolName { + t.Fatalf("Expected %q but got %q for PoolName", v.Expected.PoolName, actual.PoolName) + } + + } +} + +func TestParsePoolIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PoolId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs/bAtChAcCoUnTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/pools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs/bAtChAcCoUnTvAlUe/pOoLs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/pools/poolValue", + Expected: &PoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BatchAccountName: "batchAccountValue", + PoolName: "poolValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/pools/poolValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs/bAtChAcCoUnTvAlUe/pOoLs/pOoLvAlUe", + Expected: &PoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + BatchAccountName: "bAtChAcCoUnTvAlUe", + PoolName: "pOoLvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs/bAtChAcCoUnTvAlUe/pOoLs/pOoLvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePoolIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BatchAccountName != v.Expected.BatchAccountName { + t.Fatalf("Expected %q but got %q for BatchAccountName", v.Expected.BatchAccountName, actual.BatchAccountName) + } + + if actual.PoolName != v.Expected.PoolName { + t.Fatalf("Expected %q but got %q for PoolName", v.Expected.PoolName, actual.PoolName) + } + + } +} + +func TestSegmentsForPoolId(t *testing.T) { + segments := PoolId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PoolId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/batch/2024-02-01/pool/method_create.go b/resource-manager/batch/2024-02-01/pool/method_create.go new file mode 100644 index 00000000000..794bcc131d1 --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/method_create.go @@ -0,0 +1,91 @@ +package pool + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *Pool +} + +type CreateOperationOptions struct { + IfMatch *string + IfNoneMatch *string +} + +func DefaultCreateOperationOptions() CreateOperationOptions { + return CreateOperationOptions{} +} + +func (o CreateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + if o.IfNoneMatch != nil { + out.Append("If-None-Match", fmt.Sprintf("%v", *o.IfNoneMatch)) + } + return &out +} + +func (o CreateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Create ... +func (c PoolClient) Create(ctx context.Context, id PoolId, input Pool, options CreateOperationOptions) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model Pool + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/batch/2024-02-01/pool/method_delete.go b/resource-manager/batch/2024-02-01/pool/method_delete.go new file mode 100644 index 00000000000..3dbc00e7780 --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/method_delete.go @@ -0,0 +1,71 @@ +package pool + +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 PoolClient) Delete(ctx context.Context, id PoolId) (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 PoolClient) DeleteThenPoll(ctx context.Context, id PoolId) 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/batch/2024-02-01/pool/method_disableautoscale.go b/resource-manager/batch/2024-02-01/pool/method_disableautoscale.go new file mode 100644 index 00000000000..25e7ab31914 --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/method_disableautoscale.go @@ -0,0 +1,55 @@ +package pool + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DisableAutoScaleOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Pool +} + +// DisableAutoScale ... +func (c PoolClient) DisableAutoScale(ctx context.Context, id PoolId) (result DisableAutoScaleOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/disableAutoScale", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Pool + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/batch/2024-02-01/pool/method_get.go b/resource-manager/batch/2024-02-01/pool/method_get.go new file mode 100644 index 00000000000..65c9fd44f9e --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/method_get.go @@ -0,0 +1,54 @@ +package pool + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *Pool +} + +// Get ... +func (c PoolClient) Get(ctx context.Context, id PoolId) (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 Pool + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/batch/2024-02-01/pool/method_listbybatchaccount.go b/resource-manager/batch/2024-02-01/pool/method_listbybatchaccount.go new file mode 100644 index 00000000000..537f02f2ba3 --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/method_listbybatchaccount.go @@ -0,0 +1,127 @@ +package pool + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByBatchAccountOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Pool +} + +type ListByBatchAccountCompleteResult struct { + LatestHttpResponse *http.Response + Items []Pool +} + +type ListByBatchAccountOperationOptions struct { + Filter *string + Maxresults *int64 + Select *string +} + +func DefaultListByBatchAccountOperationOptions() ListByBatchAccountOperationOptions { + return ListByBatchAccountOperationOptions{} +} + +func (o ListByBatchAccountOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByBatchAccountOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByBatchAccountOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Maxresults != nil { + out.Append("maxresults", fmt.Sprintf("%v", *o.Maxresults)) + } + if o.Select != nil { + out.Append("$select", fmt.Sprintf("%v", *o.Select)) + } + return &out +} + +// ListByBatchAccount ... +func (c PoolClient) ListByBatchAccount(ctx context.Context, id BatchAccountId, options ListByBatchAccountOperationOptions) (result ListByBatchAccountOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/pools", 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 *[]Pool `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByBatchAccountComplete retrieves all the results into a single object +func (c PoolClient) ListByBatchAccountComplete(ctx context.Context, id BatchAccountId, options ListByBatchAccountOperationOptions) (ListByBatchAccountCompleteResult, error) { + return c.ListByBatchAccountCompleteMatchingPredicate(ctx, id, options, PoolOperationPredicate{}) +} + +// ListByBatchAccountCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PoolClient) ListByBatchAccountCompleteMatchingPredicate(ctx context.Context, id BatchAccountId, options ListByBatchAccountOperationOptions, predicate PoolOperationPredicate) (result ListByBatchAccountCompleteResult, err error) { + items := make([]Pool, 0) + + resp, err := c.ListByBatchAccount(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 = ListByBatchAccountCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/batch/2024-02-01/pool/method_stopresize.go b/resource-manager/batch/2024-02-01/pool/method_stopresize.go new file mode 100644 index 00000000000..766ec843a7f --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/method_stopresize.go @@ -0,0 +1,55 @@ +package pool + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StopResizeOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Pool +} + +// StopResize ... +func (c PoolClient) StopResize(ctx context.Context, id PoolId) (result StopResizeOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/stopResize", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Pool + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/batch/2024-02-01/pool/method_update.go b/resource-manager/batch/2024-02-01/pool/method_update.go new file mode 100644 index 00000000000..275122325d9 --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/method_update.go @@ -0,0 +1,87 @@ +package pool + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *Pool +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + 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 PoolClient) Update(ctx context.Context, id PoolId, input Pool, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model Pool + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/batch/2024-02-01/pool/model_applicationpackagereference.go b/resource-manager/batch/2024-02-01/pool/model_applicationpackagereference.go new file mode 100644 index 00000000000..cee391669f2 --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_applicationpackagereference.go @@ -0,0 +1,9 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationPackageReference struct { + Id string `json:"id"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/pool/model_automaticosupgradepolicy.go b/resource-manager/batch/2024-02-01/pool/model_automaticosupgradepolicy.go new file mode 100644 index 00000000000..87cd1130189 --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_automaticosupgradepolicy.go @@ -0,0 +1,11 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutomaticOSUpgradePolicy struct { + DisableAutomaticRollback *bool `json:"disableAutomaticRollback,omitempty"` + EnableAutomaticOSUpgrade *bool `json:"enableAutomaticOSUpgrade,omitempty"` + OsRollingUpgradeDeferral *bool `json:"osRollingUpgradeDeferral,omitempty"` + UseRollingUpgradePolicy *bool `json:"useRollingUpgradePolicy,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/pool/model_autoscalerun.go b/resource-manager/batch/2024-02-01/pool/model_autoscalerun.go new file mode 100644 index 00000000000..a7fc0434342 --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_autoscalerun.go @@ -0,0 +1,25 @@ +package pool + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoScaleRun struct { + Error *AutoScaleRunError `json:"error,omitempty"` + EvaluationTime string `json:"evaluationTime"` + Results *string `json:"results,omitempty"` +} + +func (o *AutoScaleRun) GetEvaluationTimeAsTime() (*time.Time, error) { + return dates.ParseAsFormat(&o.EvaluationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AutoScaleRun) SetEvaluationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EvaluationTime = formatted +} diff --git a/resource-manager/batch/2024-02-01/pool/model_autoscalerunerror.go b/resource-manager/batch/2024-02-01/pool/model_autoscalerunerror.go new file mode 100644 index 00000000000..48fe86695c2 --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_autoscalerunerror.go @@ -0,0 +1,10 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoScaleRunError struct { + Code string `json:"code"` + Details *[]AutoScaleRunError `json:"details,omitempty"` + Message string `json:"message"` +} diff --git a/resource-manager/batch/2024-02-01/pool/model_autoscalesettings.go b/resource-manager/batch/2024-02-01/pool/model_autoscalesettings.go new file mode 100644 index 00000000000..86d2808d4e4 --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_autoscalesettings.go @@ -0,0 +1,9 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoScaleSettings struct { + EvaluationInterval *string `json:"evaluationInterval,omitempty"` + Formula string `json:"formula"` +} diff --git a/resource-manager/batch/2024-02-01/pool/model_autouserspecification.go b/resource-manager/batch/2024-02-01/pool/model_autouserspecification.go new file mode 100644 index 00000000000..4486ae5c662 --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_autouserspecification.go @@ -0,0 +1,9 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoUserSpecification struct { + ElevationLevel *ElevationLevel `json:"elevationLevel,omitempty"` + Scope *AutoUserScope `json:"scope,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/pool/model_azureblobfilesystemconfiguration.go b/resource-manager/batch/2024-02-01/pool/model_azureblobfilesystemconfiguration.go new file mode 100644 index 00000000000..67efe0937db --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_azureblobfilesystemconfiguration.go @@ -0,0 +1,14 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureBlobFileSystemConfiguration struct { + AccountKey *string `json:"accountKey,omitempty"` + AccountName string `json:"accountName"` + BlobfuseOptions *string `json:"blobfuseOptions,omitempty"` + ContainerName string `json:"containerName"` + IdentityReference *ComputeNodeIdentityReference `json:"identityReference,omitempty"` + RelativeMountPath string `json:"relativeMountPath"` + SasKey *string `json:"sasKey,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/pool/model_azurefileshareconfiguration.go b/resource-manager/batch/2024-02-01/pool/model_azurefileshareconfiguration.go new file mode 100644 index 00000000000..910a385e4b8 --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_azurefileshareconfiguration.go @@ -0,0 +1,12 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureFileShareConfiguration struct { + AccountKey string `json:"accountKey"` + AccountName string `json:"accountName"` + AzureFileUrl string `json:"azureFileUrl"` + MountOptions *string `json:"mountOptions,omitempty"` + RelativeMountPath string `json:"relativeMountPath"` +} diff --git a/resource-manager/batch/2024-02-01/pool/model_certificatereference.go b/resource-manager/batch/2024-02-01/pool/model_certificatereference.go new file mode 100644 index 00000000000..d764ddbb7b9 --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_certificatereference.go @@ -0,0 +1,11 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificateReference struct { + Id string `json:"id"` + StoreLocation *CertificateStoreLocation `json:"storeLocation,omitempty"` + StoreName *string `json:"storeName,omitempty"` + Visibility *[]CertificateVisibility `json:"visibility,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/pool/model_cifsmountconfiguration.go b/resource-manager/batch/2024-02-01/pool/model_cifsmountconfiguration.go new file mode 100644 index 00000000000..12757b6d34a --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_cifsmountconfiguration.go @@ -0,0 +1,12 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CIFSMountConfiguration struct { + MountOptions *string `json:"mountOptions,omitempty"` + Password string `json:"password"` + RelativeMountPath string `json:"relativeMountPath"` + Source string `json:"source"` + UserName string `json:"userName"` +} diff --git a/resource-manager/batch/2024-02-01/pool/model_cloudserviceconfiguration.go b/resource-manager/batch/2024-02-01/pool/model_cloudserviceconfiguration.go new file mode 100644 index 00000000000..79a293aaf9c --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_cloudserviceconfiguration.go @@ -0,0 +1,9 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudServiceConfiguration struct { + OsFamily string `json:"osFamily"` + OsVersion *string `json:"osVersion,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/pool/model_computenodeidentityreference.go b/resource-manager/batch/2024-02-01/pool/model_computenodeidentityreference.go new file mode 100644 index 00000000000..5d061039b76 --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_computenodeidentityreference.go @@ -0,0 +1,8 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeNodeIdentityReference struct { + ResourceId *string `json:"resourceId,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/pool/model_containerconfiguration.go b/resource-manager/batch/2024-02-01/pool/model_containerconfiguration.go new file mode 100644 index 00000000000..976a955be92 --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_containerconfiguration.go @@ -0,0 +1,10 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerConfiguration struct { + ContainerImageNames *[]string `json:"containerImageNames,omitempty"` + ContainerRegistries *[]ContainerRegistry `json:"containerRegistries,omitempty"` + Type ContainerType `json:"type"` +} diff --git a/resource-manager/batch/2024-02-01/pool/model_containerregistry.go b/resource-manager/batch/2024-02-01/pool/model_containerregistry.go new file mode 100644 index 00000000000..cc4b521ecad --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_containerregistry.go @@ -0,0 +1,11 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerRegistry struct { + IdentityReference *ComputeNodeIdentityReference `json:"identityReference,omitempty"` + Password *string `json:"password,omitempty"` + RegistryServer *string `json:"registryServer,omitempty"` + Username *string `json:"username,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/pool/model_datadisk.go b/resource-manager/batch/2024-02-01/pool/model_datadisk.go new file mode 100644 index 00000000000..8daa4484cbe --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_datadisk.go @@ -0,0 +1,11 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataDisk struct { + Caching *CachingType `json:"caching,omitempty"` + DiskSizeGB int64 `json:"diskSizeGB"` + Lun int64 `json:"lun"` + StorageAccountType *StorageAccountType `json:"storageAccountType,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/pool/model_deploymentconfiguration.go b/resource-manager/batch/2024-02-01/pool/model_deploymentconfiguration.go new file mode 100644 index 00000000000..281f83d139e --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_deploymentconfiguration.go @@ -0,0 +1,9 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeploymentConfiguration struct { + CloudServiceConfiguration *CloudServiceConfiguration `json:"cloudServiceConfiguration,omitempty"` + VirtualMachineConfiguration *VirtualMachineConfiguration `json:"virtualMachineConfiguration,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/pool/model_diffdisksettings.go b/resource-manager/batch/2024-02-01/pool/model_diffdisksettings.go new file mode 100644 index 00000000000..4a6b0aabfb2 --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_diffdisksettings.go @@ -0,0 +1,8 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiffDiskSettings struct { + Placement *DiffDiskPlacement `json:"placement,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/pool/model_diskencryptionconfiguration.go b/resource-manager/batch/2024-02-01/pool/model_diskencryptionconfiguration.go new file mode 100644 index 00000000000..b25a376a8cd --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_diskencryptionconfiguration.go @@ -0,0 +1,8 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiskEncryptionConfiguration struct { + Targets *[]DiskEncryptionTarget `json:"targets,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/pool/model_environmentsetting.go b/resource-manager/batch/2024-02-01/pool/model_environmentsetting.go new file mode 100644 index 00000000000..6248e4aee95 --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_environmentsetting.go @@ -0,0 +1,9 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EnvironmentSetting struct { + Name string `json:"name"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/pool/model_fixedscalesettings.go b/resource-manager/batch/2024-02-01/pool/model_fixedscalesettings.go new file mode 100644 index 00000000000..291d31fac89 --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_fixedscalesettings.go @@ -0,0 +1,11 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FixedScaleSettings struct { + NodeDeallocationOption *ComputeNodeDeallocationOption `json:"nodeDeallocationOption,omitempty"` + ResizeTimeout *string `json:"resizeTimeout,omitempty"` + TargetDedicatedNodes *int64 `json:"targetDedicatedNodes,omitempty"` + TargetLowPriorityNodes *int64 `json:"targetLowPriorityNodes,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/pool/model_imagereference.go b/resource-manager/batch/2024-02-01/pool/model_imagereference.go new file mode 100644 index 00000000000..a0f7751f75f --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_imagereference.go @@ -0,0 +1,12 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ImageReference struct { + Id *string `json:"id,omitempty"` + Offer *string `json:"offer,omitempty"` + Publisher *string `json:"publisher,omitempty"` + Sku *string `json:"sku,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/pool/model_inboundnatpool.go b/resource-manager/batch/2024-02-01/pool/model_inboundnatpool.go new file mode 100644 index 00000000000..317ae85fa22 --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_inboundnatpool.go @@ -0,0 +1,13 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatPool struct { + BackendPort int64 `json:"backendPort"` + FrontendPortRangeEnd int64 `json:"frontendPortRangeEnd"` + FrontendPortRangeStart int64 `json:"frontendPortRangeStart"` + Name string `json:"name"` + NetworkSecurityGroupRules *[]NetworkSecurityGroupRule `json:"networkSecurityGroupRules,omitempty"` + Protocol InboundEndpointProtocol `json:"protocol"` +} diff --git a/resource-manager/batch/2024-02-01/pool/model_linuxuserconfiguration.go b/resource-manager/batch/2024-02-01/pool/model_linuxuserconfiguration.go new file mode 100644 index 00000000000..60148fc3cf4 --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_linuxuserconfiguration.go @@ -0,0 +1,10 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LinuxUserConfiguration struct { + Gid *int64 `json:"gid,omitempty"` + SshPrivateKey *string `json:"sshPrivateKey,omitempty"` + Uid *int64 `json:"uid,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/pool/model_manageddisk.go b/resource-manager/batch/2024-02-01/pool/model_manageddisk.go new file mode 100644 index 00000000000..7d7378bab50 --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_manageddisk.go @@ -0,0 +1,8 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedDisk struct { + StorageAccountType *StorageAccountType `json:"storageAccountType,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/pool/model_metadataitem.go b/resource-manager/batch/2024-02-01/pool/model_metadataitem.go new file mode 100644 index 00000000000..88e584f8828 --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_metadataitem.go @@ -0,0 +1,9 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MetadataItem struct { + Name string `json:"name"` + Value string `json:"value"` +} diff --git a/resource-manager/batch/2024-02-01/pool/model_mountconfiguration.go b/resource-manager/batch/2024-02-01/pool/model_mountconfiguration.go new file mode 100644 index 00000000000..699e78d963f --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_mountconfiguration.go @@ -0,0 +1,11 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MountConfiguration struct { + AzureBlobFileSystemConfiguration *AzureBlobFileSystemConfiguration `json:"azureBlobFileSystemConfiguration,omitempty"` + AzureFileShareConfiguration *AzureFileShareConfiguration `json:"azureFileShareConfiguration,omitempty"` + CifsMountConfiguration *CIFSMountConfiguration `json:"cifsMountConfiguration,omitempty"` + NfsMountConfiguration *NFSMountConfiguration `json:"nfsMountConfiguration,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/pool/model_networkconfiguration.go b/resource-manager/batch/2024-02-01/pool/model_networkconfiguration.go new file mode 100644 index 00000000000..a4e7d5ab173 --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_networkconfiguration.go @@ -0,0 +1,12 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkConfiguration struct { + DynamicVnetAssignmentScope *DynamicVNetAssignmentScope `json:"dynamicVnetAssignmentScope,omitempty"` + EnableAcceleratedNetworking *bool `json:"enableAcceleratedNetworking,omitempty"` + EndpointConfiguration *PoolEndpointConfiguration `json:"endpointConfiguration,omitempty"` + PublicIPAddressConfiguration *PublicIPAddressConfiguration `json:"publicIPAddressConfiguration,omitempty"` + SubnetId *string `json:"subnetId,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/pool/model_networksecuritygrouprule.go b/resource-manager/batch/2024-02-01/pool/model_networksecuritygrouprule.go new file mode 100644 index 00000000000..5b341632086 --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_networksecuritygrouprule.go @@ -0,0 +1,11 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityGroupRule struct { + Access NetworkSecurityGroupRuleAccess `json:"access"` + Priority int64 `json:"priority"` + SourceAddressPrefix string `json:"sourceAddressPrefix"` + SourcePortRanges *[]string `json:"sourcePortRanges,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/pool/model_nfsmountconfiguration.go b/resource-manager/batch/2024-02-01/pool/model_nfsmountconfiguration.go new file mode 100644 index 00000000000..7b4bac563c5 --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_nfsmountconfiguration.go @@ -0,0 +1,10 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NFSMountConfiguration struct { + MountOptions *string `json:"mountOptions,omitempty"` + RelativeMountPath string `json:"relativeMountPath"` + Source string `json:"source"` +} diff --git a/resource-manager/batch/2024-02-01/pool/model_nodeplacementconfiguration.go b/resource-manager/batch/2024-02-01/pool/model_nodeplacementconfiguration.go new file mode 100644 index 00000000000..5b3284e1b91 --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_nodeplacementconfiguration.go @@ -0,0 +1,8 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NodePlacementConfiguration struct { + Policy *NodePlacementPolicyType `json:"policy,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/pool/model_osdisk.go b/resource-manager/batch/2024-02-01/pool/model_osdisk.go new file mode 100644 index 00000000000..a51976a2015 --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_osdisk.go @@ -0,0 +1,12 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OSDisk struct { + Caching *CachingType `json:"caching,omitempty"` + DiskSizeGB *int64 `json:"diskSizeGB,omitempty"` + EphemeralOSDiskSettings *DiffDiskSettings `json:"ephemeralOSDiskSettings,omitempty"` + ManagedDisk *ManagedDisk `json:"managedDisk,omitempty"` + WriteAcceleratorEnabled *bool `json:"writeAcceleratorEnabled,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/pool/model_pool.go b/resource-manager/batch/2024-02-01/pool/model_pool.go new file mode 100644 index 00000000000..99a23f134df --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_pool.go @@ -0,0 +1,17 @@ +package pool + +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 Pool struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.UserAssignedMap `json:"identity,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PoolProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/pool/model_poolendpointconfiguration.go b/resource-manager/batch/2024-02-01/pool/model_poolendpointconfiguration.go new file mode 100644 index 00000000000..bb6db6ef74c --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_poolendpointconfiguration.go @@ -0,0 +1,8 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PoolEndpointConfiguration struct { + InboundNatPools []InboundNatPool `json:"inboundNatPools"` +} diff --git a/resource-manager/batch/2024-02-01/pool/model_poolproperties.go b/resource-manager/batch/2024-02-01/pool/model_poolproperties.go new file mode 100644 index 00000000000..31bed5fb1c9 --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_poolproperties.go @@ -0,0 +1,90 @@ +package pool + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PoolProperties struct { + AllocationState *AllocationState `json:"allocationState,omitempty"` + AllocationStateTransitionTime *string `json:"allocationStateTransitionTime,omitempty"` + ApplicationLicenses *[]string `json:"applicationLicenses,omitempty"` + ApplicationPackages *[]ApplicationPackageReference `json:"applicationPackages,omitempty"` + AutoScaleRun *AutoScaleRun `json:"autoScaleRun,omitempty"` + Certificates *[]CertificateReference `json:"certificates,omitempty"` + CreationTime *string `json:"creationTime,omitempty"` + CurrentDedicatedNodes *int64 `json:"currentDedicatedNodes,omitempty"` + CurrentLowPriorityNodes *int64 `json:"currentLowPriorityNodes,omitempty"` + CurrentNodeCommunicationMode *NodeCommunicationMode `json:"currentNodeCommunicationMode,omitempty"` + DeploymentConfiguration *DeploymentConfiguration `json:"deploymentConfiguration,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + InterNodeCommunication *InterNodeCommunicationState `json:"interNodeCommunication,omitempty"` + LastModified *string `json:"lastModified,omitempty"` + Metadata *[]MetadataItem `json:"metadata,omitempty"` + MountConfiguration *[]MountConfiguration `json:"mountConfiguration,omitempty"` + NetworkConfiguration *NetworkConfiguration `json:"networkConfiguration,omitempty"` + ProvisioningState *PoolProvisioningState `json:"provisioningState,omitempty"` + ProvisioningStateTransitionTime *string `json:"provisioningStateTransitionTime,omitempty"` + ResizeOperationStatus *ResizeOperationStatus `json:"resizeOperationStatus,omitempty"` + ResourceTags *map[string]string `json:"resourceTags,omitempty"` + ScaleSettings *ScaleSettings `json:"scaleSettings,omitempty"` + StartTask *StartTask `json:"startTask,omitempty"` + TargetNodeCommunicationMode *NodeCommunicationMode `json:"targetNodeCommunicationMode,omitempty"` + TaskSchedulingPolicy *TaskSchedulingPolicy `json:"taskSchedulingPolicy,omitempty"` + TaskSlotsPerNode *int64 `json:"taskSlotsPerNode,omitempty"` + UpgradePolicy *UpgradePolicy `json:"upgradePolicy,omitempty"` + UserAccounts *[]UserAccount `json:"userAccounts,omitempty"` + VMSize *string `json:"vmSize,omitempty"` +} + +func (o *PoolProperties) GetAllocationStateTransitionTimeAsTime() (*time.Time, error) { + if o.AllocationStateTransitionTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.AllocationStateTransitionTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *PoolProperties) SetAllocationStateTransitionTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.AllocationStateTransitionTime = &formatted +} + +func (o *PoolProperties) GetCreationTimeAsTime() (*time.Time, error) { + if o.CreationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *PoolProperties) SetCreationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTime = &formatted +} + +func (o *PoolProperties) GetLastModifiedAsTime() (*time.Time, error) { + if o.LastModified == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastModified, "2006-01-02T15:04:05Z07:00") +} + +func (o *PoolProperties) SetLastModifiedAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastModified = &formatted +} + +func (o *PoolProperties) GetProvisioningStateTransitionTimeAsTime() (*time.Time, error) { + if o.ProvisioningStateTransitionTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ProvisioningStateTransitionTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *PoolProperties) SetProvisioningStateTransitionTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ProvisioningStateTransitionTime = &formatted +} diff --git a/resource-manager/batch/2024-02-01/pool/model_publicipaddressconfiguration.go b/resource-manager/batch/2024-02-01/pool/model_publicipaddressconfiguration.go new file mode 100644 index 00000000000..99001d0826f --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_publicipaddressconfiguration.go @@ -0,0 +1,9 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressConfiguration struct { + IPAddressIds *[]string `json:"ipAddressIds,omitempty"` + Provision *IPAddressProvisioningType `json:"provision,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/pool/model_resizeerror.go b/resource-manager/batch/2024-02-01/pool/model_resizeerror.go new file mode 100644 index 00000000000..9b6eee87fdc --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_resizeerror.go @@ -0,0 +1,10 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResizeError struct { + Code string `json:"code"` + Details *[]ResizeError `json:"details,omitempty"` + Message string `json:"message"` +} diff --git a/resource-manager/batch/2024-02-01/pool/model_resizeoperationstatus.go b/resource-manager/batch/2024-02-01/pool/model_resizeoperationstatus.go new file mode 100644 index 00000000000..b4ac9148d0c --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_resizeoperationstatus.go @@ -0,0 +1,31 @@ +package pool + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResizeOperationStatus struct { + Errors *[]ResizeError `json:"errors,omitempty"` + NodeDeallocationOption *ComputeNodeDeallocationOption `json:"nodeDeallocationOption,omitempty"` + ResizeTimeout *string `json:"resizeTimeout,omitempty"` + StartTime *string `json:"startTime,omitempty"` + TargetDedicatedNodes *int64 `json:"targetDedicatedNodes,omitempty"` + TargetLowPriorityNodes *int64 `json:"targetLowPriorityNodes,omitempty"` +} + +func (o *ResizeOperationStatus) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ResizeOperationStatus) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/batch/2024-02-01/pool/model_resourcefile.go b/resource-manager/batch/2024-02-01/pool/model_resourcefile.go new file mode 100644 index 00000000000..9eddccfb1ed --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_resourcefile.go @@ -0,0 +1,14 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceFile struct { + AutoStorageContainerName *string `json:"autoStorageContainerName,omitempty"` + BlobPrefix *string `json:"blobPrefix,omitempty"` + FileMode *string `json:"fileMode,omitempty"` + FilePath *string `json:"filePath,omitempty"` + HTTPUrl *string `json:"httpUrl,omitempty"` + IdentityReference *ComputeNodeIdentityReference `json:"identityReference,omitempty"` + StorageContainerUrl *string `json:"storageContainerUrl,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/pool/model_rollingupgradepolicy.go b/resource-manager/batch/2024-02-01/pool/model_rollingupgradepolicy.go new file mode 100644 index 00000000000..e8e4ad8d4fa --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_rollingupgradepolicy.go @@ -0,0 +1,14 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RollingUpgradePolicy struct { + EnableCrossZoneUpgrade *bool `json:"enableCrossZoneUpgrade,omitempty"` + MaxBatchInstancePercent *int64 `json:"maxBatchInstancePercent,omitempty"` + MaxUnhealthyInstancePercent *int64 `json:"maxUnhealthyInstancePercent,omitempty"` + MaxUnhealthyUpgradedInstancePercent *int64 `json:"maxUnhealthyUpgradedInstancePercent,omitempty"` + PauseTimeBetweenBatches *string `json:"pauseTimeBetweenBatches,omitempty"` + PrioritizeUnhealthyInstances *bool `json:"prioritizeUnhealthyInstances,omitempty"` + RollbackFailedInstancesOnPolicyBreach *bool `json:"rollbackFailedInstancesOnPolicyBreach,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/pool/model_scalesettings.go b/resource-manager/batch/2024-02-01/pool/model_scalesettings.go new file mode 100644 index 00000000000..afed1acf196 --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_scalesettings.go @@ -0,0 +1,9 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScaleSettings struct { + AutoScale *AutoScaleSettings `json:"autoScale,omitempty"` + FixedScale *FixedScaleSettings `json:"fixedScale,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/pool/model_securityprofile.go b/resource-manager/batch/2024-02-01/pool/model_securityprofile.go new file mode 100644 index 00000000000..c3f6631223f --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_securityprofile.go @@ -0,0 +1,10 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityProfile struct { + EncryptionAtHost *bool `json:"encryptionAtHost,omitempty"` + SecurityType *SecurityTypes `json:"securityType,omitempty"` + UefiSettings *UefiSettings `json:"uefiSettings,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/pool/model_serviceartifactreference.go b/resource-manager/batch/2024-02-01/pool/model_serviceartifactreference.go new file mode 100644 index 00000000000..ce21152df9d --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_serviceartifactreference.go @@ -0,0 +1,8 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceArtifactReference struct { + Id string `json:"id"` +} diff --git a/resource-manager/batch/2024-02-01/pool/model_starttask.go b/resource-manager/batch/2024-02-01/pool/model_starttask.go new file mode 100644 index 00000000000..6846c81fcb7 --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_starttask.go @@ -0,0 +1,14 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StartTask struct { + CommandLine *string `json:"commandLine,omitempty"` + ContainerSettings *TaskContainerSettings `json:"containerSettings,omitempty"` + EnvironmentSettings *[]EnvironmentSetting `json:"environmentSettings,omitempty"` + MaxTaskRetryCount *int64 `json:"maxTaskRetryCount,omitempty"` + ResourceFiles *[]ResourceFile `json:"resourceFiles,omitempty"` + UserIdentity *UserIdentity `json:"userIdentity,omitempty"` + WaitForSuccess *bool `json:"waitForSuccess,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/pool/model_taskcontainersettings.go b/resource-manager/batch/2024-02-01/pool/model_taskcontainersettings.go new file mode 100644 index 00000000000..36ba77fadae --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_taskcontainersettings.go @@ -0,0 +1,11 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TaskContainerSettings struct { + ContainerRunOptions *string `json:"containerRunOptions,omitempty"` + ImageName string `json:"imageName"` + Registry *ContainerRegistry `json:"registry,omitempty"` + WorkingDirectory *ContainerWorkingDirectory `json:"workingDirectory,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/pool/model_taskschedulingpolicy.go b/resource-manager/batch/2024-02-01/pool/model_taskschedulingpolicy.go new file mode 100644 index 00000000000..ad42b99fa04 --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_taskschedulingpolicy.go @@ -0,0 +1,8 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TaskSchedulingPolicy struct { + NodeFillType ComputeNodeFillType `json:"nodeFillType"` +} diff --git a/resource-manager/batch/2024-02-01/pool/model_uefisettings.go b/resource-manager/batch/2024-02-01/pool/model_uefisettings.go new file mode 100644 index 00000000000..fd6d6836bac --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_uefisettings.go @@ -0,0 +1,9 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UefiSettings struct { + SecureBootEnabled *bool `json:"secureBootEnabled,omitempty"` + VTpmEnabled *bool `json:"vTpmEnabled,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/pool/model_upgradepolicy.go b/resource-manager/batch/2024-02-01/pool/model_upgradepolicy.go new file mode 100644 index 00000000000..67e90bfc5d5 --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_upgradepolicy.go @@ -0,0 +1,10 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpgradePolicy struct { + AutomaticOSUpgradePolicy *AutomaticOSUpgradePolicy `json:"automaticOSUpgradePolicy,omitempty"` + Mode UpgradeMode `json:"mode"` + RollingUpgradePolicy *RollingUpgradePolicy `json:"rollingUpgradePolicy,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/pool/model_useraccount.go b/resource-manager/batch/2024-02-01/pool/model_useraccount.go new file mode 100644 index 00000000000..e22af08ada5 --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_useraccount.go @@ -0,0 +1,12 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserAccount struct { + ElevationLevel *ElevationLevel `json:"elevationLevel,omitempty"` + LinuxUserConfiguration *LinuxUserConfiguration `json:"linuxUserConfiguration,omitempty"` + Name string `json:"name"` + Password string `json:"password"` + WindowsUserConfiguration *WindowsUserConfiguration `json:"windowsUserConfiguration,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/pool/model_useridentity.go b/resource-manager/batch/2024-02-01/pool/model_useridentity.go new file mode 100644 index 00000000000..89ef2a53df9 --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_useridentity.go @@ -0,0 +1,9 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserIdentity struct { + AutoUser *AutoUserSpecification `json:"autoUser,omitempty"` + UserName *string `json:"userName,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/pool/model_virtualmachineconfiguration.go b/resource-manager/batch/2024-02-01/pool/model_virtualmachineconfiguration.go new file mode 100644 index 00000000000..eb6ddfadac1 --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_virtualmachineconfiguration.go @@ -0,0 +1,19 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineConfiguration struct { + ContainerConfiguration *ContainerConfiguration `json:"containerConfiguration,omitempty"` + DataDisks *[]DataDisk `json:"dataDisks,omitempty"` + DiskEncryptionConfiguration *DiskEncryptionConfiguration `json:"diskEncryptionConfiguration,omitempty"` + Extensions *[]VmExtension `json:"extensions,omitempty"` + ImageReference ImageReference `json:"imageReference"` + LicenseType *string `json:"licenseType,omitempty"` + NodeAgentSkuId string `json:"nodeAgentSkuId"` + NodePlacementConfiguration *NodePlacementConfiguration `json:"nodePlacementConfiguration,omitempty"` + OsDisk *OSDisk `json:"osDisk,omitempty"` + SecurityProfile *SecurityProfile `json:"securityProfile,omitempty"` + ServiceArtifactReference *ServiceArtifactReference `json:"serviceArtifactReference,omitempty"` + WindowsConfiguration *WindowsConfiguration `json:"windowsConfiguration,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/pool/model_vmextension.go b/resource-manager/batch/2024-02-01/pool/model_vmextension.go new file mode 100644 index 00000000000..9c6f4b36afd --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_vmextension.go @@ -0,0 +1,16 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VmExtension struct { + AutoUpgradeMinorVersion *bool `json:"autoUpgradeMinorVersion,omitempty"` + EnableAutomaticUpgrade *bool `json:"enableAutomaticUpgrade,omitempty"` + Name string `json:"name"` + ProtectedSettings *interface{} `json:"protectedSettings,omitempty"` + ProvisionAfterExtensions *[]string `json:"provisionAfterExtensions,omitempty"` + Publisher string `json:"publisher"` + Settings *interface{} `json:"settings,omitempty"` + Type string `json:"type"` + TypeHandlerVersion *string `json:"typeHandlerVersion,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/pool/model_windowsconfiguration.go b/resource-manager/batch/2024-02-01/pool/model_windowsconfiguration.go new file mode 100644 index 00000000000..f3f44236405 --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_windowsconfiguration.go @@ -0,0 +1,8 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WindowsConfiguration struct { + EnableAutomaticUpdates *bool `json:"enableAutomaticUpdates,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/pool/model_windowsuserconfiguration.go b/resource-manager/batch/2024-02-01/pool/model_windowsuserconfiguration.go new file mode 100644 index 00000000000..f977e22b75a --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/model_windowsuserconfiguration.go @@ -0,0 +1,8 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WindowsUserConfiguration struct { + LoginMode *LoginMode `json:"loginMode,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/pool/predicates.go b/resource-manager/batch/2024-02-01/pool/predicates.go new file mode 100644 index 00000000000..49ae3e2310d --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/predicates.go @@ -0,0 +1,32 @@ +package pool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PoolOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p PoolOperationPredicate) Matches(input Pool) 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.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/batch/2024-02-01/pool/version.go b/resource-manager/batch/2024-02-01/pool/version.go new file mode 100644 index 00000000000..99815970d08 --- /dev/null +++ b/resource-manager/batch/2024-02-01/pool/version.go @@ -0,0 +1,12 @@ +package pool + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-02-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/pool/%s", defaultApiVersion) +} diff --git a/resource-manager/batch/2024-02-01/privateendpointconnection/README.md b/resource-manager/batch/2024-02-01/privateendpointconnection/README.md new file mode 100644 index 00000000000..ec822b27024 --- /dev/null +++ b/resource-manager/batch/2024-02-01/privateendpointconnection/README.md @@ -0,0 +1,82 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/batch/2024-02-01/privateendpointconnection` Documentation + +The `privateendpointconnection` SDK allows for interaction with the Azure Resource Manager Service `batch` (API Version `2024-02-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/batch/2024-02-01/privateendpointconnection" +``` + + +### Client Initialization + +```go +client := privateendpointconnection.NewPrivateEndpointConnectionClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PrivateEndpointConnectionClient.Delete` + +```go +ctx := context.TODO() +id := privateendpointconnection.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue", "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", "batchAccountValue", "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.ListByBatchAccount` + +```go +ctx := context.TODO() +id := privateendpointconnection.NewBatchAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue") + +// alternatively `client.ListByBatchAccount(ctx, id, privateendpointconnection.DefaultListByBatchAccountOperationOptions())` can be used to do batched pagination +items, err := client.ListByBatchAccountComplete(ctx, id, privateendpointconnection.DefaultListByBatchAccountOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PrivateEndpointConnectionClient.Update` + +```go +ctx := context.TODO() +id := privateendpointconnection.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue", "privateEndpointConnectionValue") + +payload := privateendpointconnection.PrivateEndpointConnection{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload, privateendpointconnection.DefaultUpdateOperationOptions()); err != nil { + // handle the error +} +``` diff --git a/resource-manager/batch/2024-02-01/privateendpointconnection/client.go b/resource-manager/batch/2024-02-01/privateendpointconnection/client.go new file mode 100644 index 00000000000..e430fae79d9 --- /dev/null +++ b/resource-manager/batch/2024-02-01/privateendpointconnection/client.go @@ -0,0 +1,26 @@ +package privateendpointconnection + +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 PrivateEndpointConnectionClient struct { + Client *resourcemanager.Client +} + +func NewPrivateEndpointConnectionClientWithBaseURI(sdkApi sdkEnv.Api) (*PrivateEndpointConnectionClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "privateendpointconnection", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PrivateEndpointConnectionClient: %+v", err) + } + + return &PrivateEndpointConnectionClient{ + Client: client, + }, nil +} diff --git a/resource-manager/batch/2024-02-01/privateendpointconnection/constants.go b/resource-manager/batch/2024-02-01/privateendpointconnection/constants.go new file mode 100644 index 00000000000..d321de07a50 --- /dev/null +++ b/resource-manager/batch/2024-02-01/privateendpointconnection/constants.go @@ -0,0 +1,110 @@ +package privateendpointconnection + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProvisioningState string + +const ( + PrivateEndpointConnectionProvisioningStateCancelled PrivateEndpointConnectionProvisioningState = "Cancelled" + PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" + PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" + PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" + PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" + PrivateEndpointConnectionProvisioningStateUpdating PrivateEndpointConnectionProvisioningState = "Updating" +) + +func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { + return []string{ + string(PrivateEndpointConnectionProvisioningStateCancelled), + string(PrivateEndpointConnectionProvisioningStateCreating), + string(PrivateEndpointConnectionProvisioningStateDeleting), + string(PrivateEndpointConnectionProvisioningStateFailed), + string(PrivateEndpointConnectionProvisioningStateSucceeded), + string(PrivateEndpointConnectionProvisioningStateUpdating), + } +} + +func (s *PrivateEndpointConnectionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointConnectionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { + vals := map[string]PrivateEndpointConnectionProvisioningState{ + "cancelled": PrivateEndpointConnectionProvisioningStateCancelled, + "creating": PrivateEndpointConnectionProvisioningStateCreating, + "deleting": PrivateEndpointConnectionProvisioningStateDeleting, + "failed": PrivateEndpointConnectionProvisioningStateFailed, + "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, + "updating": PrivateEndpointConnectionProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointConnectionProvisioningState(input) + return &out, nil +} + +type PrivateLinkServiceConnectionStatus string + +const ( + PrivateLinkServiceConnectionStatusApproved PrivateLinkServiceConnectionStatus = "Approved" + PrivateLinkServiceConnectionStatusDisconnected PrivateLinkServiceConnectionStatus = "Disconnected" + PrivateLinkServiceConnectionStatusPending PrivateLinkServiceConnectionStatus = "Pending" + PrivateLinkServiceConnectionStatusRejected PrivateLinkServiceConnectionStatus = "Rejected" +) + +func PossibleValuesForPrivateLinkServiceConnectionStatus() []string { + return []string{ + string(PrivateLinkServiceConnectionStatusApproved), + string(PrivateLinkServiceConnectionStatusDisconnected), + string(PrivateLinkServiceConnectionStatusPending), + string(PrivateLinkServiceConnectionStatusRejected), + } +} + +func (s *PrivateLinkServiceConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateLinkServiceConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateLinkServiceConnectionStatus(input string) (*PrivateLinkServiceConnectionStatus, error) { + vals := map[string]PrivateLinkServiceConnectionStatus{ + "approved": PrivateLinkServiceConnectionStatusApproved, + "disconnected": PrivateLinkServiceConnectionStatusDisconnected, + "pending": PrivateLinkServiceConnectionStatusPending, + "rejected": PrivateLinkServiceConnectionStatusRejected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateLinkServiceConnectionStatus(input) + return &out, nil +} diff --git a/resource-manager/batch/2024-02-01/privateendpointconnection/id_batchaccount.go b/resource-manager/batch/2024-02-01/privateendpointconnection/id_batchaccount.go new file mode 100644 index 00000000000..e06e5d5682f --- /dev/null +++ b/resource-manager/batch/2024-02-01/privateendpointconnection/id_batchaccount.go @@ -0,0 +1,125 @@ +package privateendpointconnection + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &BatchAccountId{} + +// BatchAccountId is a struct representing the Resource ID for a Batch Account +type BatchAccountId struct { + SubscriptionId string + ResourceGroupName string + BatchAccountName string +} + +// NewBatchAccountID returns a new BatchAccountId struct +func NewBatchAccountID(subscriptionId string, resourceGroupName string, batchAccountName string) BatchAccountId { + return BatchAccountId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + BatchAccountName: batchAccountName, + } +} + +// ParseBatchAccountID parses 'input' into a BatchAccountId +func ParseBatchAccountID(input string) (*BatchAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&BatchAccountId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BatchAccountId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBatchAccountIDInsensitively parses 'input' case-insensitively into a BatchAccountId +// note: this method should only be used for API response data and not user input +func ParseBatchAccountIDInsensitively(input string) (*BatchAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&BatchAccountId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BatchAccountId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BatchAccountId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.BatchAccountName, ok = input.Parsed["batchAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "batchAccountName", input) + } + + return nil +} + +// ValidateBatchAccountID checks that 'input' can be parsed as a Batch Account ID +func ValidateBatchAccountID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseBatchAccountID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Batch Account ID +func (id BatchAccountId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Batch/batchAccounts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.BatchAccountName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Batch Account ID +func (id BatchAccountId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftBatch", "Microsoft.Batch", "Microsoft.Batch"), + resourceids.StaticSegment("staticBatchAccounts", "batchAccounts", "batchAccounts"), + resourceids.UserSpecifiedSegment("batchAccountName", "batchAccountValue"), + } +} + +// String returns a human-readable description of this Batch Account ID +func (id BatchAccountId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Batch Account Name: %q", id.BatchAccountName), + } + return fmt.Sprintf("Batch Account (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/batch/2024-02-01/privateendpointconnection/id_batchaccount_test.go b/resource-manager/batch/2024-02-01/privateendpointconnection/id_batchaccount_test.go new file mode 100644 index 00000000000..db0a891c217 --- /dev/null +++ b/resource-manager/batch/2024-02-01/privateendpointconnection/id_batchaccount_test.go @@ -0,0 +1,282 @@ +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 = &BatchAccountId{} + +func TestNewBatchAccountID(t *testing.T) { + id := NewBatchAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.BatchAccountName != "batchAccountValue" { + t.Fatalf("Expected %q but got %q for Segment 'BatchAccountName'", id.BatchAccountName, "batchAccountValue") + } +} + +func TestFormatBatchAccountID(t *testing.T) { + actual := NewBatchAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBatchAccountID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BatchAccountId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue", + Expected: &BatchAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BatchAccountName: "batchAccountValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBatchAccountID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BatchAccountName != v.Expected.BatchAccountName { + t.Fatalf("Expected %q but got %q for BatchAccountName", v.Expected.BatchAccountName, actual.BatchAccountName) + } + + } +} + +func TestParseBatchAccountIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BatchAccountId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue", + Expected: &BatchAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BatchAccountName: "batchAccountValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs/bAtChAcCoUnTvAlUe", + Expected: &BatchAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + BatchAccountName: "bAtChAcCoUnTvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs/bAtChAcCoUnTvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBatchAccountIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BatchAccountName != v.Expected.BatchAccountName { + t.Fatalf("Expected %q but got %q for BatchAccountName", v.Expected.BatchAccountName, actual.BatchAccountName) + } + + } +} + +func TestSegmentsForBatchAccountId(t *testing.T) { + segments := BatchAccountId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BatchAccountId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/batch/2024-02-01/privateendpointconnection/id_privateendpointconnection.go b/resource-manager/batch/2024-02-01/privateendpointconnection/id_privateendpointconnection.go new file mode 100644 index 00000000000..c0b3e5ed5fd --- /dev/null +++ b/resource-manager/batch/2024-02-01/privateendpointconnection/id_privateendpointconnection.go @@ -0,0 +1,134 @@ +package privateendpointconnection + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PrivateEndpointConnectionId{} + +// PrivateEndpointConnectionId is a struct representing the Resource ID for a Private Endpoint Connection +type PrivateEndpointConnectionId struct { + SubscriptionId string + ResourceGroupName string + BatchAccountName string + PrivateEndpointConnectionName string +} + +// NewPrivateEndpointConnectionID returns a new PrivateEndpointConnectionId struct +func NewPrivateEndpointConnectionID(subscriptionId string, resourceGroupName string, batchAccountName string, privateEndpointConnectionName string) PrivateEndpointConnectionId { + return PrivateEndpointConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + BatchAccountName: batchAccountName, + 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.BatchAccountName, ok = input.Parsed["batchAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "batchAccountName", 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.Batch/batchAccounts/%s/privateEndpointConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.BatchAccountName, 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("staticMicrosoftBatch", "Microsoft.Batch", "Microsoft.Batch"), + resourceids.StaticSegment("staticBatchAccounts", "batchAccounts", "batchAccounts"), + resourceids.UserSpecifiedSegment("batchAccountName", "batchAccountValue"), + 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("Batch Account Name: %q", id.BatchAccountName), + 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/batch/2024-02-01/privateendpointconnection/id_privateendpointconnection_test.go b/resource-manager/batch/2024-02-01/privateendpointconnection/id_privateendpointconnection_test.go new file mode 100644 index 00000000000..c0a02738c6f --- /dev/null +++ b/resource-manager/batch/2024-02-01/privateendpointconnection/id_privateendpointconnection_test.go @@ -0,0 +1,327 @@ +package privateendpointconnection + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PrivateEndpointConnectionId{} + +func TestNewPrivateEndpointConnectionID(t *testing.T) { + id := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue", "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.BatchAccountName != "batchAccountValue" { + t.Fatalf("Expected %q but got %q for Segment 'BatchAccountName'", id.BatchAccountName, "batchAccountValue") + } + + 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", "batchAccountValue", "privateEndpointConnectionValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/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.Batch", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/privateEndpointConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/privateEndpointConnections/privateEndpointConnectionValue", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BatchAccountName: "batchAccountValue", + PrivateEndpointConnectionName: "privateEndpointConnectionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/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.BatchAccountName != v.Expected.BatchAccountName { + t.Fatalf("Expected %q but got %q for BatchAccountName", v.Expected.BatchAccountName, actual.BatchAccountName) + } + + 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.Batch", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs/bAtChAcCoUnTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/privateEndpointConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs/bAtChAcCoUnTvAlUe/pRiVaTeEnDpOiNtCoNnEcTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/privateEndpointConnections/privateEndpointConnectionValue", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BatchAccountName: "batchAccountValue", + PrivateEndpointConnectionName: "privateEndpointConnectionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/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.bAtCh/bAtChAcCoUnTs/bAtChAcCoUnTvAlUe/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + BatchAccountName: "bAtChAcCoUnTvAlUe", + 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.bAtCh/bAtChAcCoUnTs/bAtChAcCoUnTvAlUe/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.BatchAccountName != v.Expected.BatchAccountName { + t.Fatalf("Expected %q but got %q for BatchAccountName", v.Expected.BatchAccountName, actual.BatchAccountName) + } + + 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/batch/2024-02-01/privateendpointconnection/method_delete.go b/resource-manager/batch/2024-02-01/privateendpointconnection/method_delete.go new file mode 100644 index 00000000000..79b75c96d92 --- /dev/null +++ b/resource-manager/batch/2024-02-01/privateendpointconnection/method_delete.go @@ -0,0 +1,70 @@ +package privateendpointconnection + +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 PrivateEndpointConnectionClient) Delete(ctx context.Context, id PrivateEndpointConnectionId) (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 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(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/batch/2024-02-01/privateendpointconnection/method_get.go b/resource-manager/batch/2024-02-01/privateendpointconnection/method_get.go new file mode 100644 index 00000000000..d0ba6c4f1f5 --- /dev/null +++ b/resource-manager/batch/2024-02-01/privateendpointconnection/method_get.go @@ -0,0 +1,54 @@ +package privateendpointconnection + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *PrivateEndpointConnection +} + +// Get ... +func (c PrivateEndpointConnectionClient) Get(ctx context.Context, id PrivateEndpointConnectionId) (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 PrivateEndpointConnection + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/batch/2024-02-01/privateendpointconnection/method_listbybatchaccount.go b/resource-manager/batch/2024-02-01/privateendpointconnection/method_listbybatchaccount.go new file mode 100644 index 00000000000..576f235e612 --- /dev/null +++ b/resource-manager/batch/2024-02-01/privateendpointconnection/method_listbybatchaccount.go @@ -0,0 +1,119 @@ +package privateendpointconnection + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByBatchAccountOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PrivateEndpointConnection +} + +type ListByBatchAccountCompleteResult struct { + LatestHttpResponse *http.Response + Items []PrivateEndpointConnection +} + +type ListByBatchAccountOperationOptions struct { + Maxresults *int64 +} + +func DefaultListByBatchAccountOperationOptions() ListByBatchAccountOperationOptions { + return ListByBatchAccountOperationOptions{} +} + +func (o ListByBatchAccountOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByBatchAccountOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByBatchAccountOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Maxresults != nil { + out.Append("maxresults", fmt.Sprintf("%v", *o.Maxresults)) + } + return &out +} + +// ListByBatchAccount ... +func (c PrivateEndpointConnectionClient) ListByBatchAccount(ctx context.Context, id BatchAccountId, options ListByBatchAccountOperationOptions) (result ListByBatchAccountOperationResponse, 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()), + 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 *[]PrivateEndpointConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByBatchAccountComplete retrieves all the results into a single object +func (c PrivateEndpointConnectionClient) ListByBatchAccountComplete(ctx context.Context, id BatchAccountId, options ListByBatchAccountOperationOptions) (ListByBatchAccountCompleteResult, error) { + return c.ListByBatchAccountCompleteMatchingPredicate(ctx, id, options, PrivateEndpointConnectionOperationPredicate{}) +} + +// ListByBatchAccountCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PrivateEndpointConnectionClient) ListByBatchAccountCompleteMatchingPredicate(ctx context.Context, id BatchAccountId, options ListByBatchAccountOperationOptions, predicate PrivateEndpointConnectionOperationPredicate) (result ListByBatchAccountCompleteResult, err error) { + items := make([]PrivateEndpointConnection, 0) + + resp, err := c.ListByBatchAccount(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 = ListByBatchAccountCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/batch/2024-02-01/privateendpointconnection/method_update.go b/resource-manager/batch/2024-02-01/privateendpointconnection/method_update.go new file mode 100644 index 00000000000..ab33dd5f8b9 --- /dev/null +++ b/resource-manager/batch/2024-02-01/privateendpointconnection/method_update.go @@ -0,0 +1,103 @@ +package privateendpointconnection + +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 *PrivateEndpointConnection +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + 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 PrivateEndpointConnectionClient) Update(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection, 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 PrivateEndpointConnectionClient) UpdateThenPoll(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection, 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/batch/2024-02-01/privateendpointconnection/model_privateendpoint.go b/resource-manager/batch/2024-02-01/privateendpointconnection/model_privateendpoint.go new file mode 100644 index 00000000000..36d044c72d1 --- /dev/null +++ b/resource-manager/batch/2024-02-01/privateendpointconnection/model_privateendpoint.go @@ -0,0 +1,8 @@ +package privateendpointconnection + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpoint struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/privateendpointconnection/model_privateendpointconnection.go b/resource-manager/batch/2024-02-01/privateendpointconnection/model_privateendpointconnection.go new file mode 100644 index 00000000000..5eb3426b06a --- /dev/null +++ b/resource-manager/batch/2024-02-01/privateendpointconnection/model_privateendpointconnection.go @@ -0,0 +1,12 @@ +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 { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/privateendpointconnection/model_privateendpointconnectionproperties.go b/resource-manager/batch/2024-02-01/privateendpointconnection/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..44a28007fe1 --- /dev/null +++ b/resource-manager/batch/2024-02-01/privateendpointconnection/model_privateendpointconnectionproperties.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 PrivateEndpointConnectionProperties struct { + GroupIds *[]string `json:"groupIds,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/batch/2024-02-01/privateendpointconnection/model_privatelinkserviceconnectionstate.go b/resource-manager/batch/2024-02-01/privateendpointconnection/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..278ed02405a --- /dev/null +++ b/resource-manager/batch/2024-02-01/privateendpointconnection/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package privateendpointconnection + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status PrivateLinkServiceConnectionStatus `json:"status"` +} diff --git a/resource-manager/batch/2024-02-01/privateendpointconnection/predicates.go b/resource-manager/batch/2024-02-01/privateendpointconnection/predicates.go new file mode 100644 index 00000000000..92647ebc1ea --- /dev/null +++ b/resource-manager/batch/2024-02-01/privateendpointconnection/predicates.go @@ -0,0 +1,32 @@ +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 PrivateEndpointConnectionOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p PrivateEndpointConnectionOperationPredicate) Matches(input PrivateEndpointConnection) 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.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/batch/2024-02-01/privateendpointconnection/version.go b/resource-manager/batch/2024-02-01/privateendpointconnection/version.go new file mode 100644 index 00000000000..018cf8e011a --- /dev/null +++ b/resource-manager/batch/2024-02-01/privateendpointconnection/version.go @@ -0,0 +1,12 @@ +package privateendpointconnection + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-02-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/privateendpointconnection/%s", defaultApiVersion) +} diff --git a/resource-manager/batch/2024-02-01/privatelinkresource/README.md b/resource-manager/batch/2024-02-01/privatelinkresource/README.md new file mode 100644 index 00000000000..784e46a9f7e --- /dev/null +++ b/resource-manager/batch/2024-02-01/privatelinkresource/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/batch/2024-02-01/privatelinkresource` Documentation + +The `privatelinkresource` SDK allows for interaction with the Azure Resource Manager Service `batch` (API Version `2024-02-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/batch/2024-02-01/privatelinkresource" +``` + + +### Client Initialization + +```go +client := privatelinkresource.NewPrivateLinkResourceClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PrivateLinkResourceClient.Get` + +```go +ctx := context.TODO() +id := privatelinkresource.NewPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue", "privateLinkResourceValue") + +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: `PrivateLinkResourceClient.ListByBatchAccount` + +```go +ctx := context.TODO() +id := privatelinkresource.NewBatchAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue") + +// alternatively `client.ListByBatchAccount(ctx, id, privatelinkresource.DefaultListByBatchAccountOperationOptions())` can be used to do batched pagination +items, err := client.ListByBatchAccountComplete(ctx, id, privatelinkresource.DefaultListByBatchAccountOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/batch/2024-02-01/privatelinkresource/client.go b/resource-manager/batch/2024-02-01/privatelinkresource/client.go new file mode 100644 index 00000000000..7ff8fa2a05f --- /dev/null +++ b/resource-manager/batch/2024-02-01/privatelinkresource/client.go @@ -0,0 +1,26 @@ +package privatelinkresource + +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 PrivateLinkResourceClient struct { + Client *resourcemanager.Client +} + +func NewPrivateLinkResourceClientWithBaseURI(sdkApi sdkEnv.Api) (*PrivateLinkResourceClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "privatelinkresource", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PrivateLinkResourceClient: %+v", err) + } + + return &PrivateLinkResourceClient{ + Client: client, + }, nil +} diff --git a/resource-manager/batch/2024-02-01/privatelinkresource/id_batchaccount.go b/resource-manager/batch/2024-02-01/privatelinkresource/id_batchaccount.go new file mode 100644 index 00000000000..880f3429693 --- /dev/null +++ b/resource-manager/batch/2024-02-01/privatelinkresource/id_batchaccount.go @@ -0,0 +1,125 @@ +package privatelinkresource + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &BatchAccountId{} + +// BatchAccountId is a struct representing the Resource ID for a Batch Account +type BatchAccountId struct { + SubscriptionId string + ResourceGroupName string + BatchAccountName string +} + +// NewBatchAccountID returns a new BatchAccountId struct +func NewBatchAccountID(subscriptionId string, resourceGroupName string, batchAccountName string) BatchAccountId { + return BatchAccountId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + BatchAccountName: batchAccountName, + } +} + +// ParseBatchAccountID parses 'input' into a BatchAccountId +func ParseBatchAccountID(input string) (*BatchAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&BatchAccountId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BatchAccountId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBatchAccountIDInsensitively parses 'input' case-insensitively into a BatchAccountId +// note: this method should only be used for API response data and not user input +func ParseBatchAccountIDInsensitively(input string) (*BatchAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&BatchAccountId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BatchAccountId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BatchAccountId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.BatchAccountName, ok = input.Parsed["batchAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "batchAccountName", input) + } + + return nil +} + +// ValidateBatchAccountID checks that 'input' can be parsed as a Batch Account ID +func ValidateBatchAccountID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseBatchAccountID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Batch Account ID +func (id BatchAccountId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Batch/batchAccounts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.BatchAccountName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Batch Account ID +func (id BatchAccountId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftBatch", "Microsoft.Batch", "Microsoft.Batch"), + resourceids.StaticSegment("staticBatchAccounts", "batchAccounts", "batchAccounts"), + resourceids.UserSpecifiedSegment("batchAccountName", "batchAccountValue"), + } +} + +// String returns a human-readable description of this Batch Account ID +func (id BatchAccountId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Batch Account Name: %q", id.BatchAccountName), + } + return fmt.Sprintf("Batch Account (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/batch/2024-02-01/privatelinkresource/id_batchaccount_test.go b/resource-manager/batch/2024-02-01/privatelinkresource/id_batchaccount_test.go new file mode 100644 index 00000000000..218dff1995e --- /dev/null +++ b/resource-manager/batch/2024-02-01/privatelinkresource/id_batchaccount_test.go @@ -0,0 +1,282 @@ +package privatelinkresource + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &BatchAccountId{} + +func TestNewBatchAccountID(t *testing.T) { + id := NewBatchAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.BatchAccountName != "batchAccountValue" { + t.Fatalf("Expected %q but got %q for Segment 'BatchAccountName'", id.BatchAccountName, "batchAccountValue") + } +} + +func TestFormatBatchAccountID(t *testing.T) { + actual := NewBatchAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "batchAccountValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBatchAccountID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BatchAccountId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue", + Expected: &BatchAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BatchAccountName: "batchAccountValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBatchAccountID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BatchAccountName != v.Expected.BatchAccountName { + t.Fatalf("Expected %q but got %q for BatchAccountName", v.Expected.BatchAccountName, actual.BatchAccountName) + } + + } +} + +func TestParseBatchAccountIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BatchAccountId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue", + Expected: &BatchAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BatchAccountName: "batchAccountValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs/bAtChAcCoUnTvAlUe", + Expected: &BatchAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + BatchAccountName: "bAtChAcCoUnTvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs/bAtChAcCoUnTvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBatchAccountIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BatchAccountName != v.Expected.BatchAccountName { + t.Fatalf("Expected %q but got %q for BatchAccountName", v.Expected.BatchAccountName, actual.BatchAccountName) + } + + } +} + +func TestSegmentsForBatchAccountId(t *testing.T) { + segments := BatchAccountId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BatchAccountId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/batch/2024-02-01/privatelinkresource/id_privatelinkresource.go b/resource-manager/batch/2024-02-01/privatelinkresource/id_privatelinkresource.go new file mode 100644 index 00000000000..1cefbe677b1 --- /dev/null +++ b/resource-manager/batch/2024-02-01/privatelinkresource/id_privatelinkresource.go @@ -0,0 +1,134 @@ +package privatelinkresource + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PrivateLinkResourceId{} + +// PrivateLinkResourceId is a struct representing the Resource ID for a Private Link Resource +type PrivateLinkResourceId struct { + SubscriptionId string + ResourceGroupName string + BatchAccountName string + PrivateLinkResourceName string +} + +// NewPrivateLinkResourceID returns a new PrivateLinkResourceId struct +func NewPrivateLinkResourceID(subscriptionId string, resourceGroupName string, batchAccountName string, privateLinkResourceName string) PrivateLinkResourceId { + return PrivateLinkResourceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + BatchAccountName: batchAccountName, + 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.BatchAccountName, ok = input.Parsed["batchAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "batchAccountName", 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.Batch/batchAccounts/%s/privateLinkResources/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.BatchAccountName, 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("staticMicrosoftBatch", "Microsoft.Batch", "Microsoft.Batch"), + resourceids.StaticSegment("staticBatchAccounts", "batchAccounts", "batchAccounts"), + resourceids.UserSpecifiedSegment("batchAccountName", "batchAccountValue"), + 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("Batch Account Name: %q", id.BatchAccountName), + 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/batch/2024-02-01/privatelinkresource/id_privatelinkresource_test.go b/resource-manager/batch/2024-02-01/privatelinkresource/id_privatelinkresource_test.go new file mode 100644 index 00000000000..43f5713b134 --- /dev/null +++ b/resource-manager/batch/2024-02-01/privatelinkresource/id_privatelinkresource_test.go @@ -0,0 +1,327 @@ +package privatelinkresource + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (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", "batchAccountValue", "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.BatchAccountName != "batchAccountValue" { + t.Fatalf("Expected %q but got %q for Segment 'BatchAccountName'", id.BatchAccountName, "batchAccountValue") + } + + 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", "batchAccountValue", "privateLinkResourceValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/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.Batch", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/privateLinkResources", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/privateLinkResources/privateLinkResourceValue", + Expected: &PrivateLinkResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BatchAccountName: "batchAccountValue", + PrivateLinkResourceName: "privateLinkResourceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/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.BatchAccountName != v.Expected.BatchAccountName { + t.Fatalf("Expected %q but got %q for BatchAccountName", v.Expected.BatchAccountName, actual.BatchAccountName) + } + + 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.Batch", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs/bAtChAcCoUnTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/privateLinkResources", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.bAtCh/bAtChAcCoUnTs/bAtChAcCoUnTvAlUe/pRiVaTeLiNkReSoUrCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/privateLinkResources/privateLinkResourceValue", + Expected: &PrivateLinkResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BatchAccountName: "batchAccountValue", + PrivateLinkResourceName: "privateLinkResourceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Batch/batchAccounts/batchAccountValue/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.bAtCh/bAtChAcCoUnTs/bAtChAcCoUnTvAlUe/pRiVaTeLiNkReSoUrCeS/pRiVaTeLiNkReSoUrCeVaLuE", + Expected: &PrivateLinkResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + BatchAccountName: "bAtChAcCoUnTvAlUe", + 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.bAtCh/bAtChAcCoUnTs/bAtChAcCoUnTvAlUe/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.BatchAccountName != v.Expected.BatchAccountName { + t.Fatalf("Expected %q but got %q for BatchAccountName", v.Expected.BatchAccountName, actual.BatchAccountName) + } + + 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/batch/2024-02-01/privatelinkresource/method_get.go b/resource-manager/batch/2024-02-01/privatelinkresource/method_get.go new file mode 100644 index 00000000000..3a5bfc9e044 --- /dev/null +++ b/resource-manager/batch/2024-02-01/privatelinkresource/method_get.go @@ -0,0 +1,54 @@ +package privatelinkresource + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *PrivateLinkResource +} + +// Get ... +func (c PrivateLinkResourceClient) Get(ctx context.Context, id PrivateLinkResourceId) (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 PrivateLinkResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/batch/2024-02-01/privatelinkresource/method_listbybatchaccount.go b/resource-manager/batch/2024-02-01/privatelinkresource/method_listbybatchaccount.go new file mode 100644 index 00000000000..f23a760dda9 --- /dev/null +++ b/resource-manager/batch/2024-02-01/privatelinkresource/method_listbybatchaccount.go @@ -0,0 +1,119 @@ +package privatelinkresource + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByBatchAccountOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PrivateLinkResource +} + +type ListByBatchAccountCompleteResult struct { + LatestHttpResponse *http.Response + Items []PrivateLinkResource +} + +type ListByBatchAccountOperationOptions struct { + Maxresults *int64 +} + +func DefaultListByBatchAccountOperationOptions() ListByBatchAccountOperationOptions { + return ListByBatchAccountOperationOptions{} +} + +func (o ListByBatchAccountOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByBatchAccountOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByBatchAccountOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Maxresults != nil { + out.Append("maxresults", fmt.Sprintf("%v", *o.Maxresults)) + } + return &out +} + +// ListByBatchAccount ... +func (c PrivateLinkResourceClient) ListByBatchAccount(ctx context.Context, id BatchAccountId, options ListByBatchAccountOperationOptions) (result ListByBatchAccountOperationResponse, 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()), + 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 *[]PrivateLinkResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByBatchAccountComplete retrieves all the results into a single object +func (c PrivateLinkResourceClient) ListByBatchAccountComplete(ctx context.Context, id BatchAccountId, options ListByBatchAccountOperationOptions) (ListByBatchAccountCompleteResult, error) { + return c.ListByBatchAccountCompleteMatchingPredicate(ctx, id, options, PrivateLinkResourceOperationPredicate{}) +} + +// ListByBatchAccountCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PrivateLinkResourceClient) ListByBatchAccountCompleteMatchingPredicate(ctx context.Context, id BatchAccountId, options ListByBatchAccountOperationOptions, predicate PrivateLinkResourceOperationPredicate) (result ListByBatchAccountCompleteResult, err error) { + items := make([]PrivateLinkResource, 0) + + resp, err := c.ListByBatchAccount(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 = ListByBatchAccountCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/batch/2024-02-01/privatelinkresource/model_privatelinkresource.go b/resource-manager/batch/2024-02-01/privatelinkresource/model_privatelinkresource.go new file mode 100644 index 00000000000..7a4db36c0ef --- /dev/null +++ b/resource-manager/batch/2024-02-01/privatelinkresource/model_privatelinkresource.go @@ -0,0 +1,12 @@ +package privatelinkresource + +// 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 { + Etag *string `json:"etag,omitempty"` + 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/batch/2024-02-01/privatelinkresource/model_privatelinkresourceproperties.go b/resource-manager/batch/2024-02-01/privatelinkresource/model_privatelinkresourceproperties.go new file mode 100644 index 00000000000..bae657c2cde --- /dev/null +++ b/resource-manager/batch/2024-02-01/privatelinkresource/model_privatelinkresourceproperties.go @@ -0,0 +1,10 @@ +package privatelinkresource + +// 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/batch/2024-02-01/privatelinkresource/predicates.go b/resource-manager/batch/2024-02-01/privatelinkresource/predicates.go new file mode 100644 index 00000000000..d3378fa9cf3 --- /dev/null +++ b/resource-manager/batch/2024-02-01/privatelinkresource/predicates.go @@ -0,0 +1,32 @@ +package privatelinkresource + +// 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 { + Etag *string + Id *string + Name *string + Type *string +} + +func (p PrivateLinkResourceOperationPredicate) Matches(input PrivateLinkResource) 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.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/batch/2024-02-01/privatelinkresource/version.go b/resource-manager/batch/2024-02-01/privatelinkresource/version.go new file mode 100644 index 00000000000..afd3cdb8e28 --- /dev/null +++ b/resource-manager/batch/2024-02-01/privatelinkresource/version.go @@ -0,0 +1,12 @@ +package privatelinkresource + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-02-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/privatelinkresource/%s", defaultApiVersion) +}