From 74bd244c4ec98e3ff2439b1916ad74fc478ba17c Mon Sep 17 00:00:00 2001 From: hc-github-team-tf-azure <> Date: Fri, 24 May 2024 08:04:03 +0000 Subject: [PATCH] Updating based on ea0d8cdb --- resource-manager/signalr/2024-03-01/client.go | 28 + .../signalr/2024-03-01/signalr/README.md | 652 ++++++++++++++++ .../signalr/2024-03-01/signalr/client.go | 26 + .../signalr/2024-03-01/signalr/constants.go | 521 +++++++++++++ .../signalr/id_customcertificate.go | 139 ++++ .../signalr/id_customcertificate_test.go | 327 ++++++++ .../2024-03-01/signalr/id_customdomain.go | 139 ++++ .../signalr/id_customdomain_test.go | 327 ++++++++ .../signalr/2024-03-01/signalr/id_location.go | 121 +++ .../2024-03-01/signalr/id_location_test.go | 237 ++++++ .../signalr/id_privateendpointconnection.go | 139 ++++ .../id_privateendpointconnection_test.go | 327 ++++++++ .../signalr/2024-03-01/signalr/id_replica.go | 139 ++++ .../2024-03-01/signalr/id_replica_test.go | 327 ++++++++ .../id_replicasharedprivatelinkresource.go | 148 ++++ ...d_replicasharedprivatelinkresource_test.go | 372 +++++++++ .../signalr/id_sharedprivatelinkresource.go | 139 ++++ .../id_sharedprivatelinkresource_test.go | 327 ++++++++ .../signalr/2024-03-01/signalr/id_signalr.go | 130 ++++ .../2024-03-01/signalr/id_signalr_test.go | 282 +++++++ .../signalr/method_checknameavailability.go | 59 ++ .../signalr/method_createorupdate.go | 76 ++ ...method_customcertificatescreateorupdate.go | 75 ++ .../method_customcertificatesdelete.go | 47 ++ .../signalr/method_customcertificatesget.go | 54 ++ .../signalr/method_customcertificateslist.go | 92 +++ .../method_customdomainscreateorupdate.go | 74 ++ .../signalr/method_customdomainsdelete.go | 71 ++ .../signalr/method_customdomainsget.go | 54 ++ .../signalr/method_customdomainslist.go | 92 +++ .../2024-03-01/signalr/method_delete.go | 71 ++ .../signalr/2024-03-01/signalr/method_get.go | 54 ++ .../signalr/method_listbyresourcegroup.go | 93 +++ .../signalr/method_listbysubscription.go | 93 +++ .../2024-03-01/signalr/method_listkeys.go | 55 ++ .../signalr/method_listreplicaskus.go | 92 +++ .../2024-03-01/signalr/method_listskus.go | 92 +++ ...method_privateendpointconnectionsdelete.go | 71 ++ .../method_privateendpointconnectionsget.go | 54 ++ .../method_privateendpointconnectionslist.go | 92 +++ ...method_privateendpointconnectionsupdate.go | 58 ++ .../method_privatelinkresourceslist.go | 92 +++ .../signalr/method_regeneratekey.go | 75 ++ .../signalr/method_replicascreateorupdate.go | 75 ++ .../signalr/method_replicasdelete.go | 47 ++ .../2024-03-01/signalr/method_replicasget.go | 54 ++ ...haredprivatelinkresourcescreateorupdate.go | 75 ++ ...od_replicasharedprivatelinkresourcesget.go | 54 ++ ...d_replicasharedprivatelinkresourceslist.go | 92 +++ .../2024-03-01/signalr/method_replicaslist.go | 92 +++ .../signalr/method_replicasrestart.go | 70 ++ .../signalr/method_replicasupdate.go | 75 ++ .../2024-03-01/signalr/method_restart.go | 70 ++ ...haredprivatelinkresourcescreateorupdate.go | 75 ++ ...method_sharedprivatelinkresourcesdelete.go | 71 ++ .../method_sharedprivatelinkresourcesget.go | 54 ++ .../method_sharedprivatelinkresourceslist.go | 92 +++ .../2024-03-01/signalr/method_update.go | 75 ++ .../2024-03-01/signalr/method_usageslist.go | 92 +++ .../signalr/model_customcertificate.go | 16 + .../model_customcertificateproperties.go | 11 + .../2024-03-01/signalr/model_customdomain.go | 16 + .../signalr/model_customdomainproperties.go | 10 + .../2024-03-01/signalr/model_iprule.go | 9 + .../signalr/model_livetracecategory.go | 9 + .../signalr/model_livetraceconfiguration.go | 9 + .../signalr/model_managedidentitysettings.go | 8 + .../signalr/model_nameavailability.go | 10 + .../model_nameavailabilityparameters.go | 9 + .../2024-03-01/signalr/model_networkacl.go | 9 + .../signalr/model_privateendpoint.go | 8 + .../signalr/model_privateendpointacl.go | 10 + .../model_privateendpointconnection.go | 16 + ...del_privateendpointconnectionproperties.go | 11 + .../signalr/model_privatelinkresource.go | 16 + .../model_privatelinkresourceproperties.go | 11 + ...model_privatelinkserviceconnectionstate.go | 10 + .../signalr/model_regeneratekeyparameters.go | 8 + .../2024-03-01/signalr/model_replica.go | 19 + .../signalr/model_replicaproperties.go | 10 + .../signalr/model_resourcelogcategory.go | 9 + .../signalr/model_resourcelogconfiguration.go | 8 + .../signalr/model_resourcereference.go | 8 + .../2024-03-01/signalr/model_resourcesku.go | 12 + .../signalr/model_serverlesssettings.go | 8 + .../model_serverlessupstreamsettings.go | 8 + ..._shareableprivatelinkresourceproperties.go | 10 + .../model_shareableprivatelinkresourcetype.go | 9 + .../model_sharedprivatelinkresource.go | 16 + ...del_sharedprivatelinkresourceproperties.go | 12 + .../signalr/model_signalrcorssettings.go | 8 + .../signalr/model_signalrfeature.go | 10 + .../2024-03-01/signalr/model_signalrkeys.go | 11 + .../signalr/model_signalrnetworkacls.go | 11 + .../signalr/model_signalrproperties.go | 29 + .../signalr/model_signalrresource.go | 22 + .../signalr/model_signalrtlssettings.go | 8 + .../2024-03-01/signalr/model_signalrusage.go | 12 + .../signalr/model_signalrusagename.go | 9 + .../signalr/2024-03-01/signalr/model_sku.go | 10 + .../2024-03-01/signalr/model_skucapacity.go | 12 + .../signalr/model_upstreamauthsettings.go | 9 + .../signalr/model_upstreamtemplate.go | 12 + .../signalr/2024-03-01/signalr/predicates.go | 216 ++++++ .../signalr/2024-03-01/signalr/version.go | 12 + .../webpubsub/2024-03-01/client.go | 28 + .../webpubsub/2024-03-01/webpubsub/README.md | 714 ++++++++++++++++++ .../webpubsub/2024-03-01/webpubsub/client.go | 26 + .../2024-03-01/webpubsub/constants.go | 550 ++++++++++++++ .../webpubsub/id_customcertificate.go | 139 ++++ .../webpubsub/id_customcertificate_test.go | 327 ++++++++ .../2024-03-01/webpubsub/id_customdomain.go | 139 ++++ .../webpubsub/id_customdomain_test.go | 327 ++++++++ .../webpubsub/2024-03-01/webpubsub/id_hub.go | 139 ++++ .../2024-03-01/webpubsub/id_hub_test.go | 327 ++++++++ .../2024-03-01/webpubsub/id_location.go | 121 +++ .../2024-03-01/webpubsub/id_location_test.go | 237 ++++++ .../webpubsub/id_privateendpointconnection.go | 139 ++++ .../id_privateendpointconnection_test.go | 327 ++++++++ .../2024-03-01/webpubsub/id_replica.go | 139 ++++ .../2024-03-01/webpubsub/id_replica_test.go | 327 ++++++++ .../id_replicasharedprivatelinkresource.go | 148 ++++ ...d_replicasharedprivatelinkresource_test.go | 372 +++++++++ .../webpubsub/id_sharedprivatelinkresource.go | 139 ++++ .../id_sharedprivatelinkresource_test.go | 327 ++++++++ .../2024-03-01/webpubsub/id_webpubsub.go | 130 ++++ .../2024-03-01/webpubsub/id_webpubsub_test.go | 282 +++++++ .../webpubsub/method_checknameavailability.go | 59 ++ .../webpubsub/method_createorupdate.go | 76 ++ ...method_customcertificatescreateorupdate.go | 75 ++ .../method_customcertificatesdelete.go | 47 ++ .../webpubsub/method_customcertificatesget.go | 54 ++ .../method_customcertificateslist.go | 92 +++ .../method_customdomainscreateorupdate.go | 74 ++ .../webpubsub/method_customdomainsdelete.go | 71 ++ .../webpubsub/method_customdomainsget.go | 54 ++ .../webpubsub/method_customdomainslist.go | 92 +++ .../2024-03-01/webpubsub/method_delete.go | 71 ++ .../2024-03-01/webpubsub/method_get.go | 54 ++ .../webpubsub/method_hubscreateorupdate.go | 75 ++ .../2024-03-01/webpubsub/method_hubsdelete.go | 71 ++ .../2024-03-01/webpubsub/method_hubsget.go | 54 ++ .../2024-03-01/webpubsub/method_hubslist.go | 92 +++ .../webpubsub/method_listbyresourcegroup.go | 93 +++ .../webpubsub/method_listbysubscription.go | 93 +++ .../2024-03-01/webpubsub/method_listkeys.go | 55 ++ .../webpubsub/method_listreplicaskus.go | 92 +++ .../2024-03-01/webpubsub/method_listskus.go | 92 +++ ...method_privateendpointconnectionsdelete.go | 71 ++ .../method_privateendpointconnectionsget.go | 54 ++ .../method_privateendpointconnectionslist.go | 92 +++ ...method_privateendpointconnectionsupdate.go | 58 ++ .../method_privatelinkresourceslist.go | 92 +++ .../webpubsub/method_regeneratekey.go | 75 ++ .../method_replicascreateorupdate.go | 75 ++ .../webpubsub/method_replicasdelete.go | 47 ++ .../webpubsub/method_replicasget.go | 54 ++ ...haredprivatelinkresourcescreateorupdate.go | 75 ++ ...od_replicasharedprivatelinkresourcesget.go | 54 ++ ...d_replicasharedprivatelinkresourceslist.go | 92 +++ .../webpubsub/method_replicaslist.go | 92 +++ .../webpubsub/method_replicasrestart.go | 70 ++ .../webpubsub/method_replicasupdate.go | 75 ++ .../2024-03-01/webpubsub/method_restart.go | 70 ++ ...haredprivatelinkresourcescreateorupdate.go | 75 ++ ...method_sharedprivatelinkresourcesdelete.go | 71 ++ .../method_sharedprivatelinkresourcesget.go | 54 ++ .../method_sharedprivatelinkresourceslist.go | 92 +++ .../2024-03-01/webpubsub/method_update.go | 75 ++ .../2024-03-01/webpubsub/method_usageslist.go | 92 +++ .../webpubsub/model_customcertificate.go | 16 + .../model_customcertificateproperties.go | 11 + .../webpubsub/model_customdomain.go | 16 + .../webpubsub/model_customdomainproperties.go | 10 + .../webpubsub/model_eventhandler.go | 11 + .../webpubsub/model_eventhubendpoint.go | 42 ++ .../webpubsub/model_eventlistener.go | 41 + .../webpubsub/model_eventlistenerendpoint.go | 53 ++ .../webpubsub/model_eventlistenerfilter.go | 53 ++ .../webpubsub/model_eventnamefilter.go | 42 ++ .../2024-03-01/webpubsub/model_iprule.go | 9 + .../webpubsub/model_livetracecategory.go | 9 + .../webpubsub/model_livetraceconfiguration.go | 9 + .../model_managedidentitysettings.go | 8 + .../webpubsub/model_nameavailability.go | 10 + .../model_nameavailabilityparameters.go | 9 + .../2024-03-01/webpubsub/model_networkacl.go | 9 + .../webpubsub/model_privateendpoint.go | 8 + .../webpubsub/model_privateendpointacl.go | 10 + .../model_privateendpointconnection.go | 16 + ...del_privateendpointconnectionproperties.go | 11 + .../webpubsub/model_privatelinkresource.go | 16 + .../model_privatelinkresourceproperties.go | 11 + ...model_privatelinkserviceconnectionstate.go | 10 + .../model_regeneratekeyparameters.go | 8 + .../2024-03-01/webpubsub/model_replica.go | 19 + .../webpubsub/model_replicaproperties.go | 10 + .../webpubsub/model_resourcelogcategory.go | 9 + .../model_resourcelogconfiguration.go | 8 + .../webpubsub/model_resourcereference.go | 8 + .../2024-03-01/webpubsub/model_resourcesku.go | 12 + ..._shareableprivatelinkresourceproperties.go | 10 + .../model_shareableprivatelinkresourcetype.go | 9 + .../model_sharedprivatelinkresource.go | 16 + ...del_sharedprivatelinkresourceproperties.go | 12 + .../webpubsub/model_signalrserviceusage.go | 12 + .../model_signalrserviceusagename.go | 9 + .../2024-03-01/webpubsub/model_sku.go | 10 + .../2024-03-01/webpubsub/model_skucapacity.go | 12 + .../webpubsub/model_upstreamauthsettings.go | 9 + .../webpubsub/model_webpubsubhub.go | 16 + .../webpubsub/model_webpubsubhubproperties.go | 11 + .../webpubsub/model_webpubsubkeys.go | 11 + .../webpubsub/model_webpubsubnetworkacls.go | 11 + .../webpubsub/model_webpubsubproperties.go | 26 + .../webpubsub/model_webpubsubresource.go | 22 + .../model_webpubsubsocketiosettings.go | 8 + .../webpubsub/model_webpubsubtlssettings.go | 8 + .../2024-03-01/webpubsub/predicates.go | 239 ++++++ .../webpubsub/2024-03-01/webpubsub/version.go | 12 + 220 files changed, 17944 insertions(+) create mode 100644 resource-manager/signalr/2024-03-01/client.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/README.md create mode 100644 resource-manager/signalr/2024-03-01/signalr/client.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/constants.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/id_customcertificate.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/id_customcertificate_test.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/id_customdomain.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/id_customdomain_test.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/id_location.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/id_location_test.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/id_privateendpointconnection.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/id_privateendpointconnection_test.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/id_replica.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/id_replica_test.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/id_replicasharedprivatelinkresource.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/id_replicasharedprivatelinkresource_test.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/id_sharedprivatelinkresource.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/id_sharedprivatelinkresource_test.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/id_signalr.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/id_signalr_test.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/method_checknameavailability.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/method_createorupdate.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/method_customcertificatescreateorupdate.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/method_customcertificatesdelete.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/method_customcertificatesget.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/method_customcertificateslist.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/method_customdomainscreateorupdate.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/method_customdomainsdelete.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/method_customdomainsget.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/method_customdomainslist.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/method_delete.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/method_get.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/method_listbyresourcegroup.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/method_listbysubscription.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/method_listkeys.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/method_listreplicaskus.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/method_listskus.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/method_privateendpointconnectionsdelete.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/method_privateendpointconnectionsget.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/method_privateendpointconnectionslist.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/method_privateendpointconnectionsupdate.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/method_privatelinkresourceslist.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/method_regeneratekey.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/method_replicascreateorupdate.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/method_replicasdelete.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/method_replicasget.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/method_replicasharedprivatelinkresourcescreateorupdate.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/method_replicasharedprivatelinkresourcesget.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/method_replicasharedprivatelinkresourceslist.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/method_replicaslist.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/method_replicasrestart.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/method_replicasupdate.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/method_restart.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/method_sharedprivatelinkresourcescreateorupdate.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/method_sharedprivatelinkresourcesdelete.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/method_sharedprivatelinkresourcesget.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/method_sharedprivatelinkresourceslist.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/method_update.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/method_usageslist.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/model_customcertificate.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/model_customcertificateproperties.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/model_customdomain.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/model_customdomainproperties.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/model_iprule.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/model_livetracecategory.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/model_livetraceconfiguration.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/model_managedidentitysettings.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/model_nameavailability.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/model_nameavailabilityparameters.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/model_networkacl.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/model_privateendpoint.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/model_privateendpointacl.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/model_privateendpointconnection.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/model_privateendpointconnectionproperties.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/model_privatelinkresource.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/model_privatelinkresourceproperties.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/model_privatelinkserviceconnectionstate.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/model_regeneratekeyparameters.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/model_replica.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/model_replicaproperties.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/model_resourcelogcategory.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/model_resourcelogconfiguration.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/model_resourcereference.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/model_resourcesku.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/model_serverlesssettings.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/model_serverlessupstreamsettings.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/model_shareableprivatelinkresourceproperties.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/model_shareableprivatelinkresourcetype.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/model_sharedprivatelinkresource.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/model_sharedprivatelinkresourceproperties.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/model_signalrcorssettings.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/model_signalrfeature.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/model_signalrkeys.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/model_signalrnetworkacls.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/model_signalrproperties.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/model_signalrresource.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/model_signalrtlssettings.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/model_signalrusage.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/model_signalrusagename.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/model_sku.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/model_skucapacity.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/model_upstreamauthsettings.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/model_upstreamtemplate.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/predicates.go create mode 100644 resource-manager/signalr/2024-03-01/signalr/version.go create mode 100644 resource-manager/webpubsub/2024-03-01/client.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/README.md create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/client.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/constants.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/id_customcertificate.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/id_customcertificate_test.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/id_customdomain.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/id_customdomain_test.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/id_hub.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/id_hub_test.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/id_location.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/id_location_test.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/id_privateendpointconnection.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/id_privateendpointconnection_test.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/id_replica.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/id_replica_test.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/id_replicasharedprivatelinkresource.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/id_replicasharedprivatelinkresource_test.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/id_sharedprivatelinkresource.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/id_sharedprivatelinkresource_test.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/id_webpubsub.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/id_webpubsub_test.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/method_checknameavailability.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/method_createorupdate.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/method_customcertificatescreateorupdate.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/method_customcertificatesdelete.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/method_customcertificatesget.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/method_customcertificateslist.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/method_customdomainscreateorupdate.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/method_customdomainsdelete.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/method_customdomainsget.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/method_customdomainslist.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/method_delete.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/method_get.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/method_hubscreateorupdate.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/method_hubsdelete.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/method_hubsget.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/method_hubslist.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/method_listbyresourcegroup.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/method_listbysubscription.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/method_listkeys.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/method_listreplicaskus.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/method_listskus.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/method_privateendpointconnectionsdelete.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/method_privateendpointconnectionsget.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/method_privateendpointconnectionslist.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/method_privateendpointconnectionsupdate.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/method_privatelinkresourceslist.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/method_regeneratekey.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/method_replicascreateorupdate.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/method_replicasdelete.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/method_replicasget.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/method_replicasharedprivatelinkresourcescreateorupdate.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/method_replicasharedprivatelinkresourcesget.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/method_replicasharedprivatelinkresourceslist.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/method_replicaslist.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/method_replicasrestart.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/method_replicasupdate.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/method_restart.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/method_sharedprivatelinkresourcescreateorupdate.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/method_sharedprivatelinkresourcesdelete.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/method_sharedprivatelinkresourcesget.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/method_sharedprivatelinkresourceslist.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/method_update.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/method_usageslist.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/model_customcertificate.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/model_customcertificateproperties.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/model_customdomain.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/model_customdomainproperties.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/model_eventhandler.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/model_eventhubendpoint.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/model_eventlistener.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/model_eventlistenerendpoint.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/model_eventlistenerfilter.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/model_eventnamefilter.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/model_iprule.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/model_livetracecategory.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/model_livetraceconfiguration.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/model_managedidentitysettings.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/model_nameavailability.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/model_nameavailabilityparameters.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/model_networkacl.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/model_privateendpoint.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/model_privateendpointacl.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/model_privateendpointconnection.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/model_privateendpointconnectionproperties.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/model_privatelinkresource.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/model_privatelinkresourceproperties.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/model_privatelinkserviceconnectionstate.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/model_regeneratekeyparameters.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/model_replica.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/model_replicaproperties.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/model_resourcelogcategory.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/model_resourcelogconfiguration.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/model_resourcereference.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/model_resourcesku.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/model_shareableprivatelinkresourceproperties.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/model_shareableprivatelinkresourcetype.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/model_sharedprivatelinkresource.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/model_sharedprivatelinkresourceproperties.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/model_signalrserviceusage.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/model_signalrserviceusagename.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/model_sku.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/model_skucapacity.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/model_upstreamauthsettings.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/model_webpubsubhub.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/model_webpubsubhubproperties.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/model_webpubsubkeys.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/model_webpubsubnetworkacls.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/model_webpubsubproperties.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/model_webpubsubresource.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/model_webpubsubsocketiosettings.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/model_webpubsubtlssettings.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/predicates.go create mode 100644 resource-manager/webpubsub/2024-03-01/webpubsub/version.go diff --git a/resource-manager/signalr/2024-03-01/client.go b/resource-manager/signalr/2024-03-01/client.go new file mode 100644 index 00000000000..cf17fdde690 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/client.go @@ -0,0 +1,28 @@ +package v2024_03_01 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/resource-manager/signalr/2024-03-01/signalr" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + SignalR *signalr.SignalRClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + signalRClient, err := signalr.NewSignalRClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building SignalR client: %+v", err) + } + configureFunc(signalRClient.Client) + + return &Client{ + SignalR: signalRClient, + }, nil +} diff --git a/resource-manager/signalr/2024-03-01/signalr/README.md b/resource-manager/signalr/2024-03-01/signalr/README.md new file mode 100644 index 00000000000..7e3fa979011 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/README.md @@ -0,0 +1,652 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/signalr/2024-03-01/signalr` Documentation + +The `signalr` SDK allows for interaction with the Azure Resource Manager Service `signalr` (API Version `2024-03-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/signalr/2024-03-01/signalr" +``` + + +### Client Initialization + +```go +client := signalr.NewSignalRClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SignalRClient.CheckNameAvailability` + +```go +ctx := context.TODO() +id := signalr.NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + +payload := signalr.NameAvailabilityParameters{ + // ... +} + + +read, err := client.CheckNameAvailability(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SignalRClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := signalr.NewSignalRID("12345678-1234-9876-4563-123456789012", "example-resource-group", "signalRValue") + +payload := signalr.SignalRResource{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SignalRClient.CustomCertificatesCreateOrUpdate` + +```go +ctx := context.TODO() +id := signalr.NewCustomCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "signalRValue", "customCertificateValue") + +payload := signalr.CustomCertificate{ + // ... +} + + +if err := client.CustomCertificatesCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SignalRClient.CustomCertificatesDelete` + +```go +ctx := context.TODO() +id := signalr.NewCustomCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "signalRValue", "customCertificateValue") + +read, err := client.CustomCertificatesDelete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SignalRClient.CustomCertificatesGet` + +```go +ctx := context.TODO() +id := signalr.NewCustomCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "signalRValue", "customCertificateValue") + +read, err := client.CustomCertificatesGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SignalRClient.CustomCertificatesList` + +```go +ctx := context.TODO() +id := signalr.NewSignalRID("12345678-1234-9876-4563-123456789012", "example-resource-group", "signalRValue") + +// alternatively `client.CustomCertificatesList(ctx, id)` can be used to do batched pagination +items, err := client.CustomCertificatesListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `SignalRClient.CustomDomainsCreateOrUpdate` + +```go +ctx := context.TODO() +id := signalr.NewCustomDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "signalRValue", "customDomainValue") + +payload := signalr.CustomDomain{ + // ... +} + + +if err := client.CustomDomainsCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SignalRClient.CustomDomainsDelete` + +```go +ctx := context.TODO() +id := signalr.NewCustomDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "signalRValue", "customDomainValue") + +if err := client.CustomDomainsDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `SignalRClient.CustomDomainsGet` + +```go +ctx := context.TODO() +id := signalr.NewCustomDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "signalRValue", "customDomainValue") + +read, err := client.CustomDomainsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SignalRClient.CustomDomainsList` + +```go +ctx := context.TODO() +id := signalr.NewSignalRID("12345678-1234-9876-4563-123456789012", "example-resource-group", "signalRValue") + +// alternatively `client.CustomDomainsList(ctx, id)` can be used to do batched pagination +items, err := client.CustomDomainsListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `SignalRClient.Delete` + +```go +ctx := context.TODO() +id := signalr.NewSignalRID("12345678-1234-9876-4563-123456789012", "example-resource-group", "signalRValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `SignalRClient.Get` + +```go +ctx := context.TODO() +id := signalr.NewSignalRID("12345678-1234-9876-4563-123456789012", "example-resource-group", "signalRValue") + +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: `SignalRClient.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: `SignalRClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `SignalRClient.ListKeys` + +```go +ctx := context.TODO() +id := signalr.NewSignalRID("12345678-1234-9876-4563-123456789012", "example-resource-group", "signalRValue") + +read, err := client.ListKeys(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SignalRClient.ListReplicaSkus` + +```go +ctx := context.TODO() +id := signalr.NewReplicaID("12345678-1234-9876-4563-123456789012", "example-resource-group", "signalRValue", "replicaValue") + +// alternatively `client.ListReplicaSkus(ctx, id)` can be used to do batched pagination +items, err := client.ListReplicaSkusComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `SignalRClient.ListSkus` + +```go +ctx := context.TODO() +id := signalr.NewSignalRID("12345678-1234-9876-4563-123456789012", "example-resource-group", "signalRValue") + +// alternatively `client.ListSkus(ctx, id)` can be used to do batched pagination +items, err := client.ListSkusComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `SignalRClient.PrivateEndpointConnectionsDelete` + +```go +ctx := context.TODO() +id := signalr.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "signalRValue", "privateEndpointConnectionValue") + +if err := client.PrivateEndpointConnectionsDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `SignalRClient.PrivateEndpointConnectionsGet` + +```go +ctx := context.TODO() +id := signalr.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "signalRValue", "privateEndpointConnectionValue") + +read, err := client.PrivateEndpointConnectionsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SignalRClient.PrivateEndpointConnectionsList` + +```go +ctx := context.TODO() +id := signalr.NewSignalRID("12345678-1234-9876-4563-123456789012", "example-resource-group", "signalRValue") + +// alternatively `client.PrivateEndpointConnectionsList(ctx, id)` can be used to do batched pagination +items, err := client.PrivateEndpointConnectionsListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `SignalRClient.PrivateEndpointConnectionsUpdate` + +```go +ctx := context.TODO() +id := signalr.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "signalRValue", "privateEndpointConnectionValue") + +payload := signalr.PrivateEndpointConnection{ + // ... +} + + +read, err := client.PrivateEndpointConnectionsUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SignalRClient.PrivateLinkResourcesList` + +```go +ctx := context.TODO() +id := signalr.NewSignalRID("12345678-1234-9876-4563-123456789012", "example-resource-group", "signalRValue") + +// alternatively `client.PrivateLinkResourcesList(ctx, id)` can be used to do batched pagination +items, err := client.PrivateLinkResourcesListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `SignalRClient.RegenerateKey` + +```go +ctx := context.TODO() +id := signalr.NewSignalRID("12345678-1234-9876-4563-123456789012", "example-resource-group", "signalRValue") + +payload := signalr.RegenerateKeyParameters{ + // ... +} + + +if err := client.RegenerateKeyThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SignalRClient.ReplicaSharedPrivateLinkResourcesCreateOrUpdate` + +```go +ctx := context.TODO() +id := signalr.NewReplicaSharedPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "signalRValue", "replicaValue", "sharedPrivateLinkResourceValue") + +payload := signalr.SharedPrivateLinkResource{ + // ... +} + + +if err := client.ReplicaSharedPrivateLinkResourcesCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SignalRClient.ReplicaSharedPrivateLinkResourcesGet` + +```go +ctx := context.TODO() +id := signalr.NewReplicaSharedPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "signalRValue", "replicaValue", "sharedPrivateLinkResourceValue") + +read, err := client.ReplicaSharedPrivateLinkResourcesGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SignalRClient.ReplicaSharedPrivateLinkResourcesList` + +```go +ctx := context.TODO() +id := signalr.NewReplicaID("12345678-1234-9876-4563-123456789012", "example-resource-group", "signalRValue", "replicaValue") + +// alternatively `client.ReplicaSharedPrivateLinkResourcesList(ctx, id)` can be used to do batched pagination +items, err := client.ReplicaSharedPrivateLinkResourcesListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `SignalRClient.ReplicasCreateOrUpdate` + +```go +ctx := context.TODO() +id := signalr.NewReplicaID("12345678-1234-9876-4563-123456789012", "example-resource-group", "signalRValue", "replicaValue") + +payload := signalr.Replica{ + // ... +} + + +if err := client.ReplicasCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SignalRClient.ReplicasDelete` + +```go +ctx := context.TODO() +id := signalr.NewReplicaID("12345678-1234-9876-4563-123456789012", "example-resource-group", "signalRValue", "replicaValue") + +read, err := client.ReplicasDelete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SignalRClient.ReplicasGet` + +```go +ctx := context.TODO() +id := signalr.NewReplicaID("12345678-1234-9876-4563-123456789012", "example-resource-group", "signalRValue", "replicaValue") + +read, err := client.ReplicasGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SignalRClient.ReplicasList` + +```go +ctx := context.TODO() +id := signalr.NewSignalRID("12345678-1234-9876-4563-123456789012", "example-resource-group", "signalRValue") + +// alternatively `client.ReplicasList(ctx, id)` can be used to do batched pagination +items, err := client.ReplicasListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `SignalRClient.ReplicasRestart` + +```go +ctx := context.TODO() +id := signalr.NewReplicaID("12345678-1234-9876-4563-123456789012", "example-resource-group", "signalRValue", "replicaValue") + +if err := client.ReplicasRestartThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `SignalRClient.ReplicasUpdate` + +```go +ctx := context.TODO() +id := signalr.NewReplicaID("12345678-1234-9876-4563-123456789012", "example-resource-group", "signalRValue", "replicaValue") + +payload := signalr.Replica{ + // ... +} + + +if err := client.ReplicasUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SignalRClient.Restart` + +```go +ctx := context.TODO() +id := signalr.NewSignalRID("12345678-1234-9876-4563-123456789012", "example-resource-group", "signalRValue") + +if err := client.RestartThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `SignalRClient.SharedPrivateLinkResourcesCreateOrUpdate` + +```go +ctx := context.TODO() +id := signalr.NewSharedPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "signalRValue", "sharedPrivateLinkResourceValue") + +payload := signalr.SharedPrivateLinkResource{ + // ... +} + + +if err := client.SharedPrivateLinkResourcesCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SignalRClient.SharedPrivateLinkResourcesDelete` + +```go +ctx := context.TODO() +id := signalr.NewSharedPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "signalRValue", "sharedPrivateLinkResourceValue") + +if err := client.SharedPrivateLinkResourcesDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `SignalRClient.SharedPrivateLinkResourcesGet` + +```go +ctx := context.TODO() +id := signalr.NewSharedPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "signalRValue", "sharedPrivateLinkResourceValue") + +read, err := client.SharedPrivateLinkResourcesGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SignalRClient.SharedPrivateLinkResourcesList` + +```go +ctx := context.TODO() +id := signalr.NewSignalRID("12345678-1234-9876-4563-123456789012", "example-resource-group", "signalRValue") + +// alternatively `client.SharedPrivateLinkResourcesList(ctx, id)` can be used to do batched pagination +items, err := client.SharedPrivateLinkResourcesListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `SignalRClient.Update` + +```go +ctx := context.TODO() +id := signalr.NewSignalRID("12345678-1234-9876-4563-123456789012", "example-resource-group", "signalRValue") + +payload := signalr.SignalRResource{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SignalRClient.UsagesList` + +```go +ctx := context.TODO() +id := signalr.NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + +// alternatively `client.UsagesList(ctx, id)` can be used to do batched pagination +items, err := client.UsagesListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/signalr/2024-03-01/signalr/client.go b/resource-manager/signalr/2024-03-01/signalr/client.go new file mode 100644 index 00000000000..1ffbc8a319b --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/client.go @@ -0,0 +1,26 @@ +package signalr + +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 SignalRClient struct { + Client *resourcemanager.Client +} + +func NewSignalRClientWithBaseURI(sdkApi sdkEnv.Api) (*SignalRClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "signalr", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SignalRClient: %+v", err) + } + + return &SignalRClient{ + Client: client, + }, nil +} diff --git a/resource-manager/signalr/2024-03-01/signalr/constants.go b/resource-manager/signalr/2024-03-01/signalr/constants.go new file mode 100644 index 00000000000..dd10cd6ab27 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/constants.go @@ -0,0 +1,521 @@ +package signalr + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ACLAction string + +const ( + ACLActionAllow ACLAction = "Allow" + ACLActionDeny ACLAction = "Deny" +) + +func PossibleValuesForACLAction() []string { + return []string{ + string(ACLActionAllow), + string(ACLActionDeny), + } +} + +func (s *ACLAction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseACLAction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseACLAction(input string) (*ACLAction, error) { + vals := map[string]ACLAction{ + "allow": ACLActionAllow, + "deny": ACLActionDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ACLAction(input) + return &out, nil +} + +type FeatureFlags string + +const ( + FeatureFlagsEnableConnectivityLogs FeatureFlags = "EnableConnectivityLogs" + FeatureFlagsEnableLiveTrace FeatureFlags = "EnableLiveTrace" + FeatureFlagsEnableMessagingLogs FeatureFlags = "EnableMessagingLogs" + FeatureFlagsServiceMode FeatureFlags = "ServiceMode" +) + +func PossibleValuesForFeatureFlags() []string { + return []string{ + string(FeatureFlagsEnableConnectivityLogs), + string(FeatureFlagsEnableLiveTrace), + string(FeatureFlagsEnableMessagingLogs), + string(FeatureFlagsServiceMode), + } +} + +func (s *FeatureFlags) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFeatureFlags(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFeatureFlags(input string) (*FeatureFlags, error) { + vals := map[string]FeatureFlags{ + "enableconnectivitylogs": FeatureFlagsEnableConnectivityLogs, + "enablelivetrace": FeatureFlagsEnableLiveTrace, + "enablemessaginglogs": FeatureFlagsEnableMessagingLogs, + "servicemode": FeatureFlagsServiceMode, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FeatureFlags(input) + return &out, nil +} + +type KeyType string + +const ( + KeyTypePrimary KeyType = "Primary" + KeyTypeSalt KeyType = "Salt" + KeyTypeSecondary KeyType = "Secondary" +) + +func PossibleValuesForKeyType() []string { + return []string{ + string(KeyTypePrimary), + string(KeyTypeSalt), + string(KeyTypeSecondary), + } +} + +func (s *KeyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKeyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKeyType(input string) (*KeyType, error) { + vals := map[string]KeyType{ + "primary": KeyTypePrimary, + "salt": KeyTypeSalt, + "secondary": KeyTypeSecondary, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KeyType(input) + return &out, nil +} + +type 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 ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateMoving ProvisioningState = "Moving" + ProvisioningStateRunning ProvisioningState = "Running" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUnknown ProvisioningState = "Unknown" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateCreating), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateMoving), + string(ProvisioningStateRunning), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUnknown), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "creating": ProvisioningStateCreating, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "moving": ProvisioningStateMoving, + "running": ProvisioningStateRunning, + "succeeded": ProvisioningStateSucceeded, + "unknown": ProvisioningStateUnknown, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type ScaleType string + +const ( + ScaleTypeAutomatic ScaleType = "Automatic" + ScaleTypeManual ScaleType = "Manual" + ScaleTypeNone ScaleType = "None" +) + +func PossibleValuesForScaleType() []string { + return []string{ + string(ScaleTypeAutomatic), + string(ScaleTypeManual), + string(ScaleTypeNone), + } +} + +func (s *ScaleType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScaleType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScaleType(input string) (*ScaleType, error) { + vals := map[string]ScaleType{ + "automatic": ScaleTypeAutomatic, + "manual": ScaleTypeManual, + "none": ScaleTypeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScaleType(input) + return &out, nil +} + +type ServiceKind string + +const ( + ServiceKindRawWebSockets ServiceKind = "RawWebSockets" + ServiceKindSignalR ServiceKind = "SignalR" +) + +func PossibleValuesForServiceKind() []string { + return []string{ + string(ServiceKindRawWebSockets), + string(ServiceKindSignalR), + } +} + +func (s *ServiceKind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServiceKind(input string) (*ServiceKind, error) { + vals := map[string]ServiceKind{ + "rawwebsockets": ServiceKindRawWebSockets, + "signalr": ServiceKindSignalR, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServiceKind(input) + return &out, nil +} + +type SharedPrivateLinkResourceStatus string + +const ( + SharedPrivateLinkResourceStatusApproved SharedPrivateLinkResourceStatus = "Approved" + SharedPrivateLinkResourceStatusDisconnected SharedPrivateLinkResourceStatus = "Disconnected" + SharedPrivateLinkResourceStatusPending SharedPrivateLinkResourceStatus = "Pending" + SharedPrivateLinkResourceStatusRejected SharedPrivateLinkResourceStatus = "Rejected" + SharedPrivateLinkResourceStatusTimeout SharedPrivateLinkResourceStatus = "Timeout" +) + +func PossibleValuesForSharedPrivateLinkResourceStatus() []string { + return []string{ + string(SharedPrivateLinkResourceStatusApproved), + string(SharedPrivateLinkResourceStatusDisconnected), + string(SharedPrivateLinkResourceStatusPending), + string(SharedPrivateLinkResourceStatusRejected), + string(SharedPrivateLinkResourceStatusTimeout), + } +} + +func (s *SharedPrivateLinkResourceStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSharedPrivateLinkResourceStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSharedPrivateLinkResourceStatus(input string) (*SharedPrivateLinkResourceStatus, error) { + vals := map[string]SharedPrivateLinkResourceStatus{ + "approved": SharedPrivateLinkResourceStatusApproved, + "disconnected": SharedPrivateLinkResourceStatusDisconnected, + "pending": SharedPrivateLinkResourceStatusPending, + "rejected": SharedPrivateLinkResourceStatusRejected, + "timeout": SharedPrivateLinkResourceStatusTimeout, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SharedPrivateLinkResourceStatus(input) + return &out, nil +} + +type SignalRRequestType string + +const ( + SignalRRequestTypeClientConnection SignalRRequestType = "ClientConnection" + SignalRRequestTypeRESTAPI SignalRRequestType = "RESTAPI" + SignalRRequestTypeServerConnection SignalRRequestType = "ServerConnection" + SignalRRequestTypeTrace SignalRRequestType = "Trace" +) + +func PossibleValuesForSignalRRequestType() []string { + return []string{ + string(SignalRRequestTypeClientConnection), + string(SignalRRequestTypeRESTAPI), + string(SignalRRequestTypeServerConnection), + string(SignalRRequestTypeTrace), + } +} + +func (s *SignalRRequestType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSignalRRequestType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSignalRRequestType(input string) (*SignalRRequestType, error) { + vals := map[string]SignalRRequestType{ + "clientconnection": SignalRRequestTypeClientConnection, + "restapi": SignalRRequestTypeRESTAPI, + "serverconnection": SignalRRequestTypeServerConnection, + "trace": SignalRRequestTypeTrace, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SignalRRequestType(input) + return &out, nil +} + +type SignalRSkuTier string + +const ( + SignalRSkuTierBasic SignalRSkuTier = "Basic" + SignalRSkuTierFree SignalRSkuTier = "Free" + SignalRSkuTierPremium SignalRSkuTier = "Premium" + SignalRSkuTierStandard SignalRSkuTier = "Standard" +) + +func PossibleValuesForSignalRSkuTier() []string { + return []string{ + string(SignalRSkuTierBasic), + string(SignalRSkuTierFree), + string(SignalRSkuTierPremium), + string(SignalRSkuTierStandard), + } +} + +func (s *SignalRSkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSignalRSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSignalRSkuTier(input string) (*SignalRSkuTier, error) { + vals := map[string]SignalRSkuTier{ + "basic": SignalRSkuTierBasic, + "free": SignalRSkuTierFree, + "premium": SignalRSkuTierPremium, + "standard": SignalRSkuTierStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SignalRSkuTier(input) + return &out, nil +} + +type UpstreamAuthType string + +const ( + UpstreamAuthTypeManagedIdentity UpstreamAuthType = "ManagedIdentity" + UpstreamAuthTypeNone UpstreamAuthType = "None" +) + +func PossibleValuesForUpstreamAuthType() []string { + return []string{ + string(UpstreamAuthTypeManagedIdentity), + string(UpstreamAuthTypeNone), + } +} + +func (s *UpstreamAuthType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUpstreamAuthType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUpstreamAuthType(input string) (*UpstreamAuthType, error) { + vals := map[string]UpstreamAuthType{ + "managedidentity": UpstreamAuthTypeManagedIdentity, + "none": UpstreamAuthTypeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UpstreamAuthType(input) + return &out, nil +} diff --git a/resource-manager/signalr/2024-03-01/signalr/id_customcertificate.go b/resource-manager/signalr/2024-03-01/signalr/id_customcertificate.go new file mode 100644 index 00000000000..82841ff421f --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/id_customcertificate.go @@ -0,0 +1,139 @@ +package signalr + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&CustomCertificateId{}) +} + +var _ resourceids.ResourceId = &CustomCertificateId{} + +// CustomCertificateId is a struct representing the Resource ID for a Custom Certificate +type CustomCertificateId struct { + SubscriptionId string + ResourceGroupName string + SignalRName string + CustomCertificateName string +} + +// NewCustomCertificateID returns a new CustomCertificateId struct +func NewCustomCertificateID(subscriptionId string, resourceGroupName string, signalRName string, customCertificateName string) CustomCertificateId { + return CustomCertificateId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SignalRName: signalRName, + CustomCertificateName: customCertificateName, + } +} + +// ParseCustomCertificateID parses 'input' into a CustomCertificateId +func ParseCustomCertificateID(input string) (*CustomCertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&CustomCertificateId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CustomCertificateId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCustomCertificateIDInsensitively parses 'input' case-insensitively into a CustomCertificateId +// note: this method should only be used for API response data and not user input +func ParseCustomCertificateIDInsensitively(input string) (*CustomCertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&CustomCertificateId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CustomCertificateId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CustomCertificateId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SignalRName, ok = input.Parsed["signalRName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "signalRName", input) + } + + if id.CustomCertificateName, ok = input.Parsed["customCertificateName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "customCertificateName", input) + } + + return nil +} + +// ValidateCustomCertificateID checks that 'input' can be parsed as a Custom Certificate ID +func ValidateCustomCertificateID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseCustomCertificateID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Custom Certificate ID +func (id CustomCertificateId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.SignalRService/signalR/%s/customCertificates/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SignalRName, id.CustomCertificateName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Custom Certificate ID +func (id CustomCertificateId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftSignalRService", "Microsoft.SignalRService", "Microsoft.SignalRService"), + resourceids.StaticSegment("staticSignalR", "signalR", "signalR"), + resourceids.UserSpecifiedSegment("signalRName", "signalRValue"), + resourceids.StaticSegment("staticCustomCertificates", "customCertificates", "customCertificates"), + resourceids.UserSpecifiedSegment("customCertificateName", "customCertificateValue"), + } +} + +// String returns a human-readable description of this Custom Certificate ID +func (id CustomCertificateId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Signal R Name: %q", id.SignalRName), + fmt.Sprintf("Custom Certificate Name: %q", id.CustomCertificateName), + } + return fmt.Sprintf("Custom Certificate (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/signalr/2024-03-01/signalr/id_customcertificate_test.go b/resource-manager/signalr/2024-03-01/signalr/id_customcertificate_test.go new file mode 100644 index 00000000000..beb8e120013 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/id_customcertificate_test.go @@ -0,0 +1,327 @@ +package signalr + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &CustomCertificateId{} + +func TestNewCustomCertificateID(t *testing.T) { + id := NewCustomCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "signalRValue", "customCertificateValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SignalRName != "signalRValue" { + t.Fatalf("Expected %q but got %q for Segment 'SignalRName'", id.SignalRName, "signalRValue") + } + + if id.CustomCertificateName != "customCertificateValue" { + t.Fatalf("Expected %q but got %q for Segment 'CustomCertificateName'", id.CustomCertificateName, "customCertificateValue") + } +} + +func TestFormatCustomCertificateID(t *testing.T) { + actual := NewCustomCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "signalRValue", "customCertificateValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue/customCertificates/customCertificateValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCustomCertificateID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CustomCertificateId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue/customCertificates", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue/customCertificates/customCertificateValue", + Expected: &CustomCertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SignalRName: "signalRValue", + CustomCertificateName: "customCertificateValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue/customCertificates/customCertificateValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCustomCertificateID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SignalRName != v.Expected.SignalRName { + t.Fatalf("Expected %q but got %q for SignalRName", v.Expected.SignalRName, actual.SignalRName) + } + + if actual.CustomCertificateName != v.Expected.CustomCertificateName { + t.Fatalf("Expected %q but got %q for CustomCertificateName", v.Expected.CustomCertificateName, actual.CustomCertificateName) + } + + } +} + +func TestParseCustomCertificateIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CustomCertificateId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/sIgNaLr", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/sIgNaLr/sIgNaLrVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue/customCertificates", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/sIgNaLr/sIgNaLrVaLuE/cUsToMcErTiFiCaTeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue/customCertificates/customCertificateValue", + Expected: &CustomCertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SignalRName: "signalRValue", + CustomCertificateName: "customCertificateValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue/customCertificates/customCertificateValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/sIgNaLr/sIgNaLrVaLuE/cUsToMcErTiFiCaTeS/cUsToMcErTiFiCaTeVaLuE", + Expected: &CustomCertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SignalRName: "sIgNaLrVaLuE", + CustomCertificateName: "cUsToMcErTiFiCaTeVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/sIgNaLr/sIgNaLrVaLuE/cUsToMcErTiFiCaTeS/cUsToMcErTiFiCaTeVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCustomCertificateIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SignalRName != v.Expected.SignalRName { + t.Fatalf("Expected %q but got %q for SignalRName", v.Expected.SignalRName, actual.SignalRName) + } + + if actual.CustomCertificateName != v.Expected.CustomCertificateName { + t.Fatalf("Expected %q but got %q for CustomCertificateName", v.Expected.CustomCertificateName, actual.CustomCertificateName) + } + + } +} + +func TestSegmentsForCustomCertificateId(t *testing.T) { + segments := CustomCertificateId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CustomCertificateId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/signalr/2024-03-01/signalr/id_customdomain.go b/resource-manager/signalr/2024-03-01/signalr/id_customdomain.go new file mode 100644 index 00000000000..a96bdc49a7f --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/id_customdomain.go @@ -0,0 +1,139 @@ +package signalr + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&CustomDomainId{}) +} + +var _ resourceids.ResourceId = &CustomDomainId{} + +// CustomDomainId is a struct representing the Resource ID for a Custom Domain +type CustomDomainId struct { + SubscriptionId string + ResourceGroupName string + SignalRName string + CustomDomainName string +} + +// NewCustomDomainID returns a new CustomDomainId struct +func NewCustomDomainID(subscriptionId string, resourceGroupName string, signalRName string, customDomainName string) CustomDomainId { + return CustomDomainId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SignalRName: signalRName, + CustomDomainName: customDomainName, + } +} + +// ParseCustomDomainID parses 'input' into a CustomDomainId +func ParseCustomDomainID(input string) (*CustomDomainId, error) { + parser := resourceids.NewParserFromResourceIdType(&CustomDomainId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CustomDomainId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCustomDomainIDInsensitively parses 'input' case-insensitively into a CustomDomainId +// note: this method should only be used for API response data and not user input +func ParseCustomDomainIDInsensitively(input string) (*CustomDomainId, error) { + parser := resourceids.NewParserFromResourceIdType(&CustomDomainId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CustomDomainId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CustomDomainId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SignalRName, ok = input.Parsed["signalRName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "signalRName", input) + } + + if id.CustomDomainName, ok = input.Parsed["customDomainName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "customDomainName", input) + } + + return nil +} + +// ValidateCustomDomainID checks that 'input' can be parsed as a Custom Domain ID +func ValidateCustomDomainID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseCustomDomainID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Custom Domain ID +func (id CustomDomainId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.SignalRService/signalR/%s/customDomains/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SignalRName, id.CustomDomainName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Custom Domain ID +func (id CustomDomainId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftSignalRService", "Microsoft.SignalRService", "Microsoft.SignalRService"), + resourceids.StaticSegment("staticSignalR", "signalR", "signalR"), + resourceids.UserSpecifiedSegment("signalRName", "signalRValue"), + resourceids.StaticSegment("staticCustomDomains", "customDomains", "customDomains"), + resourceids.UserSpecifiedSegment("customDomainName", "customDomainValue"), + } +} + +// String returns a human-readable description of this Custom Domain ID +func (id CustomDomainId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Signal R Name: %q", id.SignalRName), + fmt.Sprintf("Custom Domain Name: %q", id.CustomDomainName), + } + return fmt.Sprintf("Custom Domain (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/signalr/2024-03-01/signalr/id_customdomain_test.go b/resource-manager/signalr/2024-03-01/signalr/id_customdomain_test.go new file mode 100644 index 00000000000..2b14ca825d2 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/id_customdomain_test.go @@ -0,0 +1,327 @@ +package signalr + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &CustomDomainId{} + +func TestNewCustomDomainID(t *testing.T) { + id := NewCustomDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "signalRValue", "customDomainValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SignalRName != "signalRValue" { + t.Fatalf("Expected %q but got %q for Segment 'SignalRName'", id.SignalRName, "signalRValue") + } + + if id.CustomDomainName != "customDomainValue" { + t.Fatalf("Expected %q but got %q for Segment 'CustomDomainName'", id.CustomDomainName, "customDomainValue") + } +} + +func TestFormatCustomDomainID(t *testing.T) { + actual := NewCustomDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "signalRValue", "customDomainValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue/customDomains/customDomainValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCustomDomainID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CustomDomainId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue/customDomains", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue/customDomains/customDomainValue", + Expected: &CustomDomainId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SignalRName: "signalRValue", + CustomDomainName: "customDomainValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue/customDomains/customDomainValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCustomDomainID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SignalRName != v.Expected.SignalRName { + t.Fatalf("Expected %q but got %q for SignalRName", v.Expected.SignalRName, actual.SignalRName) + } + + if actual.CustomDomainName != v.Expected.CustomDomainName { + t.Fatalf("Expected %q but got %q for CustomDomainName", v.Expected.CustomDomainName, actual.CustomDomainName) + } + + } +} + +func TestParseCustomDomainIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CustomDomainId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/sIgNaLr", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/sIgNaLr/sIgNaLrVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue/customDomains", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/sIgNaLr/sIgNaLrVaLuE/cUsToMdOmAiNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue/customDomains/customDomainValue", + Expected: &CustomDomainId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SignalRName: "signalRValue", + CustomDomainName: "customDomainValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue/customDomains/customDomainValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/sIgNaLr/sIgNaLrVaLuE/cUsToMdOmAiNs/cUsToMdOmAiNvAlUe", + Expected: &CustomDomainId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SignalRName: "sIgNaLrVaLuE", + CustomDomainName: "cUsToMdOmAiNvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/sIgNaLr/sIgNaLrVaLuE/cUsToMdOmAiNs/cUsToMdOmAiNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCustomDomainIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SignalRName != v.Expected.SignalRName { + t.Fatalf("Expected %q but got %q for SignalRName", v.Expected.SignalRName, actual.SignalRName) + } + + if actual.CustomDomainName != v.Expected.CustomDomainName { + t.Fatalf("Expected %q but got %q for CustomDomainName", v.Expected.CustomDomainName, actual.CustomDomainName) + } + + } +} + +func TestSegmentsForCustomDomainId(t *testing.T) { + segments := CustomDomainId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CustomDomainId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/signalr/2024-03-01/signalr/id_location.go b/resource-manager/signalr/2024-03-01/signalr/id_location.go new file mode 100644 index 00000000000..03b35c694c8 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/id_location.go @@ -0,0 +1,121 @@ +package signalr + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&LocationId{}) +} + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + SubscriptionId string + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(subscriptionId string, locationName string) LocationId { + return LocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.SignalRService/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("staticMicrosoftSignalRService", "Microsoft.SignalRService", "Microsoft.SignalRService"), + 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/signalr/2024-03-01/signalr/id_location_test.go b/resource-manager/signalr/2024-03-01/signalr/id_location_test.go new file mode 100644 index 00000000000..c033f45fe0e --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/id_location_test.go @@ -0,0 +1,237 @@ +package signalr + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (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.SignalRService/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.SignalRService", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.SignalRService/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.SignalRService/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.SignalRService/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.SignalRService", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.SignalRService/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.SignalRService/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.SignalRService/locations/locationValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/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.sIgNaLrSeRvIcE/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/signalr/2024-03-01/signalr/id_privateendpointconnection.go b/resource-manager/signalr/2024-03-01/signalr/id_privateendpointconnection.go new file mode 100644 index 00000000000..3ae4e64f3d3 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/id_privateendpointconnection.go @@ -0,0 +1,139 @@ +package signalr + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PrivateEndpointConnectionId{}) +} + +var _ resourceids.ResourceId = &PrivateEndpointConnectionId{} + +// PrivateEndpointConnectionId is a struct representing the Resource ID for a Private Endpoint Connection +type PrivateEndpointConnectionId struct { + SubscriptionId string + ResourceGroupName string + SignalRName string + PrivateEndpointConnectionName string +} + +// NewPrivateEndpointConnectionID returns a new PrivateEndpointConnectionId struct +func NewPrivateEndpointConnectionID(subscriptionId string, resourceGroupName string, signalRName string, privateEndpointConnectionName string) PrivateEndpointConnectionId { + return PrivateEndpointConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SignalRName: signalRName, + 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.SignalRName, ok = input.Parsed["signalRName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "signalRName", 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.SignalRService/signalR/%s/privateEndpointConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SignalRName, 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("staticMicrosoftSignalRService", "Microsoft.SignalRService", "Microsoft.SignalRService"), + resourceids.StaticSegment("staticSignalR", "signalR", "signalR"), + resourceids.UserSpecifiedSegment("signalRName", "signalRValue"), + 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("Signal R Name: %q", id.SignalRName), + 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/signalr/2024-03-01/signalr/id_privateendpointconnection_test.go b/resource-manager/signalr/2024-03-01/signalr/id_privateendpointconnection_test.go new file mode 100644 index 00000000000..80212dcb799 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/id_privateendpointconnection_test.go @@ -0,0 +1,327 @@ +package signalr + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (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", "signalRValue", "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.SignalRName != "signalRValue" { + t.Fatalf("Expected %q but got %q for Segment 'SignalRName'", id.SignalRName, "signalRValue") + } + + 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", "signalRValue", "privateEndpointConnectionValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue/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.SignalRService", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue/privateEndpointConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue/privateEndpointConnections/privateEndpointConnectionValue", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SignalRName: "signalRValue", + PrivateEndpointConnectionName: "privateEndpointConnectionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue/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.SignalRName != v.Expected.SignalRName { + t.Fatalf("Expected %q but got %q for SignalRName", v.Expected.SignalRName, actual.SignalRName) + } + + 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.SignalRService", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/sIgNaLr", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/sIgNaLr/sIgNaLrVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue/privateEndpointConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/sIgNaLr/sIgNaLrVaLuE/pRiVaTeEnDpOiNtCoNnEcTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue/privateEndpointConnections/privateEndpointConnectionValue", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SignalRName: "signalRValue", + PrivateEndpointConnectionName: "privateEndpointConnectionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue/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.sIgNaLrSeRvIcE/sIgNaLr/sIgNaLrVaLuE/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SignalRName: "sIgNaLrVaLuE", + 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.sIgNaLrSeRvIcE/sIgNaLr/sIgNaLrVaLuE/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.SignalRName != v.Expected.SignalRName { + t.Fatalf("Expected %q but got %q for SignalRName", v.Expected.SignalRName, actual.SignalRName) + } + + 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/signalr/2024-03-01/signalr/id_replica.go b/resource-manager/signalr/2024-03-01/signalr/id_replica.go new file mode 100644 index 00000000000..6063260a202 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/id_replica.go @@ -0,0 +1,139 @@ +package signalr + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ReplicaId{}) +} + +var _ resourceids.ResourceId = &ReplicaId{} + +// ReplicaId is a struct representing the Resource ID for a Replica +type ReplicaId struct { + SubscriptionId string + ResourceGroupName string + SignalRName string + ReplicaName string +} + +// NewReplicaID returns a new ReplicaId struct +func NewReplicaID(subscriptionId string, resourceGroupName string, signalRName string, replicaName string) ReplicaId { + return ReplicaId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SignalRName: signalRName, + ReplicaName: replicaName, + } +} + +// ParseReplicaID parses 'input' into a ReplicaId +func ParseReplicaID(input string) (*ReplicaId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicaId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicaId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicaIDInsensitively parses 'input' case-insensitively into a ReplicaId +// note: this method should only be used for API response data and not user input +func ParseReplicaIDInsensitively(input string) (*ReplicaId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicaId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicaId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicaId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SignalRName, ok = input.Parsed["signalRName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "signalRName", input) + } + + if id.ReplicaName, ok = input.Parsed["replicaName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicaName", input) + } + + return nil +} + +// ValidateReplicaID checks that 'input' can be parsed as a Replica ID +func ValidateReplicaID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseReplicaID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replica ID +func (id ReplicaId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.SignalRService/signalR/%s/replicas/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SignalRName, id.ReplicaName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replica ID +func (id ReplicaId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftSignalRService", "Microsoft.SignalRService", "Microsoft.SignalRService"), + resourceids.StaticSegment("staticSignalR", "signalR", "signalR"), + resourceids.UserSpecifiedSegment("signalRName", "signalRValue"), + resourceids.StaticSegment("staticReplicas", "replicas", "replicas"), + resourceids.UserSpecifiedSegment("replicaName", "replicaValue"), + } +} + +// String returns a human-readable description of this Replica ID +func (id ReplicaId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Signal R Name: %q", id.SignalRName), + fmt.Sprintf("Replica Name: %q", id.ReplicaName), + } + return fmt.Sprintf("Replica (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/signalr/2024-03-01/signalr/id_replica_test.go b/resource-manager/signalr/2024-03-01/signalr/id_replica_test.go new file mode 100644 index 00000000000..e2fffc1f657 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/id_replica_test.go @@ -0,0 +1,327 @@ +package signalr + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ReplicaId{} + +func TestNewReplicaID(t *testing.T) { + id := NewReplicaID("12345678-1234-9876-4563-123456789012", "example-resource-group", "signalRValue", "replicaValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SignalRName != "signalRValue" { + t.Fatalf("Expected %q but got %q for Segment 'SignalRName'", id.SignalRName, "signalRValue") + } + + if id.ReplicaName != "replicaValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicaName'", id.ReplicaName, "replicaValue") + } +} + +func TestFormatReplicaID(t *testing.T) { + actual := NewReplicaID("12345678-1234-9876-4563-123456789012", "example-resource-group", "signalRValue", "replicaValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue/replicas/replicaValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicaID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicaId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue/replicas", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue/replicas/replicaValue", + Expected: &ReplicaId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SignalRName: "signalRValue", + ReplicaName: "replicaValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue/replicas/replicaValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicaID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SignalRName != v.Expected.SignalRName { + t.Fatalf("Expected %q but got %q for SignalRName", v.Expected.SignalRName, actual.SignalRName) + } + + if actual.ReplicaName != v.Expected.ReplicaName { + t.Fatalf("Expected %q but got %q for ReplicaName", v.Expected.ReplicaName, actual.ReplicaName) + } + + } +} + +func TestParseReplicaIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicaId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/sIgNaLr", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/sIgNaLr/sIgNaLrVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue/replicas", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/sIgNaLr/sIgNaLrVaLuE/rEpLiCaS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue/replicas/replicaValue", + Expected: &ReplicaId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SignalRName: "signalRValue", + ReplicaName: "replicaValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue/replicas/replicaValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/sIgNaLr/sIgNaLrVaLuE/rEpLiCaS/rEpLiCaVaLuE", + Expected: &ReplicaId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SignalRName: "sIgNaLrVaLuE", + ReplicaName: "rEpLiCaVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/sIgNaLr/sIgNaLrVaLuE/rEpLiCaS/rEpLiCaVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicaIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SignalRName != v.Expected.SignalRName { + t.Fatalf("Expected %q but got %q for SignalRName", v.Expected.SignalRName, actual.SignalRName) + } + + if actual.ReplicaName != v.Expected.ReplicaName { + t.Fatalf("Expected %q but got %q for ReplicaName", v.Expected.ReplicaName, actual.ReplicaName) + } + + } +} + +func TestSegmentsForReplicaId(t *testing.T) { + segments := ReplicaId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicaId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/signalr/2024-03-01/signalr/id_replicasharedprivatelinkresource.go b/resource-manager/signalr/2024-03-01/signalr/id_replicasharedprivatelinkresource.go new file mode 100644 index 00000000000..d00fd80f162 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/id_replicasharedprivatelinkresource.go @@ -0,0 +1,148 @@ +package signalr + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ReplicaSharedPrivateLinkResourceId{}) +} + +var _ resourceids.ResourceId = &ReplicaSharedPrivateLinkResourceId{} + +// ReplicaSharedPrivateLinkResourceId is a struct representing the Resource ID for a Replica Shared Private Link Resource +type ReplicaSharedPrivateLinkResourceId struct { + SubscriptionId string + ResourceGroupName string + SignalRName string + ReplicaName string + SharedPrivateLinkResourceName string +} + +// NewReplicaSharedPrivateLinkResourceID returns a new ReplicaSharedPrivateLinkResourceId struct +func NewReplicaSharedPrivateLinkResourceID(subscriptionId string, resourceGroupName string, signalRName string, replicaName string, sharedPrivateLinkResourceName string) ReplicaSharedPrivateLinkResourceId { + return ReplicaSharedPrivateLinkResourceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SignalRName: signalRName, + ReplicaName: replicaName, + SharedPrivateLinkResourceName: sharedPrivateLinkResourceName, + } +} + +// ParseReplicaSharedPrivateLinkResourceID parses 'input' into a ReplicaSharedPrivateLinkResourceId +func ParseReplicaSharedPrivateLinkResourceID(input string) (*ReplicaSharedPrivateLinkResourceId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicaSharedPrivateLinkResourceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicaSharedPrivateLinkResourceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicaSharedPrivateLinkResourceIDInsensitively parses 'input' case-insensitively into a ReplicaSharedPrivateLinkResourceId +// note: this method should only be used for API response data and not user input +func ParseReplicaSharedPrivateLinkResourceIDInsensitively(input string) (*ReplicaSharedPrivateLinkResourceId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicaSharedPrivateLinkResourceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicaSharedPrivateLinkResourceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicaSharedPrivateLinkResourceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SignalRName, ok = input.Parsed["signalRName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "signalRName", input) + } + + if id.ReplicaName, ok = input.Parsed["replicaName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicaName", input) + } + + if id.SharedPrivateLinkResourceName, ok = input.Parsed["sharedPrivateLinkResourceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "sharedPrivateLinkResourceName", input) + } + + return nil +} + +// ValidateReplicaSharedPrivateLinkResourceID checks that 'input' can be parsed as a Replica Shared Private Link Resource ID +func ValidateReplicaSharedPrivateLinkResourceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseReplicaSharedPrivateLinkResourceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replica Shared Private Link Resource ID +func (id ReplicaSharedPrivateLinkResourceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.SignalRService/signalR/%s/replicas/%s/sharedPrivateLinkResources/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SignalRName, id.ReplicaName, id.SharedPrivateLinkResourceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replica Shared Private Link Resource ID +func (id ReplicaSharedPrivateLinkResourceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftSignalRService", "Microsoft.SignalRService", "Microsoft.SignalRService"), + resourceids.StaticSegment("staticSignalR", "signalR", "signalR"), + resourceids.UserSpecifiedSegment("signalRName", "signalRValue"), + resourceids.StaticSegment("staticReplicas", "replicas", "replicas"), + resourceids.UserSpecifiedSegment("replicaName", "replicaValue"), + resourceids.StaticSegment("staticSharedPrivateLinkResources", "sharedPrivateLinkResources", "sharedPrivateLinkResources"), + resourceids.UserSpecifiedSegment("sharedPrivateLinkResourceName", "sharedPrivateLinkResourceValue"), + } +} + +// String returns a human-readable description of this Replica Shared Private Link Resource ID +func (id ReplicaSharedPrivateLinkResourceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Signal R Name: %q", id.SignalRName), + fmt.Sprintf("Replica Name: %q", id.ReplicaName), + fmt.Sprintf("Shared Private Link Resource Name: %q", id.SharedPrivateLinkResourceName), + } + return fmt.Sprintf("Replica Shared Private Link Resource (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/signalr/2024-03-01/signalr/id_replicasharedprivatelinkresource_test.go b/resource-manager/signalr/2024-03-01/signalr/id_replicasharedprivatelinkresource_test.go new file mode 100644 index 00000000000..4fa6e000273 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/id_replicasharedprivatelinkresource_test.go @@ -0,0 +1,372 @@ +package signalr + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ReplicaSharedPrivateLinkResourceId{} + +func TestNewReplicaSharedPrivateLinkResourceID(t *testing.T) { + id := NewReplicaSharedPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "signalRValue", "replicaValue", "sharedPrivateLinkResourceValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SignalRName != "signalRValue" { + t.Fatalf("Expected %q but got %q for Segment 'SignalRName'", id.SignalRName, "signalRValue") + } + + if id.ReplicaName != "replicaValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicaName'", id.ReplicaName, "replicaValue") + } + + if id.SharedPrivateLinkResourceName != "sharedPrivateLinkResourceValue" { + t.Fatalf("Expected %q but got %q for Segment 'SharedPrivateLinkResourceName'", id.SharedPrivateLinkResourceName, "sharedPrivateLinkResourceValue") + } +} + +func TestFormatReplicaSharedPrivateLinkResourceID(t *testing.T) { + actual := NewReplicaSharedPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "signalRValue", "replicaValue", "sharedPrivateLinkResourceValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue/replicas/replicaValue/sharedPrivateLinkResources/sharedPrivateLinkResourceValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicaSharedPrivateLinkResourceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicaSharedPrivateLinkResourceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue/replicas", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue/replicas/replicaValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue/replicas/replicaValue/sharedPrivateLinkResources", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue/replicas/replicaValue/sharedPrivateLinkResources/sharedPrivateLinkResourceValue", + Expected: &ReplicaSharedPrivateLinkResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SignalRName: "signalRValue", + ReplicaName: "replicaValue", + SharedPrivateLinkResourceName: "sharedPrivateLinkResourceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue/replicas/replicaValue/sharedPrivateLinkResources/sharedPrivateLinkResourceValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicaSharedPrivateLinkResourceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SignalRName != v.Expected.SignalRName { + t.Fatalf("Expected %q but got %q for SignalRName", v.Expected.SignalRName, actual.SignalRName) + } + + if actual.ReplicaName != v.Expected.ReplicaName { + t.Fatalf("Expected %q but got %q for ReplicaName", v.Expected.ReplicaName, actual.ReplicaName) + } + + if actual.SharedPrivateLinkResourceName != v.Expected.SharedPrivateLinkResourceName { + t.Fatalf("Expected %q but got %q for SharedPrivateLinkResourceName", v.Expected.SharedPrivateLinkResourceName, actual.SharedPrivateLinkResourceName) + } + + } +} + +func TestParseReplicaSharedPrivateLinkResourceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicaSharedPrivateLinkResourceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/sIgNaLr", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/sIgNaLr/sIgNaLrVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue/replicas", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/sIgNaLr/sIgNaLrVaLuE/rEpLiCaS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue/replicas/replicaValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/sIgNaLr/sIgNaLrVaLuE/rEpLiCaS/rEpLiCaVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue/replicas/replicaValue/sharedPrivateLinkResources", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/sIgNaLr/sIgNaLrVaLuE/rEpLiCaS/rEpLiCaVaLuE/sHaReDpRiVaTeLiNkReSoUrCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue/replicas/replicaValue/sharedPrivateLinkResources/sharedPrivateLinkResourceValue", + Expected: &ReplicaSharedPrivateLinkResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SignalRName: "signalRValue", + ReplicaName: "replicaValue", + SharedPrivateLinkResourceName: "sharedPrivateLinkResourceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue/replicas/replicaValue/sharedPrivateLinkResources/sharedPrivateLinkResourceValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/sIgNaLr/sIgNaLrVaLuE/rEpLiCaS/rEpLiCaVaLuE/sHaReDpRiVaTeLiNkReSoUrCeS/sHaReDpRiVaTeLiNkReSoUrCeVaLuE", + Expected: &ReplicaSharedPrivateLinkResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SignalRName: "sIgNaLrVaLuE", + ReplicaName: "rEpLiCaVaLuE", + SharedPrivateLinkResourceName: "sHaReDpRiVaTeLiNkReSoUrCeVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/sIgNaLr/sIgNaLrVaLuE/rEpLiCaS/rEpLiCaVaLuE/sHaReDpRiVaTeLiNkReSoUrCeS/sHaReDpRiVaTeLiNkReSoUrCeVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicaSharedPrivateLinkResourceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SignalRName != v.Expected.SignalRName { + t.Fatalf("Expected %q but got %q for SignalRName", v.Expected.SignalRName, actual.SignalRName) + } + + if actual.ReplicaName != v.Expected.ReplicaName { + t.Fatalf("Expected %q but got %q for ReplicaName", v.Expected.ReplicaName, actual.ReplicaName) + } + + if actual.SharedPrivateLinkResourceName != v.Expected.SharedPrivateLinkResourceName { + t.Fatalf("Expected %q but got %q for SharedPrivateLinkResourceName", v.Expected.SharedPrivateLinkResourceName, actual.SharedPrivateLinkResourceName) + } + + } +} + +func TestSegmentsForReplicaSharedPrivateLinkResourceId(t *testing.T) { + segments := ReplicaSharedPrivateLinkResourceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicaSharedPrivateLinkResourceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/signalr/2024-03-01/signalr/id_sharedprivatelinkresource.go b/resource-manager/signalr/2024-03-01/signalr/id_sharedprivatelinkresource.go new file mode 100644 index 00000000000..6fce0e78e3e --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/id_sharedprivatelinkresource.go @@ -0,0 +1,139 @@ +package signalr + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SharedPrivateLinkResourceId{}) +} + +var _ resourceids.ResourceId = &SharedPrivateLinkResourceId{} + +// SharedPrivateLinkResourceId is a struct representing the Resource ID for a Shared Private Link Resource +type SharedPrivateLinkResourceId struct { + SubscriptionId string + ResourceGroupName string + SignalRName string + SharedPrivateLinkResourceName string +} + +// NewSharedPrivateLinkResourceID returns a new SharedPrivateLinkResourceId struct +func NewSharedPrivateLinkResourceID(subscriptionId string, resourceGroupName string, signalRName string, sharedPrivateLinkResourceName string) SharedPrivateLinkResourceId { + return SharedPrivateLinkResourceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SignalRName: signalRName, + SharedPrivateLinkResourceName: sharedPrivateLinkResourceName, + } +} + +// ParseSharedPrivateLinkResourceID parses 'input' into a SharedPrivateLinkResourceId +func ParseSharedPrivateLinkResourceID(input string) (*SharedPrivateLinkResourceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SharedPrivateLinkResourceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SharedPrivateLinkResourceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSharedPrivateLinkResourceIDInsensitively parses 'input' case-insensitively into a SharedPrivateLinkResourceId +// note: this method should only be used for API response data and not user input +func ParseSharedPrivateLinkResourceIDInsensitively(input string) (*SharedPrivateLinkResourceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SharedPrivateLinkResourceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SharedPrivateLinkResourceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SharedPrivateLinkResourceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SignalRName, ok = input.Parsed["signalRName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "signalRName", input) + } + + if id.SharedPrivateLinkResourceName, ok = input.Parsed["sharedPrivateLinkResourceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "sharedPrivateLinkResourceName", input) + } + + return nil +} + +// ValidateSharedPrivateLinkResourceID checks that 'input' can be parsed as a Shared Private Link Resource ID +func ValidateSharedPrivateLinkResourceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSharedPrivateLinkResourceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Shared Private Link Resource ID +func (id SharedPrivateLinkResourceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.SignalRService/signalR/%s/sharedPrivateLinkResources/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SignalRName, id.SharedPrivateLinkResourceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Shared Private Link Resource ID +func (id SharedPrivateLinkResourceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftSignalRService", "Microsoft.SignalRService", "Microsoft.SignalRService"), + resourceids.StaticSegment("staticSignalR", "signalR", "signalR"), + resourceids.UserSpecifiedSegment("signalRName", "signalRValue"), + resourceids.StaticSegment("staticSharedPrivateLinkResources", "sharedPrivateLinkResources", "sharedPrivateLinkResources"), + resourceids.UserSpecifiedSegment("sharedPrivateLinkResourceName", "sharedPrivateLinkResourceValue"), + } +} + +// String returns a human-readable description of this Shared Private Link Resource ID +func (id SharedPrivateLinkResourceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Signal R Name: %q", id.SignalRName), + fmt.Sprintf("Shared Private Link Resource Name: %q", id.SharedPrivateLinkResourceName), + } + return fmt.Sprintf("Shared Private Link Resource (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/signalr/2024-03-01/signalr/id_sharedprivatelinkresource_test.go b/resource-manager/signalr/2024-03-01/signalr/id_sharedprivatelinkresource_test.go new file mode 100644 index 00000000000..2c1408ef986 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/id_sharedprivatelinkresource_test.go @@ -0,0 +1,327 @@ +package signalr + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SharedPrivateLinkResourceId{} + +func TestNewSharedPrivateLinkResourceID(t *testing.T) { + id := NewSharedPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "signalRValue", "sharedPrivateLinkResourceValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SignalRName != "signalRValue" { + t.Fatalf("Expected %q but got %q for Segment 'SignalRName'", id.SignalRName, "signalRValue") + } + + if id.SharedPrivateLinkResourceName != "sharedPrivateLinkResourceValue" { + t.Fatalf("Expected %q but got %q for Segment 'SharedPrivateLinkResourceName'", id.SharedPrivateLinkResourceName, "sharedPrivateLinkResourceValue") + } +} + +func TestFormatSharedPrivateLinkResourceID(t *testing.T) { + actual := NewSharedPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "signalRValue", "sharedPrivateLinkResourceValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue/sharedPrivateLinkResources/sharedPrivateLinkResourceValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSharedPrivateLinkResourceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SharedPrivateLinkResourceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue/sharedPrivateLinkResources", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue/sharedPrivateLinkResources/sharedPrivateLinkResourceValue", + Expected: &SharedPrivateLinkResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SignalRName: "signalRValue", + SharedPrivateLinkResourceName: "sharedPrivateLinkResourceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue/sharedPrivateLinkResources/sharedPrivateLinkResourceValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSharedPrivateLinkResourceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SignalRName != v.Expected.SignalRName { + t.Fatalf("Expected %q but got %q for SignalRName", v.Expected.SignalRName, actual.SignalRName) + } + + if actual.SharedPrivateLinkResourceName != v.Expected.SharedPrivateLinkResourceName { + t.Fatalf("Expected %q but got %q for SharedPrivateLinkResourceName", v.Expected.SharedPrivateLinkResourceName, actual.SharedPrivateLinkResourceName) + } + + } +} + +func TestParseSharedPrivateLinkResourceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SharedPrivateLinkResourceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/sIgNaLr", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/sIgNaLr/sIgNaLrVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue/sharedPrivateLinkResources", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/sIgNaLr/sIgNaLrVaLuE/sHaReDpRiVaTeLiNkReSoUrCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue/sharedPrivateLinkResources/sharedPrivateLinkResourceValue", + Expected: &SharedPrivateLinkResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SignalRName: "signalRValue", + SharedPrivateLinkResourceName: "sharedPrivateLinkResourceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue/sharedPrivateLinkResources/sharedPrivateLinkResourceValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/sIgNaLr/sIgNaLrVaLuE/sHaReDpRiVaTeLiNkReSoUrCeS/sHaReDpRiVaTeLiNkReSoUrCeVaLuE", + Expected: &SharedPrivateLinkResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SignalRName: "sIgNaLrVaLuE", + SharedPrivateLinkResourceName: "sHaReDpRiVaTeLiNkReSoUrCeVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/sIgNaLr/sIgNaLrVaLuE/sHaReDpRiVaTeLiNkReSoUrCeS/sHaReDpRiVaTeLiNkReSoUrCeVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSharedPrivateLinkResourceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SignalRName != v.Expected.SignalRName { + t.Fatalf("Expected %q but got %q for SignalRName", v.Expected.SignalRName, actual.SignalRName) + } + + if actual.SharedPrivateLinkResourceName != v.Expected.SharedPrivateLinkResourceName { + t.Fatalf("Expected %q but got %q for SharedPrivateLinkResourceName", v.Expected.SharedPrivateLinkResourceName, actual.SharedPrivateLinkResourceName) + } + + } +} + +func TestSegmentsForSharedPrivateLinkResourceId(t *testing.T) { + segments := SharedPrivateLinkResourceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SharedPrivateLinkResourceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/signalr/2024-03-01/signalr/id_signalr.go b/resource-manager/signalr/2024-03-01/signalr/id_signalr.go new file mode 100644 index 00000000000..3c2909478d7 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/id_signalr.go @@ -0,0 +1,130 @@ +package signalr + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SignalRId{}) +} + +var _ resourceids.ResourceId = &SignalRId{} + +// SignalRId is a struct representing the Resource ID for a Signal R +type SignalRId struct { + SubscriptionId string + ResourceGroupName string + SignalRName string +} + +// NewSignalRID returns a new SignalRId struct +func NewSignalRID(subscriptionId string, resourceGroupName string, signalRName string) SignalRId { + return SignalRId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SignalRName: signalRName, + } +} + +// ParseSignalRID parses 'input' into a SignalRId +func ParseSignalRID(input string) (*SignalRId, error) { + parser := resourceids.NewParserFromResourceIdType(&SignalRId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SignalRId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSignalRIDInsensitively parses 'input' case-insensitively into a SignalRId +// note: this method should only be used for API response data and not user input +func ParseSignalRIDInsensitively(input string) (*SignalRId, error) { + parser := resourceids.NewParserFromResourceIdType(&SignalRId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SignalRId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SignalRId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SignalRName, ok = input.Parsed["signalRName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "signalRName", input) + } + + return nil +} + +// ValidateSignalRID checks that 'input' can be parsed as a Signal R ID +func ValidateSignalRID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSignalRID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Signal R ID +func (id SignalRId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.SignalRService/signalR/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SignalRName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Signal R ID +func (id SignalRId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftSignalRService", "Microsoft.SignalRService", "Microsoft.SignalRService"), + resourceids.StaticSegment("staticSignalR", "signalR", "signalR"), + resourceids.UserSpecifiedSegment("signalRName", "signalRValue"), + } +} + +// String returns a human-readable description of this Signal R ID +func (id SignalRId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Signal R Name: %q", id.SignalRName), + } + return fmt.Sprintf("Signal R (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/signalr/2024-03-01/signalr/id_signalr_test.go b/resource-manager/signalr/2024-03-01/signalr/id_signalr_test.go new file mode 100644 index 00000000000..1e36cd4a19f --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/id_signalr_test.go @@ -0,0 +1,282 @@ +package signalr + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SignalRId{} + +func TestNewSignalRID(t *testing.T) { + id := NewSignalRID("12345678-1234-9876-4563-123456789012", "example-resource-group", "signalRValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SignalRName != "signalRValue" { + t.Fatalf("Expected %q but got %q for Segment 'SignalRName'", id.SignalRName, "signalRValue") + } +} + +func TestFormatSignalRID(t *testing.T) { + actual := NewSignalRID("12345678-1234-9876-4563-123456789012", "example-resource-group", "signalRValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSignalRID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SignalRId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue", + Expected: &SignalRId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SignalRName: "signalRValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSignalRID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SignalRName != v.Expected.SignalRName { + t.Fatalf("Expected %q but got %q for SignalRName", v.Expected.SignalRName, actual.SignalRName) + } + + } +} + +func TestParseSignalRIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SignalRId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/sIgNaLr", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue", + Expected: &SignalRId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SignalRName: "signalRValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/signalR/signalRValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/sIgNaLr/sIgNaLrVaLuE", + Expected: &SignalRId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SignalRName: "sIgNaLrVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/sIgNaLr/sIgNaLrVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSignalRIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SignalRName != v.Expected.SignalRName { + t.Fatalf("Expected %q but got %q for SignalRName", v.Expected.SignalRName, actual.SignalRName) + } + + } +} + +func TestSegmentsForSignalRId(t *testing.T) { + segments := SignalRId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SignalRId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/signalr/2024-03-01/signalr/method_checknameavailability.go b/resource-manager/signalr/2024-03-01/signalr/method_checknameavailability.go new file mode 100644 index 00000000000..bcd49e5f1c1 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/method_checknameavailability.go @@ -0,0 +1,59 @@ +package signalr + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NameAvailability +} + +// CheckNameAvailability ... +func (c SignalRClient) CheckNameAvailability(ctx context.Context, id LocationId, input NameAvailabilityParameters) (result CheckNameAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/checkNameAvailability", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NameAvailability + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/signalr/2024-03-01/signalr/method_createorupdate.go b/resource-manager/signalr/2024-03-01/signalr/method_createorupdate.go new file mode 100644 index 00000000000..5a57bd51171 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/method_createorupdate.go @@ -0,0 +1,76 @@ +package signalr + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SignalRResource +} + +// CreateOrUpdate ... +func (c SignalRClient) CreateOrUpdate(ctx context.Context, id SignalRId, input SignalRResource) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c SignalRClient) CreateOrUpdateThenPoll(ctx context.Context, id SignalRId, input SignalRResource) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/signalr/2024-03-01/signalr/method_customcertificatescreateorupdate.go b/resource-manager/signalr/2024-03-01/signalr/method_customcertificatescreateorupdate.go new file mode 100644 index 00000000000..a838a6ccbc0 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/method_customcertificatescreateorupdate.go @@ -0,0 +1,75 @@ +package signalr + +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 CustomCertificatesCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *CustomCertificate +} + +// CustomCertificatesCreateOrUpdate ... +func (c SignalRClient) CustomCertificatesCreateOrUpdate(ctx context.Context, id CustomCertificateId, input CustomCertificate) (result CustomCertificatesCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CustomCertificatesCreateOrUpdateThenPoll performs CustomCertificatesCreateOrUpdate then polls until it's completed +func (c SignalRClient) CustomCertificatesCreateOrUpdateThenPoll(ctx context.Context, id CustomCertificateId, input CustomCertificate) error { + result, err := c.CustomCertificatesCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CustomCertificatesCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CustomCertificatesCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/signalr/2024-03-01/signalr/method_customcertificatesdelete.go b/resource-manager/signalr/2024-03-01/signalr/method_customcertificatesdelete.go new file mode 100644 index 00000000000..8dd48c72e66 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/method_customcertificatesdelete.go @@ -0,0 +1,47 @@ +package signalr + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomCertificatesDeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// CustomCertificatesDelete ... +func (c SignalRClient) CustomCertificatesDelete(ctx context.Context, id CustomCertificateId) (result CustomCertificatesDeleteOperationResponse, 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/signalr/2024-03-01/signalr/method_customcertificatesget.go b/resource-manager/signalr/2024-03-01/signalr/method_customcertificatesget.go new file mode 100644 index 00000000000..d578f431c41 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/method_customcertificatesget.go @@ -0,0 +1,54 @@ +package signalr + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomCertificatesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CustomCertificate +} + +// CustomCertificatesGet ... +func (c SignalRClient) CustomCertificatesGet(ctx context.Context, id CustomCertificateId) (result CustomCertificatesGetOperationResponse, 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 CustomCertificate + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/signalr/2024-03-01/signalr/method_customcertificateslist.go b/resource-manager/signalr/2024-03-01/signalr/method_customcertificateslist.go new file mode 100644 index 00000000000..a862d047bb8 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/method_customcertificateslist.go @@ -0,0 +1,92 @@ +package signalr + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomCertificatesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CustomCertificate +} + +type CustomCertificatesListCompleteResult struct { + LatestHttpResponse *http.Response + Items []CustomCertificate +} + +// CustomCertificatesList ... +func (c SignalRClient) CustomCertificatesList(ctx context.Context, id SignalRId) (result CustomCertificatesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/customCertificates", 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 *[]CustomCertificate `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// CustomCertificatesListComplete retrieves all the results into a single object +func (c SignalRClient) CustomCertificatesListComplete(ctx context.Context, id SignalRId) (CustomCertificatesListCompleteResult, error) { + return c.CustomCertificatesListCompleteMatchingPredicate(ctx, id, CustomCertificateOperationPredicate{}) +} + +// CustomCertificatesListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SignalRClient) CustomCertificatesListCompleteMatchingPredicate(ctx context.Context, id SignalRId, predicate CustomCertificateOperationPredicate) (result CustomCertificatesListCompleteResult, err error) { + items := make([]CustomCertificate, 0) + + resp, err := c.CustomCertificatesList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = CustomCertificatesListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/signalr/2024-03-01/signalr/method_customdomainscreateorupdate.go b/resource-manager/signalr/2024-03-01/signalr/method_customdomainscreateorupdate.go new file mode 100644 index 00000000000..c0083d8644d --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/method_customdomainscreateorupdate.go @@ -0,0 +1,74 @@ +package signalr + +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 CustomDomainsCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *CustomDomain +} + +// CustomDomainsCreateOrUpdate ... +func (c SignalRClient) CustomDomainsCreateOrUpdate(ctx context.Context, id CustomDomainId, input CustomDomain) (result CustomDomainsCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CustomDomainsCreateOrUpdateThenPoll performs CustomDomainsCreateOrUpdate then polls until it's completed +func (c SignalRClient) CustomDomainsCreateOrUpdateThenPoll(ctx context.Context, id CustomDomainId, input CustomDomain) error { + result, err := c.CustomDomainsCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CustomDomainsCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CustomDomainsCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/signalr/2024-03-01/signalr/method_customdomainsdelete.go b/resource-manager/signalr/2024-03-01/signalr/method_customdomainsdelete.go new file mode 100644 index 00000000000..3acee4f8171 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/method_customdomainsdelete.go @@ -0,0 +1,71 @@ +package signalr + +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 CustomDomainsDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CustomDomainsDelete ... +func (c SignalRClient) CustomDomainsDelete(ctx context.Context, id CustomDomainId) (result CustomDomainsDeleteOperationResponse, 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 +} + +// CustomDomainsDeleteThenPoll performs CustomDomainsDelete then polls until it's completed +func (c SignalRClient) CustomDomainsDeleteThenPoll(ctx context.Context, id CustomDomainId) error { + result, err := c.CustomDomainsDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing CustomDomainsDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CustomDomainsDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/signalr/2024-03-01/signalr/method_customdomainsget.go b/resource-manager/signalr/2024-03-01/signalr/method_customdomainsget.go new file mode 100644 index 00000000000..0d2b6dbe7df --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/method_customdomainsget.go @@ -0,0 +1,54 @@ +package signalr + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomDomainsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CustomDomain +} + +// CustomDomainsGet ... +func (c SignalRClient) CustomDomainsGet(ctx context.Context, id CustomDomainId) (result CustomDomainsGetOperationResponse, 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 CustomDomain + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/signalr/2024-03-01/signalr/method_customdomainslist.go b/resource-manager/signalr/2024-03-01/signalr/method_customdomainslist.go new file mode 100644 index 00000000000..95d92e50a6b --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/method_customdomainslist.go @@ -0,0 +1,92 @@ +package signalr + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomDomainsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CustomDomain +} + +type CustomDomainsListCompleteResult struct { + LatestHttpResponse *http.Response + Items []CustomDomain +} + +// CustomDomainsList ... +func (c SignalRClient) CustomDomainsList(ctx context.Context, id SignalRId) (result CustomDomainsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/customDomains", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]CustomDomain `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// CustomDomainsListComplete retrieves all the results into a single object +func (c SignalRClient) CustomDomainsListComplete(ctx context.Context, id SignalRId) (CustomDomainsListCompleteResult, error) { + return c.CustomDomainsListCompleteMatchingPredicate(ctx, id, CustomDomainOperationPredicate{}) +} + +// CustomDomainsListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SignalRClient) CustomDomainsListCompleteMatchingPredicate(ctx context.Context, id SignalRId, predicate CustomDomainOperationPredicate) (result CustomDomainsListCompleteResult, err error) { + items := make([]CustomDomain, 0) + + resp, err := c.CustomDomainsList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = CustomDomainsListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/signalr/2024-03-01/signalr/method_delete.go b/resource-manager/signalr/2024-03-01/signalr/method_delete.go new file mode 100644 index 00000000000..1c36e7186a8 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/method_delete.go @@ -0,0 +1,71 @@ +package signalr + +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 SignalRClient) Delete(ctx context.Context, id SignalRId) (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 SignalRClient) DeleteThenPoll(ctx context.Context, id SignalRId) 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/signalr/2024-03-01/signalr/method_get.go b/resource-manager/signalr/2024-03-01/signalr/method_get.go new file mode 100644 index 00000000000..21bba97c916 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/method_get.go @@ -0,0 +1,54 @@ +package signalr + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *SignalRResource +} + +// Get ... +func (c SignalRClient) Get(ctx context.Context, id SignalRId) (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 SignalRResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/signalr/2024-03-01/signalr/method_listbyresourcegroup.go b/resource-manager/signalr/2024-03-01/signalr/method_listbyresourcegroup.go new file mode 100644 index 00000000000..51f60cbee08 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/method_listbyresourcegroup.go @@ -0,0 +1,93 @@ +package signalr + +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 *[]SignalRResource +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []SignalRResource +} + +// ListByResourceGroup ... +func (c SignalRClient) 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.SignalRService/signalR", 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 *[]SignalRResource `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 SignalRClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, SignalRResourceOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SignalRClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate SignalRResourceOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]SignalRResource, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/signalr/2024-03-01/signalr/method_listbysubscription.go b/resource-manager/signalr/2024-03-01/signalr/method_listbysubscription.go new file mode 100644 index 00000000000..10fbe2d99d9 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/method_listbysubscription.go @@ -0,0 +1,93 @@ +package signalr + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SignalRResource +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []SignalRResource +} + +// ListBySubscription ... +func (c SignalRClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.SignalRService/signalR", 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 *[]SignalRResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c SignalRClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, SignalRResourceOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SignalRClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate SignalRResourceOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]SignalRResource, 0) + + resp, err := c.ListBySubscription(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/signalr/2024-03-01/signalr/method_listkeys.go b/resource-manager/signalr/2024-03-01/signalr/method_listkeys.go new file mode 100644 index 00000000000..d64c1522a2b --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/method_listkeys.go @@ -0,0 +1,55 @@ +package signalr + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SignalRKeys +} + +// ListKeys ... +func (c SignalRClient) ListKeys(ctx context.Context, id SignalRId) (result ListKeysOperationResponse, 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 SignalRKeys + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/signalr/2024-03-01/signalr/method_listreplicaskus.go b/resource-manager/signalr/2024-03-01/signalr/method_listreplicaskus.go new file mode 100644 index 00000000000..47be25db25a --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/method_listreplicaskus.go @@ -0,0 +1,92 @@ +package signalr + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListReplicaSkusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Sku +} + +type ListReplicaSkusCompleteResult struct { + LatestHttpResponse *http.Response + Items []Sku +} + +// ListReplicaSkus ... +func (c SignalRClient) ListReplicaSkus(ctx context.Context, id ReplicaId) (result ListReplicaSkusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/skus", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Sku `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListReplicaSkusComplete retrieves all the results into a single object +func (c SignalRClient) ListReplicaSkusComplete(ctx context.Context, id ReplicaId) (ListReplicaSkusCompleteResult, error) { + return c.ListReplicaSkusCompleteMatchingPredicate(ctx, id, SkuOperationPredicate{}) +} + +// ListReplicaSkusCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SignalRClient) ListReplicaSkusCompleteMatchingPredicate(ctx context.Context, id ReplicaId, predicate SkuOperationPredicate) (result ListReplicaSkusCompleteResult, err error) { + items := make([]Sku, 0) + + resp, err := c.ListReplicaSkus(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListReplicaSkusCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/signalr/2024-03-01/signalr/method_listskus.go b/resource-manager/signalr/2024-03-01/signalr/method_listskus.go new file mode 100644 index 00000000000..253619c723f --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/method_listskus.go @@ -0,0 +1,92 @@ +package signalr + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListSkusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Sku +} + +type ListSkusCompleteResult struct { + LatestHttpResponse *http.Response + Items []Sku +} + +// ListSkus ... +func (c SignalRClient) ListSkus(ctx context.Context, id SignalRId) (result ListSkusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/skus", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Sku `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSkusComplete retrieves all the results into a single object +func (c SignalRClient) ListSkusComplete(ctx context.Context, id SignalRId) (ListSkusCompleteResult, error) { + return c.ListSkusCompleteMatchingPredicate(ctx, id, SkuOperationPredicate{}) +} + +// ListSkusCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SignalRClient) ListSkusCompleteMatchingPredicate(ctx context.Context, id SignalRId, predicate SkuOperationPredicate) (result ListSkusCompleteResult, err error) { + items := make([]Sku, 0) + + resp, err := c.ListSkus(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSkusCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/signalr/2024-03-01/signalr/method_privateendpointconnectionsdelete.go b/resource-manager/signalr/2024-03-01/signalr/method_privateendpointconnectionsdelete.go new file mode 100644 index 00000000000..46a72d0903d --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/method_privateendpointconnectionsdelete.go @@ -0,0 +1,71 @@ +package signalr + +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 PrivateEndpointConnectionsDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// PrivateEndpointConnectionsDelete ... +func (c SignalRClient) PrivateEndpointConnectionsDelete(ctx context.Context, id PrivateEndpointConnectionId) (result PrivateEndpointConnectionsDeleteOperationResponse, 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 +} + +// PrivateEndpointConnectionsDeleteThenPoll performs PrivateEndpointConnectionsDelete then polls until it's completed +func (c SignalRClient) PrivateEndpointConnectionsDeleteThenPoll(ctx context.Context, id PrivateEndpointConnectionId) error { + result, err := c.PrivateEndpointConnectionsDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing PrivateEndpointConnectionsDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after PrivateEndpointConnectionsDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/signalr/2024-03-01/signalr/method_privateendpointconnectionsget.go b/resource-manager/signalr/2024-03-01/signalr/method_privateendpointconnectionsget.go new file mode 100644 index 00000000000..7db6c53904f --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/method_privateendpointconnectionsget.go @@ -0,0 +1,54 @@ +package signalr + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnection +} + +// PrivateEndpointConnectionsGet ... +func (c SignalRClient) PrivateEndpointConnectionsGet(ctx context.Context, id PrivateEndpointConnectionId) (result PrivateEndpointConnectionsGetOperationResponse, 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/signalr/2024-03-01/signalr/method_privateendpointconnectionslist.go b/resource-manager/signalr/2024-03-01/signalr/method_privateendpointconnectionslist.go new file mode 100644 index 00000000000..e34ed499046 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/method_privateendpointconnectionslist.go @@ -0,0 +1,92 @@ +package signalr + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PrivateEndpointConnection +} + +type PrivateEndpointConnectionsListCompleteResult struct { + LatestHttpResponse *http.Response + Items []PrivateEndpointConnection +} + +// PrivateEndpointConnectionsList ... +func (c SignalRClient) PrivateEndpointConnectionsList(ctx context.Context, id SignalRId) (result PrivateEndpointConnectionsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateEndpointConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PrivateEndpointConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// PrivateEndpointConnectionsListComplete retrieves all the results into a single object +func (c SignalRClient) PrivateEndpointConnectionsListComplete(ctx context.Context, id SignalRId) (PrivateEndpointConnectionsListCompleteResult, error) { + return c.PrivateEndpointConnectionsListCompleteMatchingPredicate(ctx, id, PrivateEndpointConnectionOperationPredicate{}) +} + +// PrivateEndpointConnectionsListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SignalRClient) PrivateEndpointConnectionsListCompleteMatchingPredicate(ctx context.Context, id SignalRId, predicate PrivateEndpointConnectionOperationPredicate) (result PrivateEndpointConnectionsListCompleteResult, err error) { + items := make([]PrivateEndpointConnection, 0) + + resp, err := c.PrivateEndpointConnectionsList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = PrivateEndpointConnectionsListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/signalr/2024-03-01/signalr/method_privateendpointconnectionsupdate.go b/resource-manager/signalr/2024-03-01/signalr/method_privateendpointconnectionsupdate.go new file mode 100644 index 00000000000..08598a73e3a --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/method_privateendpointconnectionsupdate.go @@ -0,0 +1,58 @@ +package signalr + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionsUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnection +} + +// PrivateEndpointConnectionsUpdate ... +func (c SignalRClient) PrivateEndpointConnectionsUpdate(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) (result PrivateEndpointConnectionsUpdateOperationResponse, 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 PrivateEndpointConnection + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/signalr/2024-03-01/signalr/method_privatelinkresourceslist.go b/resource-manager/signalr/2024-03-01/signalr/method_privatelinkresourceslist.go new file mode 100644 index 00000000000..1c1c04bcada --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/method_privatelinkresourceslist.go @@ -0,0 +1,92 @@ +package signalr + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourcesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PrivateLinkResource +} + +type PrivateLinkResourcesListCompleteResult struct { + LatestHttpResponse *http.Response + Items []PrivateLinkResource +} + +// PrivateLinkResourcesList ... +func (c SignalRClient) PrivateLinkResourcesList(ctx context.Context, id SignalRId) (result PrivateLinkResourcesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateLinkResources", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PrivateLinkResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// PrivateLinkResourcesListComplete retrieves all the results into a single object +func (c SignalRClient) PrivateLinkResourcesListComplete(ctx context.Context, id SignalRId) (PrivateLinkResourcesListCompleteResult, error) { + return c.PrivateLinkResourcesListCompleteMatchingPredicate(ctx, id, PrivateLinkResourceOperationPredicate{}) +} + +// PrivateLinkResourcesListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SignalRClient) PrivateLinkResourcesListCompleteMatchingPredicate(ctx context.Context, id SignalRId, predicate PrivateLinkResourceOperationPredicate) (result PrivateLinkResourcesListCompleteResult, err error) { + items := make([]PrivateLinkResource, 0) + + resp, err := c.PrivateLinkResourcesList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = PrivateLinkResourcesListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/signalr/2024-03-01/signalr/method_regeneratekey.go b/resource-manager/signalr/2024-03-01/signalr/method_regeneratekey.go new file mode 100644 index 00000000000..e37a378fb12 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/method_regeneratekey.go @@ -0,0 +1,75 @@ +package signalr + +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 RegenerateKeyOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SignalRKeys +} + +// RegenerateKey ... +func (c SignalRClient) RegenerateKey(ctx context.Context, id SignalRId, input RegenerateKeyParameters) (result RegenerateKeyOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/regenerateKey", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + 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 +} + +// RegenerateKeyThenPoll performs RegenerateKey then polls until it's completed +func (c SignalRClient) RegenerateKeyThenPoll(ctx context.Context, id SignalRId, input RegenerateKeyParameters) error { + result, err := c.RegenerateKey(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RegenerateKey: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RegenerateKey: %+v", err) + } + + return nil +} diff --git a/resource-manager/signalr/2024-03-01/signalr/method_replicascreateorupdate.go b/resource-manager/signalr/2024-03-01/signalr/method_replicascreateorupdate.go new file mode 100644 index 00000000000..9d1aa1cc95b --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/method_replicascreateorupdate.go @@ -0,0 +1,75 @@ +package signalr + +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 ReplicasCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Replica +} + +// ReplicasCreateOrUpdate ... +func (c SignalRClient) ReplicasCreateOrUpdate(ctx context.Context, id ReplicaId, input Replica) (result ReplicasCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ReplicasCreateOrUpdateThenPoll performs ReplicasCreateOrUpdate then polls until it's completed +func (c SignalRClient) ReplicasCreateOrUpdateThenPoll(ctx context.Context, id ReplicaId, input Replica) error { + result, err := c.ReplicasCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ReplicasCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ReplicasCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/signalr/2024-03-01/signalr/method_replicasdelete.go b/resource-manager/signalr/2024-03-01/signalr/method_replicasdelete.go new file mode 100644 index 00000000000..d3e50cf4483 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/method_replicasdelete.go @@ -0,0 +1,47 @@ +package signalr + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicasDeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ReplicasDelete ... +func (c SignalRClient) ReplicasDelete(ctx context.Context, id ReplicaId) (result ReplicasDeleteOperationResponse, 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/signalr/2024-03-01/signalr/method_replicasget.go b/resource-manager/signalr/2024-03-01/signalr/method_replicasget.go new file mode 100644 index 00000000000..c46dd5749cd --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/method_replicasget.go @@ -0,0 +1,54 @@ +package signalr + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicasGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Replica +} + +// ReplicasGet ... +func (c SignalRClient) ReplicasGet(ctx context.Context, id ReplicaId) (result ReplicasGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Replica + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/signalr/2024-03-01/signalr/method_replicasharedprivatelinkresourcescreateorupdate.go b/resource-manager/signalr/2024-03-01/signalr/method_replicasharedprivatelinkresourcescreateorupdate.go new file mode 100644 index 00000000000..c1f769ad203 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/method_replicasharedprivatelinkresourcescreateorupdate.go @@ -0,0 +1,75 @@ +package signalr + +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 ReplicaSharedPrivateLinkResourcesCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SharedPrivateLinkResource +} + +// ReplicaSharedPrivateLinkResourcesCreateOrUpdate ... +func (c SignalRClient) ReplicaSharedPrivateLinkResourcesCreateOrUpdate(ctx context.Context, id ReplicaSharedPrivateLinkResourceId, input SharedPrivateLinkResource) (result ReplicaSharedPrivateLinkResourcesCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ReplicaSharedPrivateLinkResourcesCreateOrUpdateThenPoll performs ReplicaSharedPrivateLinkResourcesCreateOrUpdate then polls until it's completed +func (c SignalRClient) ReplicaSharedPrivateLinkResourcesCreateOrUpdateThenPoll(ctx context.Context, id ReplicaSharedPrivateLinkResourceId, input SharedPrivateLinkResource) error { + result, err := c.ReplicaSharedPrivateLinkResourcesCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ReplicaSharedPrivateLinkResourcesCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ReplicaSharedPrivateLinkResourcesCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/signalr/2024-03-01/signalr/method_replicasharedprivatelinkresourcesget.go b/resource-manager/signalr/2024-03-01/signalr/method_replicasharedprivatelinkresourcesget.go new file mode 100644 index 00000000000..9ff412a394b --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/method_replicasharedprivatelinkresourcesget.go @@ -0,0 +1,54 @@ +package signalr + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicaSharedPrivateLinkResourcesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SharedPrivateLinkResource +} + +// ReplicaSharedPrivateLinkResourcesGet ... +func (c SignalRClient) ReplicaSharedPrivateLinkResourcesGet(ctx context.Context, id ReplicaSharedPrivateLinkResourceId) (result ReplicaSharedPrivateLinkResourcesGetOperationResponse, 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 SharedPrivateLinkResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/signalr/2024-03-01/signalr/method_replicasharedprivatelinkresourceslist.go b/resource-manager/signalr/2024-03-01/signalr/method_replicasharedprivatelinkresourceslist.go new file mode 100644 index 00000000000..3d6b1247720 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/method_replicasharedprivatelinkresourceslist.go @@ -0,0 +1,92 @@ +package signalr + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicaSharedPrivateLinkResourcesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SharedPrivateLinkResource +} + +type ReplicaSharedPrivateLinkResourcesListCompleteResult struct { + LatestHttpResponse *http.Response + Items []SharedPrivateLinkResource +} + +// ReplicaSharedPrivateLinkResourcesList ... +func (c SignalRClient) ReplicaSharedPrivateLinkResourcesList(ctx context.Context, id ReplicaId) (result ReplicaSharedPrivateLinkResourcesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/sharedPrivateLinkResources", 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 *[]SharedPrivateLinkResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ReplicaSharedPrivateLinkResourcesListComplete retrieves all the results into a single object +func (c SignalRClient) ReplicaSharedPrivateLinkResourcesListComplete(ctx context.Context, id ReplicaId) (ReplicaSharedPrivateLinkResourcesListCompleteResult, error) { + return c.ReplicaSharedPrivateLinkResourcesListCompleteMatchingPredicate(ctx, id, SharedPrivateLinkResourceOperationPredicate{}) +} + +// ReplicaSharedPrivateLinkResourcesListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SignalRClient) ReplicaSharedPrivateLinkResourcesListCompleteMatchingPredicate(ctx context.Context, id ReplicaId, predicate SharedPrivateLinkResourceOperationPredicate) (result ReplicaSharedPrivateLinkResourcesListCompleteResult, err error) { + items := make([]SharedPrivateLinkResource, 0) + + resp, err := c.ReplicaSharedPrivateLinkResourcesList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ReplicaSharedPrivateLinkResourcesListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/signalr/2024-03-01/signalr/method_replicaslist.go b/resource-manager/signalr/2024-03-01/signalr/method_replicaslist.go new file mode 100644 index 00000000000..f582e1328e9 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/method_replicaslist.go @@ -0,0 +1,92 @@ +package signalr + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicasListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Replica +} + +type ReplicasListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Replica +} + +// ReplicasList ... +func (c SignalRClient) ReplicasList(ctx context.Context, id SignalRId) (result ReplicasListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/replicas", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Replica `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ReplicasListComplete retrieves all the results into a single object +func (c SignalRClient) ReplicasListComplete(ctx context.Context, id SignalRId) (ReplicasListCompleteResult, error) { + return c.ReplicasListCompleteMatchingPredicate(ctx, id, ReplicaOperationPredicate{}) +} + +// ReplicasListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SignalRClient) ReplicasListCompleteMatchingPredicate(ctx context.Context, id SignalRId, predicate ReplicaOperationPredicate) (result ReplicasListCompleteResult, err error) { + items := make([]Replica, 0) + + resp, err := c.ReplicasList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ReplicasListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/signalr/2024-03-01/signalr/method_replicasrestart.go b/resource-manager/signalr/2024-03-01/signalr/method_replicasrestart.go new file mode 100644 index 00000000000..30d5b28a4b7 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/method_replicasrestart.go @@ -0,0 +1,70 @@ +package signalr + +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 ReplicasRestartOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ReplicasRestart ... +func (c SignalRClient) ReplicasRestart(ctx context.Context, id ReplicaId) (result ReplicasRestartOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restart", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ReplicasRestartThenPoll performs ReplicasRestart then polls until it's completed +func (c SignalRClient) ReplicasRestartThenPoll(ctx context.Context, id ReplicaId) error { + result, err := c.ReplicasRestart(ctx, id) + if err != nil { + return fmt.Errorf("performing ReplicasRestart: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ReplicasRestart: %+v", err) + } + + return nil +} diff --git a/resource-manager/signalr/2024-03-01/signalr/method_replicasupdate.go b/resource-manager/signalr/2024-03-01/signalr/method_replicasupdate.go new file mode 100644 index 00000000000..69b9d847970 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/method_replicasupdate.go @@ -0,0 +1,75 @@ +package signalr + +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 ReplicasUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Replica +} + +// ReplicasUpdate ... +func (c SignalRClient) ReplicasUpdate(ctx context.Context, id ReplicaId, input Replica) (result ReplicasUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ReplicasUpdateThenPoll performs ReplicasUpdate then polls until it's completed +func (c SignalRClient) ReplicasUpdateThenPoll(ctx context.Context, id ReplicaId, input Replica) error { + result, err := c.ReplicasUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ReplicasUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ReplicasUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/signalr/2024-03-01/signalr/method_restart.go b/resource-manager/signalr/2024-03-01/signalr/method_restart.go new file mode 100644 index 00000000000..bebffe48acf --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/method_restart.go @@ -0,0 +1,70 @@ +package signalr + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestartOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Restart ... +func (c SignalRClient) Restart(ctx context.Context, id SignalRId) (result RestartOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restart", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RestartThenPoll performs Restart then polls until it's completed +func (c SignalRClient) RestartThenPoll(ctx context.Context, id SignalRId) error { + result, err := c.Restart(ctx, id) + if err != nil { + return fmt.Errorf("performing Restart: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Restart: %+v", err) + } + + return nil +} diff --git a/resource-manager/signalr/2024-03-01/signalr/method_sharedprivatelinkresourcescreateorupdate.go b/resource-manager/signalr/2024-03-01/signalr/method_sharedprivatelinkresourcescreateorupdate.go new file mode 100644 index 00000000000..5f0afeb7a2a --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/method_sharedprivatelinkresourcescreateorupdate.go @@ -0,0 +1,75 @@ +package signalr + +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 SharedPrivateLinkResourcesCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SharedPrivateLinkResource +} + +// SharedPrivateLinkResourcesCreateOrUpdate ... +func (c SignalRClient) SharedPrivateLinkResourcesCreateOrUpdate(ctx context.Context, id SharedPrivateLinkResourceId, input SharedPrivateLinkResource) (result SharedPrivateLinkResourcesCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// SharedPrivateLinkResourcesCreateOrUpdateThenPoll performs SharedPrivateLinkResourcesCreateOrUpdate then polls until it's completed +func (c SignalRClient) SharedPrivateLinkResourcesCreateOrUpdateThenPoll(ctx context.Context, id SharedPrivateLinkResourceId, input SharedPrivateLinkResource) error { + result, err := c.SharedPrivateLinkResourcesCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing SharedPrivateLinkResourcesCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SharedPrivateLinkResourcesCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/signalr/2024-03-01/signalr/method_sharedprivatelinkresourcesdelete.go b/resource-manager/signalr/2024-03-01/signalr/method_sharedprivatelinkresourcesdelete.go new file mode 100644 index 00000000000..fcf37c321bd --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/method_sharedprivatelinkresourcesdelete.go @@ -0,0 +1,71 @@ +package signalr + +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 SharedPrivateLinkResourcesDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// SharedPrivateLinkResourcesDelete ... +func (c SignalRClient) SharedPrivateLinkResourcesDelete(ctx context.Context, id SharedPrivateLinkResourceId) (result SharedPrivateLinkResourcesDeleteOperationResponse, 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 +} + +// SharedPrivateLinkResourcesDeleteThenPoll performs SharedPrivateLinkResourcesDelete then polls until it's completed +func (c SignalRClient) SharedPrivateLinkResourcesDeleteThenPoll(ctx context.Context, id SharedPrivateLinkResourceId) error { + result, err := c.SharedPrivateLinkResourcesDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing SharedPrivateLinkResourcesDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SharedPrivateLinkResourcesDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/signalr/2024-03-01/signalr/method_sharedprivatelinkresourcesget.go b/resource-manager/signalr/2024-03-01/signalr/method_sharedprivatelinkresourcesget.go new file mode 100644 index 00000000000..d0b8ac5ccc9 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/method_sharedprivatelinkresourcesget.go @@ -0,0 +1,54 @@ +package signalr + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SharedPrivateLinkResourcesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SharedPrivateLinkResource +} + +// SharedPrivateLinkResourcesGet ... +func (c SignalRClient) SharedPrivateLinkResourcesGet(ctx context.Context, id SharedPrivateLinkResourceId) (result SharedPrivateLinkResourcesGetOperationResponse, 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 SharedPrivateLinkResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/signalr/2024-03-01/signalr/method_sharedprivatelinkresourceslist.go b/resource-manager/signalr/2024-03-01/signalr/method_sharedprivatelinkresourceslist.go new file mode 100644 index 00000000000..ea248b11d90 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/method_sharedprivatelinkresourceslist.go @@ -0,0 +1,92 @@ +package signalr + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SharedPrivateLinkResourcesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SharedPrivateLinkResource +} + +type SharedPrivateLinkResourcesListCompleteResult struct { + LatestHttpResponse *http.Response + Items []SharedPrivateLinkResource +} + +// SharedPrivateLinkResourcesList ... +func (c SignalRClient) SharedPrivateLinkResourcesList(ctx context.Context, id SignalRId) (result SharedPrivateLinkResourcesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/sharedPrivateLinkResources", 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 *[]SharedPrivateLinkResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// SharedPrivateLinkResourcesListComplete retrieves all the results into a single object +func (c SignalRClient) SharedPrivateLinkResourcesListComplete(ctx context.Context, id SignalRId) (SharedPrivateLinkResourcesListCompleteResult, error) { + return c.SharedPrivateLinkResourcesListCompleteMatchingPredicate(ctx, id, SharedPrivateLinkResourceOperationPredicate{}) +} + +// SharedPrivateLinkResourcesListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SignalRClient) SharedPrivateLinkResourcesListCompleteMatchingPredicate(ctx context.Context, id SignalRId, predicate SharedPrivateLinkResourceOperationPredicate) (result SharedPrivateLinkResourcesListCompleteResult, err error) { + items := make([]SharedPrivateLinkResource, 0) + + resp, err := c.SharedPrivateLinkResourcesList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = SharedPrivateLinkResourcesListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/signalr/2024-03-01/signalr/method_update.go b/resource-manager/signalr/2024-03-01/signalr/method_update.go new file mode 100644 index 00000000000..7f441c89412 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/method_update.go @@ -0,0 +1,75 @@ +package signalr + +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 *SignalRResource +} + +// Update ... +func (c SignalRClient) Update(ctx context.Context, id SignalRId, input SignalRResource) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c SignalRClient) UpdateThenPoll(ctx context.Context, id SignalRId, input SignalRResource) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/resource-manager/signalr/2024-03-01/signalr/method_usageslist.go b/resource-manager/signalr/2024-03-01/signalr/method_usageslist.go new file mode 100644 index 00000000000..398b21c0268 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/method_usageslist.go @@ -0,0 +1,92 @@ +package signalr + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UsagesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SignalRUsage +} + +type UsagesListCompleteResult struct { + LatestHttpResponse *http.Response + Items []SignalRUsage +} + +// UsagesList ... +func (c SignalRClient) UsagesList(ctx context.Context, id LocationId) (result UsagesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/usages", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SignalRUsage `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// UsagesListComplete retrieves all the results into a single object +func (c SignalRClient) UsagesListComplete(ctx context.Context, id LocationId) (UsagesListCompleteResult, error) { + return c.UsagesListCompleteMatchingPredicate(ctx, id, SignalRUsageOperationPredicate{}) +} + +// UsagesListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SignalRClient) UsagesListCompleteMatchingPredicate(ctx context.Context, id LocationId, predicate SignalRUsageOperationPredicate) (result UsagesListCompleteResult, err error) { + items := make([]SignalRUsage, 0) + + resp, err := c.UsagesList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = UsagesListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/signalr/2024-03-01/signalr/model_customcertificate.go b/resource-manager/signalr/2024-03-01/signalr/model_customcertificate.go new file mode 100644 index 00000000000..d6ff9633aa0 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/model_customcertificate.go @@ -0,0 +1,16 @@ +package signalr + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomCertificate struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties CustomCertificateProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/signalr/2024-03-01/signalr/model_customcertificateproperties.go b/resource-manager/signalr/2024-03-01/signalr/model_customcertificateproperties.go new file mode 100644 index 00000000000..95b0e37cbc8 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/model_customcertificateproperties.go @@ -0,0 +1,11 @@ +package signalr + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomCertificateProperties struct { + KeyVaultBaseUri string `json:"keyVaultBaseUri"` + KeyVaultSecretName string `json:"keyVaultSecretName"` + KeyVaultSecretVersion *string `json:"keyVaultSecretVersion,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/signalr/2024-03-01/signalr/model_customdomain.go b/resource-manager/signalr/2024-03-01/signalr/model_customdomain.go new file mode 100644 index 00000000000..07cf8a4002e --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/model_customdomain.go @@ -0,0 +1,16 @@ +package signalr + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomDomain struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties CustomDomainProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/signalr/2024-03-01/signalr/model_customdomainproperties.go b/resource-manager/signalr/2024-03-01/signalr/model_customdomainproperties.go new file mode 100644 index 00000000000..c084ddc8155 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/model_customdomainproperties.go @@ -0,0 +1,10 @@ +package signalr + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomDomainProperties struct { + CustomCertificate ResourceReference `json:"customCertificate"` + DomainName string `json:"domainName"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/signalr/2024-03-01/signalr/model_iprule.go b/resource-manager/signalr/2024-03-01/signalr/model_iprule.go new file mode 100644 index 00000000000..a9a918ccef7 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/model_iprule.go @@ -0,0 +1,9 @@ +package signalr + +// 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 *ACLAction `json:"action,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/signalr/2024-03-01/signalr/model_livetracecategory.go b/resource-manager/signalr/2024-03-01/signalr/model_livetracecategory.go new file mode 100644 index 00000000000..eaf0b128ba7 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/model_livetracecategory.go @@ -0,0 +1,9 @@ +package signalr + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LiveTraceCategory struct { + Enabled *string `json:"enabled,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/signalr/2024-03-01/signalr/model_livetraceconfiguration.go b/resource-manager/signalr/2024-03-01/signalr/model_livetraceconfiguration.go new file mode 100644 index 00000000000..62766225faf --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/model_livetraceconfiguration.go @@ -0,0 +1,9 @@ +package signalr + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LiveTraceConfiguration struct { + Categories *[]LiveTraceCategory `json:"categories,omitempty"` + Enabled *string `json:"enabled,omitempty"` +} diff --git a/resource-manager/signalr/2024-03-01/signalr/model_managedidentitysettings.go b/resource-manager/signalr/2024-03-01/signalr/model_managedidentitysettings.go new file mode 100644 index 00000000000..05ada7009e8 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/model_managedidentitysettings.go @@ -0,0 +1,8 @@ +package signalr + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedIdentitySettings struct { + Resource *string `json:"resource,omitempty"` +} diff --git a/resource-manager/signalr/2024-03-01/signalr/model_nameavailability.go b/resource-manager/signalr/2024-03-01/signalr/model_nameavailability.go new file mode 100644 index 00000000000..1c5d9874121 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/model_nameavailability.go @@ -0,0 +1,10 @@ +package signalr + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NameAvailability struct { + Message *string `json:"message,omitempty"` + NameAvailable *bool `json:"nameAvailable,omitempty"` + Reason *string `json:"reason,omitempty"` +} diff --git a/resource-manager/signalr/2024-03-01/signalr/model_nameavailabilityparameters.go b/resource-manager/signalr/2024-03-01/signalr/model_nameavailabilityparameters.go new file mode 100644 index 00000000000..e555e38d3e0 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/model_nameavailabilityparameters.go @@ -0,0 +1,9 @@ +package signalr + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NameAvailabilityParameters struct { + Name string `json:"name"` + Type string `json:"type"` +} diff --git a/resource-manager/signalr/2024-03-01/signalr/model_networkacl.go b/resource-manager/signalr/2024-03-01/signalr/model_networkacl.go new file mode 100644 index 00000000000..4527c32d44e --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/model_networkacl.go @@ -0,0 +1,9 @@ +package signalr + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkACL struct { + Allow *[]SignalRRequestType `json:"allow,omitempty"` + Deny *[]SignalRRequestType `json:"deny,omitempty"` +} diff --git a/resource-manager/signalr/2024-03-01/signalr/model_privateendpoint.go b/resource-manager/signalr/2024-03-01/signalr/model_privateendpoint.go new file mode 100644 index 00000000000..386ec10fcc5 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/model_privateendpoint.go @@ -0,0 +1,8 @@ +package signalr + +// 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/signalr/2024-03-01/signalr/model_privateendpointacl.go b/resource-manager/signalr/2024-03-01/signalr/model_privateendpointacl.go new file mode 100644 index 00000000000..023e23531e9 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/model_privateendpointacl.go @@ -0,0 +1,10 @@ +package signalr + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointACL struct { + Allow *[]SignalRRequestType `json:"allow,omitempty"` + Deny *[]SignalRRequestType `json:"deny,omitempty"` + Name string `json:"name"` +} diff --git a/resource-manager/signalr/2024-03-01/signalr/model_privateendpointconnection.go b/resource-manager/signalr/2024-03-01/signalr/model_privateendpointconnection.go new file mode 100644 index 00000000000..f82669103c5 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/model_privateendpointconnection.go @@ -0,0 +1,16 @@ +package signalr + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/signalr/2024-03-01/signalr/model_privateendpointconnectionproperties.go b/resource-manager/signalr/2024-03-01/signalr/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..4f579802977 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/model_privateendpointconnectionproperties.go @@ -0,0 +1,11 @@ +package signalr + +// 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 *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/signalr/2024-03-01/signalr/model_privatelinkresource.go b/resource-manager/signalr/2024-03-01/signalr/model_privatelinkresource.go new file mode 100644 index 00000000000..0cbcb04e862 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/model_privatelinkresource.go @@ -0,0 +1,16 @@ +package signalr + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkResourceProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/signalr/2024-03-01/signalr/model_privatelinkresourceproperties.go b/resource-manager/signalr/2024-03-01/signalr/model_privatelinkresourceproperties.go new file mode 100644 index 00000000000..15661eded28 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/model_privatelinkresourceproperties.go @@ -0,0 +1,11 @@ +package signalr + +// 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"` + ShareablePrivateLinkResourceTypes *[]ShareablePrivateLinkResourceType `json:"shareablePrivateLinkResourceTypes,omitempty"` +} diff --git a/resource-manager/signalr/2024-03-01/signalr/model_privatelinkserviceconnectionstate.go b/resource-manager/signalr/2024-03-01/signalr/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..943f9ca6832 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package signalr + +// 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,omitempty"` +} diff --git a/resource-manager/signalr/2024-03-01/signalr/model_regeneratekeyparameters.go b/resource-manager/signalr/2024-03-01/signalr/model_regeneratekeyparameters.go new file mode 100644 index 00000000000..13b82dd658c --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/model_regeneratekeyparameters.go @@ -0,0 +1,8 @@ +package signalr + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegenerateKeyParameters struct { + KeyType *KeyType `json:"keyType,omitempty"` +} diff --git a/resource-manager/signalr/2024-03-01/signalr/model_replica.go b/resource-manager/signalr/2024-03-01/signalr/model_replica.go new file mode 100644 index 00000000000..5471a9493ea --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/model_replica.go @@ -0,0 +1,19 @@ +package signalr + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Replica struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *ReplicaProperties `json:"properties,omitempty"` + Sku *ResourceSku `json:"sku,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/signalr/2024-03-01/signalr/model_replicaproperties.go b/resource-manager/signalr/2024-03-01/signalr/model_replicaproperties.go new file mode 100644 index 00000000000..f23ca8c3d72 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/model_replicaproperties.go @@ -0,0 +1,10 @@ +package signalr + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicaProperties struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RegionEndpointEnabled *string `json:"regionEndpointEnabled,omitempty"` + ResourceStopped *string `json:"resourceStopped,omitempty"` +} diff --git a/resource-manager/signalr/2024-03-01/signalr/model_resourcelogcategory.go b/resource-manager/signalr/2024-03-01/signalr/model_resourcelogcategory.go new file mode 100644 index 00000000000..d43e44612c0 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/model_resourcelogcategory.go @@ -0,0 +1,9 @@ +package signalr + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceLogCategory struct { + Enabled *string `json:"enabled,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/signalr/2024-03-01/signalr/model_resourcelogconfiguration.go b/resource-manager/signalr/2024-03-01/signalr/model_resourcelogconfiguration.go new file mode 100644 index 00000000000..34bfdaaa1e4 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/model_resourcelogconfiguration.go @@ -0,0 +1,8 @@ +package signalr + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceLogConfiguration struct { + Categories *[]ResourceLogCategory `json:"categories,omitempty"` +} diff --git a/resource-manager/signalr/2024-03-01/signalr/model_resourcereference.go b/resource-manager/signalr/2024-03-01/signalr/model_resourcereference.go new file mode 100644 index 00000000000..7a2971d96a8 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/model_resourcereference.go @@ -0,0 +1,8 @@ +package signalr + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceReference struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/signalr/2024-03-01/signalr/model_resourcesku.go b/resource-manager/signalr/2024-03-01/signalr/model_resourcesku.go new file mode 100644 index 00000000000..e05ec7fcdc7 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/model_resourcesku.go @@ -0,0 +1,12 @@ +package signalr + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceSku struct { + Capacity *int64 `json:"capacity,omitempty"` + Family *string `json:"family,omitempty"` + Name string `json:"name"` + Size *string `json:"size,omitempty"` + Tier *SignalRSkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/signalr/2024-03-01/signalr/model_serverlesssettings.go b/resource-manager/signalr/2024-03-01/signalr/model_serverlesssettings.go new file mode 100644 index 00000000000..0075693e2e5 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/model_serverlesssettings.go @@ -0,0 +1,8 @@ +package signalr + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServerlessSettings struct { + ConnectionTimeoutInSeconds *int64 `json:"connectionTimeoutInSeconds,omitempty"` +} diff --git a/resource-manager/signalr/2024-03-01/signalr/model_serverlessupstreamsettings.go b/resource-manager/signalr/2024-03-01/signalr/model_serverlessupstreamsettings.go new file mode 100644 index 00000000000..7248ea8446b --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/model_serverlessupstreamsettings.go @@ -0,0 +1,8 @@ +package signalr + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServerlessUpstreamSettings struct { + Templates *[]UpstreamTemplate `json:"templates,omitempty"` +} diff --git a/resource-manager/signalr/2024-03-01/signalr/model_shareableprivatelinkresourceproperties.go b/resource-manager/signalr/2024-03-01/signalr/model_shareableprivatelinkresourceproperties.go new file mode 100644 index 00000000000..acc48625575 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/model_shareableprivatelinkresourceproperties.go @@ -0,0 +1,10 @@ +package signalr + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ShareablePrivateLinkResourceProperties struct { + Description *string `json:"description,omitempty"` + GroupId *string `json:"groupId,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/signalr/2024-03-01/signalr/model_shareableprivatelinkresourcetype.go b/resource-manager/signalr/2024-03-01/signalr/model_shareableprivatelinkresourcetype.go new file mode 100644 index 00000000000..18407d00fe3 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/model_shareableprivatelinkresourcetype.go @@ -0,0 +1,9 @@ +package signalr + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ShareablePrivateLinkResourceType struct { + Name *string `json:"name,omitempty"` + Properties *ShareablePrivateLinkResourceProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/signalr/2024-03-01/signalr/model_sharedprivatelinkresource.go b/resource-manager/signalr/2024-03-01/signalr/model_sharedprivatelinkresource.go new file mode 100644 index 00000000000..6c5aab1998b --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/model_sharedprivatelinkresource.go @@ -0,0 +1,16 @@ +package signalr + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SharedPrivateLinkResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SharedPrivateLinkResourceProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/signalr/2024-03-01/signalr/model_sharedprivatelinkresourceproperties.go b/resource-manager/signalr/2024-03-01/signalr/model_sharedprivatelinkresourceproperties.go new file mode 100644 index 00000000000..425fbc50526 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/model_sharedprivatelinkresourceproperties.go @@ -0,0 +1,12 @@ +package signalr + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SharedPrivateLinkResourceProperties struct { + GroupId string `json:"groupId"` + PrivateLinkResourceId string `json:"privateLinkResourceId"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RequestMessage *string `json:"requestMessage,omitempty"` + Status *SharedPrivateLinkResourceStatus `json:"status,omitempty"` +} diff --git a/resource-manager/signalr/2024-03-01/signalr/model_signalrcorssettings.go b/resource-manager/signalr/2024-03-01/signalr/model_signalrcorssettings.go new file mode 100644 index 00000000000..aa046d4b367 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/model_signalrcorssettings.go @@ -0,0 +1,8 @@ +package signalr + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SignalRCorsSettings struct { + AllowedOrigins *[]string `json:"allowedOrigins,omitempty"` +} diff --git a/resource-manager/signalr/2024-03-01/signalr/model_signalrfeature.go b/resource-manager/signalr/2024-03-01/signalr/model_signalrfeature.go new file mode 100644 index 00000000000..506f4ec0e67 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/model_signalrfeature.go @@ -0,0 +1,10 @@ +package signalr + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SignalRFeature struct { + Flag FeatureFlags `json:"flag"` + Properties *map[string]string `json:"properties,omitempty"` + Value string `json:"value"` +} diff --git a/resource-manager/signalr/2024-03-01/signalr/model_signalrkeys.go b/resource-manager/signalr/2024-03-01/signalr/model_signalrkeys.go new file mode 100644 index 00000000000..70821e28a59 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/model_signalrkeys.go @@ -0,0 +1,11 @@ +package signalr + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SignalRKeys struct { + PrimaryConnectionString *string `json:"primaryConnectionString,omitempty"` + PrimaryKey *string `json:"primaryKey,omitempty"` + SecondaryConnectionString *string `json:"secondaryConnectionString,omitempty"` + SecondaryKey *string `json:"secondaryKey,omitempty"` +} diff --git a/resource-manager/signalr/2024-03-01/signalr/model_signalrnetworkacls.go b/resource-manager/signalr/2024-03-01/signalr/model_signalrnetworkacls.go new file mode 100644 index 00000000000..0ace3a55deb --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/model_signalrnetworkacls.go @@ -0,0 +1,11 @@ +package signalr + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SignalRNetworkACLs struct { + DefaultAction *ACLAction `json:"defaultAction,omitempty"` + IPRules *[]IPRule `json:"ipRules,omitempty"` + PrivateEndpoints *[]PrivateEndpointACL `json:"privateEndpoints,omitempty"` + PublicNetwork *NetworkACL `json:"publicNetwork,omitempty"` +} diff --git a/resource-manager/signalr/2024-03-01/signalr/model_signalrproperties.go b/resource-manager/signalr/2024-03-01/signalr/model_signalrproperties.go new file mode 100644 index 00000000000..b17d8941b59 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/model_signalrproperties.go @@ -0,0 +1,29 @@ +package signalr + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SignalRProperties struct { + Cors *SignalRCorsSettings `json:"cors,omitempty"` + DisableAadAuth *bool `json:"disableAadAuth,omitempty"` + DisableLocalAuth *bool `json:"disableLocalAuth,omitempty"` + ExternalIP *string `json:"externalIP,omitempty"` + Features *[]SignalRFeature `json:"features,omitempty"` + HostName *string `json:"hostName,omitempty"` + HostNamePrefix *string `json:"hostNamePrefix,omitempty"` + LiveTraceConfiguration *LiveTraceConfiguration `json:"liveTraceConfiguration,omitempty"` + NetworkACLs *SignalRNetworkACLs `json:"networkACLs,omitempty"` + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicNetworkAccess *string `json:"publicNetworkAccess,omitempty"` + PublicPort *int64 `json:"publicPort,omitempty"` + RegionEndpointEnabled *string `json:"regionEndpointEnabled,omitempty"` + ResourceLogConfiguration *ResourceLogConfiguration `json:"resourceLogConfiguration,omitempty"` + ResourceStopped *string `json:"resourceStopped,omitempty"` + ServerPort *int64 `json:"serverPort,omitempty"` + Serverless *ServerlessSettings `json:"serverless,omitempty"` + SharedPrivateLinkResources *[]SharedPrivateLinkResource `json:"sharedPrivateLinkResources,omitempty"` + Tls *SignalRTlsSettings `json:"tls,omitempty"` + Upstream *ServerlessUpstreamSettings `json:"upstream,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/signalr/2024-03-01/signalr/model_signalrresource.go b/resource-manager/signalr/2024-03-01/signalr/model_signalrresource.go new file mode 100644 index 00000000000..1b763e3a44c --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/model_signalrresource.go @@ -0,0 +1,22 @@ +package signalr + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SignalRResource struct { + Id *string `json:"id,omitempty"` + Identity *identity.SystemOrUserAssignedMap `json:"identity,omitempty"` + Kind *ServiceKind `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *SignalRProperties `json:"properties,omitempty"` + Sku *ResourceSku `json:"sku,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/signalr/2024-03-01/signalr/model_signalrtlssettings.go b/resource-manager/signalr/2024-03-01/signalr/model_signalrtlssettings.go new file mode 100644 index 00000000000..94dbfbda5e6 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/model_signalrtlssettings.go @@ -0,0 +1,8 @@ +package signalr + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SignalRTlsSettings struct { + ClientCertEnabled *bool `json:"clientCertEnabled,omitempty"` +} diff --git a/resource-manager/signalr/2024-03-01/signalr/model_signalrusage.go b/resource-manager/signalr/2024-03-01/signalr/model_signalrusage.go new file mode 100644 index 00000000000..2bd863e5aff --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/model_signalrusage.go @@ -0,0 +1,12 @@ +package signalr + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SignalRUsage struct { + CurrentValue *int64 `json:"currentValue,omitempty"` + Id *string `json:"id,omitempty"` + Limit *int64 `json:"limit,omitempty"` + Name *SignalRUsageName `json:"name,omitempty"` + Unit *string `json:"unit,omitempty"` +} diff --git a/resource-manager/signalr/2024-03-01/signalr/model_signalrusagename.go b/resource-manager/signalr/2024-03-01/signalr/model_signalrusagename.go new file mode 100644 index 00000000000..f9a475cc7c1 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/model_signalrusagename.go @@ -0,0 +1,9 @@ +package signalr + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SignalRUsageName struct { + LocalizedValue *string `json:"localizedValue,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/signalr/2024-03-01/signalr/model_sku.go b/resource-manager/signalr/2024-03-01/signalr/model_sku.go new file mode 100644 index 00000000000..0b2efca5d62 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/model_sku.go @@ -0,0 +1,10 @@ +package signalr + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Sku struct { + Capacity *SkuCapacity `json:"capacity,omitempty"` + ResourceType *string `json:"resourceType,omitempty"` + Sku *ResourceSku `json:"sku,omitempty"` +} diff --git a/resource-manager/signalr/2024-03-01/signalr/model_skucapacity.go b/resource-manager/signalr/2024-03-01/signalr/model_skucapacity.go new file mode 100644 index 00000000000..3ac0d557740 --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/model_skucapacity.go @@ -0,0 +1,12 @@ +package signalr + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SkuCapacity struct { + AllowedValues *[]int64 `json:"allowedValues,omitempty"` + Default *int64 `json:"default,omitempty"` + Maximum *int64 `json:"maximum,omitempty"` + Minimum *int64 `json:"minimum,omitempty"` + ScaleType *ScaleType `json:"scaleType,omitempty"` +} diff --git a/resource-manager/signalr/2024-03-01/signalr/model_upstreamauthsettings.go b/resource-manager/signalr/2024-03-01/signalr/model_upstreamauthsettings.go new file mode 100644 index 00000000000..e5418bfaecf --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/model_upstreamauthsettings.go @@ -0,0 +1,9 @@ +package signalr + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpstreamAuthSettings struct { + ManagedIdentity *ManagedIdentitySettings `json:"managedIdentity,omitempty"` + Type *UpstreamAuthType `json:"type,omitempty"` +} diff --git a/resource-manager/signalr/2024-03-01/signalr/model_upstreamtemplate.go b/resource-manager/signalr/2024-03-01/signalr/model_upstreamtemplate.go new file mode 100644 index 00000000000..476b1dd7cde --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/model_upstreamtemplate.go @@ -0,0 +1,12 @@ +package signalr + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpstreamTemplate struct { + Auth *UpstreamAuthSettings `json:"auth,omitempty"` + CategoryPattern *string `json:"categoryPattern,omitempty"` + EventPattern *string `json:"eventPattern,omitempty"` + HubPattern *string `json:"hubPattern,omitempty"` + UrlTemplate string `json:"urlTemplate"` +} diff --git a/resource-manager/signalr/2024-03-01/signalr/predicates.go b/resource-manager/signalr/2024-03-01/signalr/predicates.go new file mode 100644 index 00000000000..84aad69eaba --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/predicates.go @@ -0,0 +1,216 @@ +package signalr + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomCertificateOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p CustomCertificateOperationPredicate) Matches(input CustomCertificate) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type CustomDomainOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p CustomDomainOperationPredicate) Matches(input CustomDomain) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type PrivateEndpointConnectionOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p PrivateEndpointConnectionOperationPredicate) Matches(input PrivateEndpointConnection) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type PrivateLinkResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p PrivateLinkResourceOperationPredicate) Matches(input PrivateLinkResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type ReplicaOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p ReplicaOperationPredicate) Matches(input Replica) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type SharedPrivateLinkResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p SharedPrivateLinkResourceOperationPredicate) Matches(input SharedPrivateLinkResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type SignalRResourceOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p SignalRResourceOperationPredicate) Matches(input SignalRResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type SignalRUsageOperationPredicate struct { + CurrentValue *int64 + Id *string + Limit *int64 + Unit *string +} + +func (p SignalRUsageOperationPredicate) Matches(input SignalRUsage) bool { + + if p.CurrentValue != nil && (input.CurrentValue == nil || *p.CurrentValue != *input.CurrentValue) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Limit != nil && (input.Limit == nil || *p.Limit != *input.Limit) { + return false + } + + if p.Unit != nil && (input.Unit == nil || *p.Unit != *input.Unit) { + return false + } + + return true +} + +type SkuOperationPredicate struct { + ResourceType *string +} + +func (p SkuOperationPredicate) Matches(input Sku) bool { + + if p.ResourceType != nil && (input.ResourceType == nil || *p.ResourceType != *input.ResourceType) { + return false + } + + return true +} diff --git a/resource-manager/signalr/2024-03-01/signalr/version.go b/resource-manager/signalr/2024-03-01/signalr/version.go new file mode 100644 index 00000000000..fcd7f47d8cf --- /dev/null +++ b/resource-manager/signalr/2024-03-01/signalr/version.go @@ -0,0 +1,12 @@ +package signalr + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-03-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/signalr/%s", defaultApiVersion) +} diff --git a/resource-manager/webpubsub/2024-03-01/client.go b/resource-manager/webpubsub/2024-03-01/client.go new file mode 100644 index 00000000000..19715df27cf --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/client.go @@ -0,0 +1,28 @@ +package v2024_03_01 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/resource-manager/webpubsub/2024-03-01/webpubsub" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + WebPubSub *webpubsub.WebPubSubClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + webPubSubClient, err := webpubsub.NewWebPubSubClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building WebPubSub client: %+v", err) + } + configureFunc(webPubSubClient.Client) + + return &Client{ + WebPubSub: webPubSubClient, + }, nil +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/README.md b/resource-manager/webpubsub/2024-03-01/webpubsub/README.md new file mode 100644 index 00000000000..56b81535bf7 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/README.md @@ -0,0 +1,714 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/webpubsub/2024-03-01/webpubsub` Documentation + +The `webpubsub` SDK allows for interaction with the Azure Resource Manager Service `webpubsub` (API Version `2024-03-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/webpubsub/2024-03-01/webpubsub" +``` + + +### Client Initialization + +```go +client := webpubsub.NewWebPubSubClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `WebPubSubClient.CheckNameAvailability` + +```go +ctx := context.TODO() +id := webpubsub.NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + +payload := webpubsub.NameAvailabilityParameters{ + // ... +} + + +read, err := client.CheckNameAvailability(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebPubSubClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := webpubsub.NewWebPubSubID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue") + +payload := webpubsub.WebPubSubResource{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebPubSubClient.CustomCertificatesCreateOrUpdate` + +```go +ctx := context.TODO() +id := webpubsub.NewCustomCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue", "customCertificateValue") + +payload := webpubsub.CustomCertificate{ + // ... +} + + +if err := client.CustomCertificatesCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebPubSubClient.CustomCertificatesDelete` + +```go +ctx := context.TODO() +id := webpubsub.NewCustomCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue", "customCertificateValue") + +read, err := client.CustomCertificatesDelete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebPubSubClient.CustomCertificatesGet` + +```go +ctx := context.TODO() +id := webpubsub.NewCustomCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue", "customCertificateValue") + +read, err := client.CustomCertificatesGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebPubSubClient.CustomCertificatesList` + +```go +ctx := context.TODO() +id := webpubsub.NewWebPubSubID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue") + +// alternatively `client.CustomCertificatesList(ctx, id)` can be used to do batched pagination +items, err := client.CustomCertificatesListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebPubSubClient.CustomDomainsCreateOrUpdate` + +```go +ctx := context.TODO() +id := webpubsub.NewCustomDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue", "customDomainValue") + +payload := webpubsub.CustomDomain{ + // ... +} + + +if err := client.CustomDomainsCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebPubSubClient.CustomDomainsDelete` + +```go +ctx := context.TODO() +id := webpubsub.NewCustomDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue", "customDomainValue") + +if err := client.CustomDomainsDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebPubSubClient.CustomDomainsGet` + +```go +ctx := context.TODO() +id := webpubsub.NewCustomDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue", "customDomainValue") + +read, err := client.CustomDomainsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebPubSubClient.CustomDomainsList` + +```go +ctx := context.TODO() +id := webpubsub.NewWebPubSubID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue") + +// alternatively `client.CustomDomainsList(ctx, id)` can be used to do batched pagination +items, err := client.CustomDomainsListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebPubSubClient.Delete` + +```go +ctx := context.TODO() +id := webpubsub.NewWebPubSubID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebPubSubClient.Get` + +```go +ctx := context.TODO() +id := webpubsub.NewWebPubSubID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue") + +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: `WebPubSubClient.HubsCreateOrUpdate` + +```go +ctx := context.TODO() +id := webpubsub.NewHubID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue", "hubValue") + +payload := webpubsub.WebPubSubHub{ + // ... +} + + +if err := client.HubsCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebPubSubClient.HubsDelete` + +```go +ctx := context.TODO() +id := webpubsub.NewHubID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue", "hubValue") + +if err := client.HubsDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebPubSubClient.HubsGet` + +```go +ctx := context.TODO() +id := webpubsub.NewHubID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue", "hubValue") + +read, err := client.HubsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebPubSubClient.HubsList` + +```go +ctx := context.TODO() +id := webpubsub.NewWebPubSubID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue") + +// alternatively `client.HubsList(ctx, id)` can be used to do batched pagination +items, err := client.HubsListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebPubSubClient.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: `WebPubSubClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebPubSubClient.ListKeys` + +```go +ctx := context.TODO() +id := webpubsub.NewWebPubSubID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue") + +read, err := client.ListKeys(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebPubSubClient.ListReplicaSkus` + +```go +ctx := context.TODO() +id := webpubsub.NewReplicaID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue", "replicaValue") + +// alternatively `client.ListReplicaSkus(ctx, id)` can be used to do batched pagination +items, err := client.ListReplicaSkusComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebPubSubClient.ListSkus` + +```go +ctx := context.TODO() +id := webpubsub.NewWebPubSubID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue") + +// alternatively `client.ListSkus(ctx, id)` can be used to do batched pagination +items, err := client.ListSkusComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebPubSubClient.PrivateEndpointConnectionsDelete` + +```go +ctx := context.TODO() +id := webpubsub.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue", "privateEndpointConnectionValue") + +if err := client.PrivateEndpointConnectionsDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebPubSubClient.PrivateEndpointConnectionsGet` + +```go +ctx := context.TODO() +id := webpubsub.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue", "privateEndpointConnectionValue") + +read, err := client.PrivateEndpointConnectionsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebPubSubClient.PrivateEndpointConnectionsList` + +```go +ctx := context.TODO() +id := webpubsub.NewWebPubSubID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue") + +// alternatively `client.PrivateEndpointConnectionsList(ctx, id)` can be used to do batched pagination +items, err := client.PrivateEndpointConnectionsListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebPubSubClient.PrivateEndpointConnectionsUpdate` + +```go +ctx := context.TODO() +id := webpubsub.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue", "privateEndpointConnectionValue") + +payload := webpubsub.PrivateEndpointConnection{ + // ... +} + + +read, err := client.PrivateEndpointConnectionsUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebPubSubClient.PrivateLinkResourcesList` + +```go +ctx := context.TODO() +id := webpubsub.NewWebPubSubID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue") + +// alternatively `client.PrivateLinkResourcesList(ctx, id)` can be used to do batched pagination +items, err := client.PrivateLinkResourcesListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebPubSubClient.RegenerateKey` + +```go +ctx := context.TODO() +id := webpubsub.NewWebPubSubID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue") + +payload := webpubsub.RegenerateKeyParameters{ + // ... +} + + +if err := client.RegenerateKeyThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebPubSubClient.ReplicaSharedPrivateLinkResourcesCreateOrUpdate` + +```go +ctx := context.TODO() +id := webpubsub.NewReplicaSharedPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue", "replicaValue", "sharedPrivateLinkResourceValue") + +payload := webpubsub.SharedPrivateLinkResource{ + // ... +} + + +if err := client.ReplicaSharedPrivateLinkResourcesCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebPubSubClient.ReplicaSharedPrivateLinkResourcesGet` + +```go +ctx := context.TODO() +id := webpubsub.NewReplicaSharedPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue", "replicaValue", "sharedPrivateLinkResourceValue") + +read, err := client.ReplicaSharedPrivateLinkResourcesGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebPubSubClient.ReplicaSharedPrivateLinkResourcesList` + +```go +ctx := context.TODO() +id := webpubsub.NewReplicaID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue", "replicaValue") + +// alternatively `client.ReplicaSharedPrivateLinkResourcesList(ctx, id)` can be used to do batched pagination +items, err := client.ReplicaSharedPrivateLinkResourcesListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebPubSubClient.ReplicasCreateOrUpdate` + +```go +ctx := context.TODO() +id := webpubsub.NewReplicaID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue", "replicaValue") + +payload := webpubsub.Replica{ + // ... +} + + +if err := client.ReplicasCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebPubSubClient.ReplicasDelete` + +```go +ctx := context.TODO() +id := webpubsub.NewReplicaID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue", "replicaValue") + +read, err := client.ReplicasDelete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebPubSubClient.ReplicasGet` + +```go +ctx := context.TODO() +id := webpubsub.NewReplicaID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue", "replicaValue") + +read, err := client.ReplicasGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebPubSubClient.ReplicasList` + +```go +ctx := context.TODO() +id := webpubsub.NewWebPubSubID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue") + +// alternatively `client.ReplicasList(ctx, id)` can be used to do batched pagination +items, err := client.ReplicasListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebPubSubClient.ReplicasRestart` + +```go +ctx := context.TODO() +id := webpubsub.NewReplicaID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue", "replicaValue") + +if err := client.ReplicasRestartThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebPubSubClient.ReplicasUpdate` + +```go +ctx := context.TODO() +id := webpubsub.NewReplicaID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue", "replicaValue") + +payload := webpubsub.Replica{ + // ... +} + + +if err := client.ReplicasUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebPubSubClient.Restart` + +```go +ctx := context.TODO() +id := webpubsub.NewWebPubSubID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue") + +if err := client.RestartThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebPubSubClient.SharedPrivateLinkResourcesCreateOrUpdate` + +```go +ctx := context.TODO() +id := webpubsub.NewSharedPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue", "sharedPrivateLinkResourceValue") + +payload := webpubsub.SharedPrivateLinkResource{ + // ... +} + + +if err := client.SharedPrivateLinkResourcesCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebPubSubClient.SharedPrivateLinkResourcesDelete` + +```go +ctx := context.TODO() +id := webpubsub.NewSharedPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue", "sharedPrivateLinkResourceValue") + +if err := client.SharedPrivateLinkResourcesDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebPubSubClient.SharedPrivateLinkResourcesGet` + +```go +ctx := context.TODO() +id := webpubsub.NewSharedPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue", "sharedPrivateLinkResourceValue") + +read, err := client.SharedPrivateLinkResourcesGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebPubSubClient.SharedPrivateLinkResourcesList` + +```go +ctx := context.TODO() +id := webpubsub.NewWebPubSubID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue") + +// alternatively `client.SharedPrivateLinkResourcesList(ctx, id)` can be used to do batched pagination +items, err := client.SharedPrivateLinkResourcesListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebPubSubClient.Update` + +```go +ctx := context.TODO() +id := webpubsub.NewWebPubSubID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue") + +payload := webpubsub.WebPubSubResource{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebPubSubClient.UsagesList` + +```go +ctx := context.TODO() +id := webpubsub.NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + +// alternatively `client.UsagesList(ctx, id)` can be used to do batched pagination +items, err := client.UsagesListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/client.go b/resource-manager/webpubsub/2024-03-01/webpubsub/client.go new file mode 100644 index 00000000000..aaf69b3d112 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/client.go @@ -0,0 +1,26 @@ +package webpubsub + +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 WebPubSubClient struct { + Client *resourcemanager.Client +} + +func NewWebPubSubClientWithBaseURI(sdkApi sdkEnv.Api) (*WebPubSubClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "webpubsub", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating WebPubSubClient: %+v", err) + } + + return &WebPubSubClient{ + Client: client, + }, nil +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/constants.go b/resource-manager/webpubsub/2024-03-01/webpubsub/constants.go new file mode 100644 index 00000000000..ee93c30d095 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/constants.go @@ -0,0 +1,550 @@ +package webpubsub + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ACLAction string + +const ( + ACLActionAllow ACLAction = "Allow" + ACLActionDeny ACLAction = "Deny" +) + +func PossibleValuesForACLAction() []string { + return []string{ + string(ACLActionAllow), + string(ACLActionDeny), + } +} + +func (s *ACLAction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseACLAction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseACLAction(input string) (*ACLAction, error) { + vals := map[string]ACLAction{ + "allow": ACLActionAllow, + "deny": ACLActionDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ACLAction(input) + return &out, nil +} + +type EventListenerEndpointDiscriminator string + +const ( + EventListenerEndpointDiscriminatorEventHub EventListenerEndpointDiscriminator = "EventHub" +) + +func PossibleValuesForEventListenerEndpointDiscriminator() []string { + return []string{ + string(EventListenerEndpointDiscriminatorEventHub), + } +} + +func (s *EventListenerEndpointDiscriminator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEventListenerEndpointDiscriminator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEventListenerEndpointDiscriminator(input string) (*EventListenerEndpointDiscriminator, error) { + vals := map[string]EventListenerEndpointDiscriminator{ + "eventhub": EventListenerEndpointDiscriminatorEventHub, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EventListenerEndpointDiscriminator(input) + return &out, nil +} + +type EventListenerFilterDiscriminator string + +const ( + EventListenerFilterDiscriminatorEventName EventListenerFilterDiscriminator = "EventName" +) + +func PossibleValuesForEventListenerFilterDiscriminator() []string { + return []string{ + string(EventListenerFilterDiscriminatorEventName), + } +} + +func (s *EventListenerFilterDiscriminator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEventListenerFilterDiscriminator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEventListenerFilterDiscriminator(input string) (*EventListenerFilterDiscriminator, error) { + vals := map[string]EventListenerFilterDiscriminator{ + "eventname": EventListenerFilterDiscriminatorEventName, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EventListenerFilterDiscriminator(input) + return &out, nil +} + +type KeyType string + +const ( + KeyTypePrimary KeyType = "Primary" + KeyTypeSalt KeyType = "Salt" + KeyTypeSecondary KeyType = "Secondary" +) + +func PossibleValuesForKeyType() []string { + return []string{ + string(KeyTypePrimary), + string(KeyTypeSalt), + string(KeyTypeSecondary), + } +} + +func (s *KeyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKeyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKeyType(input string) (*KeyType, error) { + vals := map[string]KeyType{ + "primary": KeyTypePrimary, + "salt": KeyTypeSalt, + "secondary": KeyTypeSecondary, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KeyType(input) + return &out, nil +} + +type 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 ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateMoving ProvisioningState = "Moving" + ProvisioningStateRunning ProvisioningState = "Running" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUnknown ProvisioningState = "Unknown" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateCreating), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateMoving), + string(ProvisioningStateRunning), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUnknown), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "creating": ProvisioningStateCreating, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "moving": ProvisioningStateMoving, + "running": ProvisioningStateRunning, + "succeeded": ProvisioningStateSucceeded, + "unknown": ProvisioningStateUnknown, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type ScaleType string + +const ( + ScaleTypeAutomatic ScaleType = "Automatic" + ScaleTypeManual ScaleType = "Manual" + ScaleTypeNone ScaleType = "None" +) + +func PossibleValuesForScaleType() []string { + return []string{ + string(ScaleTypeAutomatic), + string(ScaleTypeManual), + string(ScaleTypeNone), + } +} + +func (s *ScaleType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScaleType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScaleType(input string) (*ScaleType, error) { + vals := map[string]ScaleType{ + "automatic": ScaleTypeAutomatic, + "manual": ScaleTypeManual, + "none": ScaleTypeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScaleType(input) + return &out, nil +} + +type ServiceKind string + +const ( + ServiceKindSocketIO ServiceKind = "SocketIO" + ServiceKindWebPubSub ServiceKind = "WebPubSub" +) + +func PossibleValuesForServiceKind() []string { + return []string{ + string(ServiceKindSocketIO), + string(ServiceKindWebPubSub), + } +} + +func (s *ServiceKind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServiceKind(input string) (*ServiceKind, error) { + vals := map[string]ServiceKind{ + "socketio": ServiceKindSocketIO, + "webpubsub": ServiceKindWebPubSub, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServiceKind(input) + return &out, nil +} + +type SharedPrivateLinkResourceStatus string + +const ( + SharedPrivateLinkResourceStatusApproved SharedPrivateLinkResourceStatus = "Approved" + SharedPrivateLinkResourceStatusDisconnected SharedPrivateLinkResourceStatus = "Disconnected" + SharedPrivateLinkResourceStatusPending SharedPrivateLinkResourceStatus = "Pending" + SharedPrivateLinkResourceStatusRejected SharedPrivateLinkResourceStatus = "Rejected" + SharedPrivateLinkResourceStatusTimeout SharedPrivateLinkResourceStatus = "Timeout" +) + +func PossibleValuesForSharedPrivateLinkResourceStatus() []string { + return []string{ + string(SharedPrivateLinkResourceStatusApproved), + string(SharedPrivateLinkResourceStatusDisconnected), + string(SharedPrivateLinkResourceStatusPending), + string(SharedPrivateLinkResourceStatusRejected), + string(SharedPrivateLinkResourceStatusTimeout), + } +} + +func (s *SharedPrivateLinkResourceStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSharedPrivateLinkResourceStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSharedPrivateLinkResourceStatus(input string) (*SharedPrivateLinkResourceStatus, error) { + vals := map[string]SharedPrivateLinkResourceStatus{ + "approved": SharedPrivateLinkResourceStatusApproved, + "disconnected": SharedPrivateLinkResourceStatusDisconnected, + "pending": SharedPrivateLinkResourceStatusPending, + "rejected": SharedPrivateLinkResourceStatusRejected, + "timeout": SharedPrivateLinkResourceStatusTimeout, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SharedPrivateLinkResourceStatus(input) + return &out, nil +} + +type UpstreamAuthType string + +const ( + UpstreamAuthTypeManagedIdentity UpstreamAuthType = "ManagedIdentity" + UpstreamAuthTypeNone UpstreamAuthType = "None" +) + +func PossibleValuesForUpstreamAuthType() []string { + return []string{ + string(UpstreamAuthTypeManagedIdentity), + string(UpstreamAuthTypeNone), + } +} + +func (s *UpstreamAuthType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUpstreamAuthType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUpstreamAuthType(input string) (*UpstreamAuthType, error) { + vals := map[string]UpstreamAuthType{ + "managedidentity": UpstreamAuthTypeManagedIdentity, + "none": UpstreamAuthTypeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UpstreamAuthType(input) + return &out, nil +} + +type WebPubSubRequestType string + +const ( + WebPubSubRequestTypeClientConnection WebPubSubRequestType = "ClientConnection" + WebPubSubRequestTypeRESTAPI WebPubSubRequestType = "RESTAPI" + WebPubSubRequestTypeServerConnection WebPubSubRequestType = "ServerConnection" + WebPubSubRequestTypeTrace WebPubSubRequestType = "Trace" +) + +func PossibleValuesForWebPubSubRequestType() []string { + return []string{ + string(WebPubSubRequestTypeClientConnection), + string(WebPubSubRequestTypeRESTAPI), + string(WebPubSubRequestTypeServerConnection), + string(WebPubSubRequestTypeTrace), + } +} + +func (s *WebPubSubRequestType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWebPubSubRequestType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWebPubSubRequestType(input string) (*WebPubSubRequestType, error) { + vals := map[string]WebPubSubRequestType{ + "clientconnection": WebPubSubRequestTypeClientConnection, + "restapi": WebPubSubRequestTypeRESTAPI, + "serverconnection": WebPubSubRequestTypeServerConnection, + "trace": WebPubSubRequestTypeTrace, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WebPubSubRequestType(input) + return &out, nil +} + +type WebPubSubSkuTier string + +const ( + WebPubSubSkuTierBasic WebPubSubSkuTier = "Basic" + WebPubSubSkuTierFree WebPubSubSkuTier = "Free" + WebPubSubSkuTierPremium WebPubSubSkuTier = "Premium" + WebPubSubSkuTierStandard WebPubSubSkuTier = "Standard" +) + +func PossibleValuesForWebPubSubSkuTier() []string { + return []string{ + string(WebPubSubSkuTierBasic), + string(WebPubSubSkuTierFree), + string(WebPubSubSkuTierPremium), + string(WebPubSubSkuTierStandard), + } +} + +func (s *WebPubSubSkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWebPubSubSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWebPubSubSkuTier(input string) (*WebPubSubSkuTier, error) { + vals := map[string]WebPubSubSkuTier{ + "basic": WebPubSubSkuTierBasic, + "free": WebPubSubSkuTierFree, + "premium": WebPubSubSkuTierPremium, + "standard": WebPubSubSkuTierStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WebPubSubSkuTier(input) + return &out, nil +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/id_customcertificate.go b/resource-manager/webpubsub/2024-03-01/webpubsub/id_customcertificate.go new file mode 100644 index 00000000000..e24c9265f45 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/id_customcertificate.go @@ -0,0 +1,139 @@ +package webpubsub + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&CustomCertificateId{}) +} + +var _ resourceids.ResourceId = &CustomCertificateId{} + +// CustomCertificateId is a struct representing the Resource ID for a Custom Certificate +type CustomCertificateId struct { + SubscriptionId string + ResourceGroupName string + WebPubSubName string + CustomCertificateName string +} + +// NewCustomCertificateID returns a new CustomCertificateId struct +func NewCustomCertificateID(subscriptionId string, resourceGroupName string, webPubSubName string, customCertificateName string) CustomCertificateId { + return CustomCertificateId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WebPubSubName: webPubSubName, + CustomCertificateName: customCertificateName, + } +} + +// ParseCustomCertificateID parses 'input' into a CustomCertificateId +func ParseCustomCertificateID(input string) (*CustomCertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&CustomCertificateId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CustomCertificateId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCustomCertificateIDInsensitively parses 'input' case-insensitively into a CustomCertificateId +// note: this method should only be used for API response data and not user input +func ParseCustomCertificateIDInsensitively(input string) (*CustomCertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&CustomCertificateId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CustomCertificateId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CustomCertificateId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WebPubSubName, ok = input.Parsed["webPubSubName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "webPubSubName", input) + } + + if id.CustomCertificateName, ok = input.Parsed["customCertificateName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "customCertificateName", input) + } + + return nil +} + +// ValidateCustomCertificateID checks that 'input' can be parsed as a Custom Certificate ID +func ValidateCustomCertificateID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseCustomCertificateID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Custom Certificate ID +func (id CustomCertificateId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.SignalRService/webPubSub/%s/customCertificates/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WebPubSubName, id.CustomCertificateName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Custom Certificate ID +func (id CustomCertificateId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftSignalRService", "Microsoft.SignalRService", "Microsoft.SignalRService"), + resourceids.StaticSegment("staticWebPubSub", "webPubSub", "webPubSub"), + resourceids.UserSpecifiedSegment("webPubSubName", "webPubSubValue"), + resourceids.StaticSegment("staticCustomCertificates", "customCertificates", "customCertificates"), + resourceids.UserSpecifiedSegment("customCertificateName", "customCertificateValue"), + } +} + +// String returns a human-readable description of this Custom Certificate ID +func (id CustomCertificateId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Web Pub Sub Name: %q", id.WebPubSubName), + fmt.Sprintf("Custom Certificate Name: %q", id.CustomCertificateName), + } + return fmt.Sprintf("Custom Certificate (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/id_customcertificate_test.go b/resource-manager/webpubsub/2024-03-01/webpubsub/id_customcertificate_test.go new file mode 100644 index 00000000000..fd572bc81f6 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/id_customcertificate_test.go @@ -0,0 +1,327 @@ +package webpubsub + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &CustomCertificateId{} + +func TestNewCustomCertificateID(t *testing.T) { + id := NewCustomCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue", "customCertificateValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WebPubSubName != "webPubSubValue" { + t.Fatalf("Expected %q but got %q for Segment 'WebPubSubName'", id.WebPubSubName, "webPubSubValue") + } + + if id.CustomCertificateName != "customCertificateValue" { + t.Fatalf("Expected %q but got %q for Segment 'CustomCertificateName'", id.CustomCertificateName, "customCertificateValue") + } +} + +func TestFormatCustomCertificateID(t *testing.T) { + actual := NewCustomCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue", "customCertificateValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/customCertificates/customCertificateValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCustomCertificateID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CustomCertificateId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/customCertificates", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/customCertificates/customCertificateValue", + Expected: &CustomCertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WebPubSubName: "webPubSubValue", + CustomCertificateName: "customCertificateValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/customCertificates/customCertificateValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCustomCertificateID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WebPubSubName != v.Expected.WebPubSubName { + t.Fatalf("Expected %q but got %q for WebPubSubName", v.Expected.WebPubSubName, actual.WebPubSubName) + } + + if actual.CustomCertificateName != v.Expected.CustomCertificateName { + t.Fatalf("Expected %q but got %q for CustomCertificateName", v.Expected.CustomCertificateName, actual.CustomCertificateName) + } + + } +} + +func TestParseCustomCertificateIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CustomCertificateId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/wEbPuBsUb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/wEbPuBsUb/wEbPuBsUbVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/customCertificates", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/wEbPuBsUb/wEbPuBsUbVaLuE/cUsToMcErTiFiCaTeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/customCertificates/customCertificateValue", + Expected: &CustomCertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WebPubSubName: "webPubSubValue", + CustomCertificateName: "customCertificateValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/customCertificates/customCertificateValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/wEbPuBsUb/wEbPuBsUbVaLuE/cUsToMcErTiFiCaTeS/cUsToMcErTiFiCaTeVaLuE", + Expected: &CustomCertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WebPubSubName: "wEbPuBsUbVaLuE", + CustomCertificateName: "cUsToMcErTiFiCaTeVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/wEbPuBsUb/wEbPuBsUbVaLuE/cUsToMcErTiFiCaTeS/cUsToMcErTiFiCaTeVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCustomCertificateIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WebPubSubName != v.Expected.WebPubSubName { + t.Fatalf("Expected %q but got %q for WebPubSubName", v.Expected.WebPubSubName, actual.WebPubSubName) + } + + if actual.CustomCertificateName != v.Expected.CustomCertificateName { + t.Fatalf("Expected %q but got %q for CustomCertificateName", v.Expected.CustomCertificateName, actual.CustomCertificateName) + } + + } +} + +func TestSegmentsForCustomCertificateId(t *testing.T) { + segments := CustomCertificateId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CustomCertificateId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/id_customdomain.go b/resource-manager/webpubsub/2024-03-01/webpubsub/id_customdomain.go new file mode 100644 index 00000000000..6cf8f6ed5e1 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/id_customdomain.go @@ -0,0 +1,139 @@ +package webpubsub + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&CustomDomainId{}) +} + +var _ resourceids.ResourceId = &CustomDomainId{} + +// CustomDomainId is a struct representing the Resource ID for a Custom Domain +type CustomDomainId struct { + SubscriptionId string + ResourceGroupName string + WebPubSubName string + CustomDomainName string +} + +// NewCustomDomainID returns a new CustomDomainId struct +func NewCustomDomainID(subscriptionId string, resourceGroupName string, webPubSubName string, customDomainName string) CustomDomainId { + return CustomDomainId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WebPubSubName: webPubSubName, + CustomDomainName: customDomainName, + } +} + +// ParseCustomDomainID parses 'input' into a CustomDomainId +func ParseCustomDomainID(input string) (*CustomDomainId, error) { + parser := resourceids.NewParserFromResourceIdType(&CustomDomainId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CustomDomainId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCustomDomainIDInsensitively parses 'input' case-insensitively into a CustomDomainId +// note: this method should only be used for API response data and not user input +func ParseCustomDomainIDInsensitively(input string) (*CustomDomainId, error) { + parser := resourceids.NewParserFromResourceIdType(&CustomDomainId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CustomDomainId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CustomDomainId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WebPubSubName, ok = input.Parsed["webPubSubName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "webPubSubName", input) + } + + if id.CustomDomainName, ok = input.Parsed["customDomainName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "customDomainName", input) + } + + return nil +} + +// ValidateCustomDomainID checks that 'input' can be parsed as a Custom Domain ID +func ValidateCustomDomainID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseCustomDomainID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Custom Domain ID +func (id CustomDomainId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.SignalRService/webPubSub/%s/customDomains/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WebPubSubName, id.CustomDomainName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Custom Domain ID +func (id CustomDomainId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftSignalRService", "Microsoft.SignalRService", "Microsoft.SignalRService"), + resourceids.StaticSegment("staticWebPubSub", "webPubSub", "webPubSub"), + resourceids.UserSpecifiedSegment("webPubSubName", "webPubSubValue"), + resourceids.StaticSegment("staticCustomDomains", "customDomains", "customDomains"), + resourceids.UserSpecifiedSegment("customDomainName", "customDomainValue"), + } +} + +// String returns a human-readable description of this Custom Domain ID +func (id CustomDomainId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Web Pub Sub Name: %q", id.WebPubSubName), + fmt.Sprintf("Custom Domain Name: %q", id.CustomDomainName), + } + return fmt.Sprintf("Custom Domain (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/id_customdomain_test.go b/resource-manager/webpubsub/2024-03-01/webpubsub/id_customdomain_test.go new file mode 100644 index 00000000000..1e14acdc273 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/id_customdomain_test.go @@ -0,0 +1,327 @@ +package webpubsub + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &CustomDomainId{} + +func TestNewCustomDomainID(t *testing.T) { + id := NewCustomDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue", "customDomainValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WebPubSubName != "webPubSubValue" { + t.Fatalf("Expected %q but got %q for Segment 'WebPubSubName'", id.WebPubSubName, "webPubSubValue") + } + + if id.CustomDomainName != "customDomainValue" { + t.Fatalf("Expected %q but got %q for Segment 'CustomDomainName'", id.CustomDomainName, "customDomainValue") + } +} + +func TestFormatCustomDomainID(t *testing.T) { + actual := NewCustomDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue", "customDomainValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/customDomains/customDomainValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCustomDomainID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CustomDomainId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/customDomains", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/customDomains/customDomainValue", + Expected: &CustomDomainId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WebPubSubName: "webPubSubValue", + CustomDomainName: "customDomainValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/customDomains/customDomainValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCustomDomainID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WebPubSubName != v.Expected.WebPubSubName { + t.Fatalf("Expected %q but got %q for WebPubSubName", v.Expected.WebPubSubName, actual.WebPubSubName) + } + + if actual.CustomDomainName != v.Expected.CustomDomainName { + t.Fatalf("Expected %q but got %q for CustomDomainName", v.Expected.CustomDomainName, actual.CustomDomainName) + } + + } +} + +func TestParseCustomDomainIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CustomDomainId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/wEbPuBsUb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/wEbPuBsUb/wEbPuBsUbVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/customDomains", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/wEbPuBsUb/wEbPuBsUbVaLuE/cUsToMdOmAiNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/customDomains/customDomainValue", + Expected: &CustomDomainId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WebPubSubName: "webPubSubValue", + CustomDomainName: "customDomainValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/customDomains/customDomainValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/wEbPuBsUb/wEbPuBsUbVaLuE/cUsToMdOmAiNs/cUsToMdOmAiNvAlUe", + Expected: &CustomDomainId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WebPubSubName: "wEbPuBsUbVaLuE", + CustomDomainName: "cUsToMdOmAiNvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/wEbPuBsUb/wEbPuBsUbVaLuE/cUsToMdOmAiNs/cUsToMdOmAiNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCustomDomainIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WebPubSubName != v.Expected.WebPubSubName { + t.Fatalf("Expected %q but got %q for WebPubSubName", v.Expected.WebPubSubName, actual.WebPubSubName) + } + + if actual.CustomDomainName != v.Expected.CustomDomainName { + t.Fatalf("Expected %q but got %q for CustomDomainName", v.Expected.CustomDomainName, actual.CustomDomainName) + } + + } +} + +func TestSegmentsForCustomDomainId(t *testing.T) { + segments := CustomDomainId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CustomDomainId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/id_hub.go b/resource-manager/webpubsub/2024-03-01/webpubsub/id_hub.go new file mode 100644 index 00000000000..d6fc6e18139 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/id_hub.go @@ -0,0 +1,139 @@ +package webpubsub + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&HubId{}) +} + +var _ resourceids.ResourceId = &HubId{} + +// HubId is a struct representing the Resource ID for a Hub +type HubId struct { + SubscriptionId string + ResourceGroupName string + WebPubSubName string + HubName string +} + +// NewHubID returns a new HubId struct +func NewHubID(subscriptionId string, resourceGroupName string, webPubSubName string, hubName string) HubId { + return HubId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WebPubSubName: webPubSubName, + HubName: hubName, + } +} + +// ParseHubID parses 'input' into a HubId +func ParseHubID(input string) (*HubId, error) { + parser := resourceids.NewParserFromResourceIdType(&HubId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HubId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseHubIDInsensitively parses 'input' case-insensitively into a HubId +// note: this method should only be used for API response data and not user input +func ParseHubIDInsensitively(input string) (*HubId, error) { + parser := resourceids.NewParserFromResourceIdType(&HubId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HubId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *HubId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WebPubSubName, ok = input.Parsed["webPubSubName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "webPubSubName", input) + } + + if id.HubName, ok = input.Parsed["hubName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hubName", input) + } + + return nil +} + +// ValidateHubID checks that 'input' can be parsed as a Hub ID +func ValidateHubID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseHubID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Hub ID +func (id HubId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.SignalRService/webPubSub/%s/hubs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WebPubSubName, id.HubName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Hub ID +func (id HubId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftSignalRService", "Microsoft.SignalRService", "Microsoft.SignalRService"), + resourceids.StaticSegment("staticWebPubSub", "webPubSub", "webPubSub"), + resourceids.UserSpecifiedSegment("webPubSubName", "webPubSubValue"), + resourceids.StaticSegment("staticHubs", "hubs", "hubs"), + resourceids.UserSpecifiedSegment("hubName", "hubValue"), + } +} + +// String returns a human-readable description of this Hub ID +func (id HubId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Web Pub Sub Name: %q", id.WebPubSubName), + fmt.Sprintf("Hub Name: %q", id.HubName), + } + return fmt.Sprintf("Hub (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/id_hub_test.go b/resource-manager/webpubsub/2024-03-01/webpubsub/id_hub_test.go new file mode 100644 index 00000000000..f8f7fdb8fcb --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/id_hub_test.go @@ -0,0 +1,327 @@ +package webpubsub + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &HubId{} + +func TestNewHubID(t *testing.T) { + id := NewHubID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue", "hubValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WebPubSubName != "webPubSubValue" { + t.Fatalf("Expected %q but got %q for Segment 'WebPubSubName'", id.WebPubSubName, "webPubSubValue") + } + + if id.HubName != "hubValue" { + t.Fatalf("Expected %q but got %q for Segment 'HubName'", id.HubName, "hubValue") + } +} + +func TestFormatHubID(t *testing.T) { + actual := NewHubID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue", "hubValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/hubs/hubValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseHubID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HubId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/hubs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/hubs/hubValue", + Expected: &HubId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WebPubSubName: "webPubSubValue", + HubName: "hubValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/hubs/hubValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHubID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WebPubSubName != v.Expected.WebPubSubName { + t.Fatalf("Expected %q but got %q for WebPubSubName", v.Expected.WebPubSubName, actual.WebPubSubName) + } + + if actual.HubName != v.Expected.HubName { + t.Fatalf("Expected %q but got %q for HubName", v.Expected.HubName, actual.HubName) + } + + } +} + +func TestParseHubIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HubId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/wEbPuBsUb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/wEbPuBsUb/wEbPuBsUbVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/hubs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/wEbPuBsUb/wEbPuBsUbVaLuE/hUbS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/hubs/hubValue", + Expected: &HubId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WebPubSubName: "webPubSubValue", + HubName: "hubValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/hubs/hubValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/wEbPuBsUb/wEbPuBsUbVaLuE/hUbS/hUbVaLuE", + Expected: &HubId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WebPubSubName: "wEbPuBsUbVaLuE", + HubName: "hUbVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/wEbPuBsUb/wEbPuBsUbVaLuE/hUbS/hUbVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHubIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WebPubSubName != v.Expected.WebPubSubName { + t.Fatalf("Expected %q but got %q for WebPubSubName", v.Expected.WebPubSubName, actual.WebPubSubName) + } + + if actual.HubName != v.Expected.HubName { + t.Fatalf("Expected %q but got %q for HubName", v.Expected.HubName, actual.HubName) + } + + } +} + +func TestSegmentsForHubId(t *testing.T) { + segments := HubId{}.Segments() + if len(segments) == 0 { + t.Fatalf("HubId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/id_location.go b/resource-manager/webpubsub/2024-03-01/webpubsub/id_location.go new file mode 100644 index 00000000000..7486fb2e46c --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/id_location.go @@ -0,0 +1,121 @@ +package webpubsub + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&LocationId{}) +} + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + SubscriptionId string + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(subscriptionId string, locationName string) LocationId { + return LocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.SignalRService/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("staticMicrosoftSignalRService", "Microsoft.SignalRService", "Microsoft.SignalRService"), + 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/webpubsub/2024-03-01/webpubsub/id_location_test.go b/resource-manager/webpubsub/2024-03-01/webpubsub/id_location_test.go new file mode 100644 index 00000000000..fb2aee65995 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/id_location_test.go @@ -0,0 +1,237 @@ +package webpubsub + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (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.SignalRService/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.SignalRService", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.SignalRService/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.SignalRService/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.SignalRService/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.SignalRService", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.SignalRService/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.SignalRService/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.SignalRService/locations/locationValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/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.sIgNaLrSeRvIcE/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/webpubsub/2024-03-01/webpubsub/id_privateendpointconnection.go b/resource-manager/webpubsub/2024-03-01/webpubsub/id_privateendpointconnection.go new file mode 100644 index 00000000000..7516b436c7a --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/id_privateendpointconnection.go @@ -0,0 +1,139 @@ +package webpubsub + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PrivateEndpointConnectionId{}) +} + +var _ resourceids.ResourceId = &PrivateEndpointConnectionId{} + +// PrivateEndpointConnectionId is a struct representing the Resource ID for a Private Endpoint Connection +type PrivateEndpointConnectionId struct { + SubscriptionId string + ResourceGroupName string + WebPubSubName string + PrivateEndpointConnectionName string +} + +// NewPrivateEndpointConnectionID returns a new PrivateEndpointConnectionId struct +func NewPrivateEndpointConnectionID(subscriptionId string, resourceGroupName string, webPubSubName string, privateEndpointConnectionName string) PrivateEndpointConnectionId { + return PrivateEndpointConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WebPubSubName: webPubSubName, + 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.WebPubSubName, ok = input.Parsed["webPubSubName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "webPubSubName", 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.SignalRService/webPubSub/%s/privateEndpointConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WebPubSubName, 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("staticMicrosoftSignalRService", "Microsoft.SignalRService", "Microsoft.SignalRService"), + resourceids.StaticSegment("staticWebPubSub", "webPubSub", "webPubSub"), + resourceids.UserSpecifiedSegment("webPubSubName", "webPubSubValue"), + 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("Web Pub Sub Name: %q", id.WebPubSubName), + 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/webpubsub/2024-03-01/webpubsub/id_privateendpointconnection_test.go b/resource-manager/webpubsub/2024-03-01/webpubsub/id_privateendpointconnection_test.go new file mode 100644 index 00000000000..b841b40f151 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/id_privateendpointconnection_test.go @@ -0,0 +1,327 @@ +package webpubsub + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (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", "webPubSubValue", "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.WebPubSubName != "webPubSubValue" { + t.Fatalf("Expected %q but got %q for Segment 'WebPubSubName'", id.WebPubSubName, "webPubSubValue") + } + + 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", "webPubSubValue", "privateEndpointConnectionValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/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.SignalRService", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/privateEndpointConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/privateEndpointConnections/privateEndpointConnectionValue", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WebPubSubName: "webPubSubValue", + PrivateEndpointConnectionName: "privateEndpointConnectionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/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.WebPubSubName != v.Expected.WebPubSubName { + t.Fatalf("Expected %q but got %q for WebPubSubName", v.Expected.WebPubSubName, actual.WebPubSubName) + } + + 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.SignalRService", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/wEbPuBsUb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/wEbPuBsUb/wEbPuBsUbVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/privateEndpointConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/wEbPuBsUb/wEbPuBsUbVaLuE/pRiVaTeEnDpOiNtCoNnEcTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/privateEndpointConnections/privateEndpointConnectionValue", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WebPubSubName: "webPubSubValue", + PrivateEndpointConnectionName: "privateEndpointConnectionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/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.sIgNaLrSeRvIcE/wEbPuBsUb/wEbPuBsUbVaLuE/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WebPubSubName: "wEbPuBsUbVaLuE", + 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.sIgNaLrSeRvIcE/wEbPuBsUb/wEbPuBsUbVaLuE/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.WebPubSubName != v.Expected.WebPubSubName { + t.Fatalf("Expected %q but got %q for WebPubSubName", v.Expected.WebPubSubName, actual.WebPubSubName) + } + + 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/webpubsub/2024-03-01/webpubsub/id_replica.go b/resource-manager/webpubsub/2024-03-01/webpubsub/id_replica.go new file mode 100644 index 00000000000..0dfe235e6a0 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/id_replica.go @@ -0,0 +1,139 @@ +package webpubsub + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ReplicaId{}) +} + +var _ resourceids.ResourceId = &ReplicaId{} + +// ReplicaId is a struct representing the Resource ID for a Replica +type ReplicaId struct { + SubscriptionId string + ResourceGroupName string + WebPubSubName string + ReplicaName string +} + +// NewReplicaID returns a new ReplicaId struct +func NewReplicaID(subscriptionId string, resourceGroupName string, webPubSubName string, replicaName string) ReplicaId { + return ReplicaId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WebPubSubName: webPubSubName, + ReplicaName: replicaName, + } +} + +// ParseReplicaID parses 'input' into a ReplicaId +func ParseReplicaID(input string) (*ReplicaId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicaId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicaId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicaIDInsensitively parses 'input' case-insensitively into a ReplicaId +// note: this method should only be used for API response data and not user input +func ParseReplicaIDInsensitively(input string) (*ReplicaId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicaId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicaId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicaId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WebPubSubName, ok = input.Parsed["webPubSubName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "webPubSubName", input) + } + + if id.ReplicaName, ok = input.Parsed["replicaName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicaName", input) + } + + return nil +} + +// ValidateReplicaID checks that 'input' can be parsed as a Replica ID +func ValidateReplicaID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseReplicaID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replica ID +func (id ReplicaId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.SignalRService/webPubSub/%s/replicas/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WebPubSubName, id.ReplicaName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replica ID +func (id ReplicaId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftSignalRService", "Microsoft.SignalRService", "Microsoft.SignalRService"), + resourceids.StaticSegment("staticWebPubSub", "webPubSub", "webPubSub"), + resourceids.UserSpecifiedSegment("webPubSubName", "webPubSubValue"), + resourceids.StaticSegment("staticReplicas", "replicas", "replicas"), + resourceids.UserSpecifiedSegment("replicaName", "replicaValue"), + } +} + +// String returns a human-readable description of this Replica ID +func (id ReplicaId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Web Pub Sub Name: %q", id.WebPubSubName), + fmt.Sprintf("Replica Name: %q", id.ReplicaName), + } + return fmt.Sprintf("Replica (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/id_replica_test.go b/resource-manager/webpubsub/2024-03-01/webpubsub/id_replica_test.go new file mode 100644 index 00000000000..d7b746274ca --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/id_replica_test.go @@ -0,0 +1,327 @@ +package webpubsub + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ReplicaId{} + +func TestNewReplicaID(t *testing.T) { + id := NewReplicaID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue", "replicaValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WebPubSubName != "webPubSubValue" { + t.Fatalf("Expected %q but got %q for Segment 'WebPubSubName'", id.WebPubSubName, "webPubSubValue") + } + + if id.ReplicaName != "replicaValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicaName'", id.ReplicaName, "replicaValue") + } +} + +func TestFormatReplicaID(t *testing.T) { + actual := NewReplicaID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue", "replicaValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/replicas/replicaValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicaID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicaId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/replicas", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/replicas/replicaValue", + Expected: &ReplicaId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WebPubSubName: "webPubSubValue", + ReplicaName: "replicaValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/replicas/replicaValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicaID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WebPubSubName != v.Expected.WebPubSubName { + t.Fatalf("Expected %q but got %q for WebPubSubName", v.Expected.WebPubSubName, actual.WebPubSubName) + } + + if actual.ReplicaName != v.Expected.ReplicaName { + t.Fatalf("Expected %q but got %q for ReplicaName", v.Expected.ReplicaName, actual.ReplicaName) + } + + } +} + +func TestParseReplicaIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicaId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/wEbPuBsUb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/wEbPuBsUb/wEbPuBsUbVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/replicas", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/wEbPuBsUb/wEbPuBsUbVaLuE/rEpLiCaS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/replicas/replicaValue", + Expected: &ReplicaId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WebPubSubName: "webPubSubValue", + ReplicaName: "replicaValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/replicas/replicaValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/wEbPuBsUb/wEbPuBsUbVaLuE/rEpLiCaS/rEpLiCaVaLuE", + Expected: &ReplicaId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WebPubSubName: "wEbPuBsUbVaLuE", + ReplicaName: "rEpLiCaVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/wEbPuBsUb/wEbPuBsUbVaLuE/rEpLiCaS/rEpLiCaVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicaIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WebPubSubName != v.Expected.WebPubSubName { + t.Fatalf("Expected %q but got %q for WebPubSubName", v.Expected.WebPubSubName, actual.WebPubSubName) + } + + if actual.ReplicaName != v.Expected.ReplicaName { + t.Fatalf("Expected %q but got %q for ReplicaName", v.Expected.ReplicaName, actual.ReplicaName) + } + + } +} + +func TestSegmentsForReplicaId(t *testing.T) { + segments := ReplicaId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicaId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/id_replicasharedprivatelinkresource.go b/resource-manager/webpubsub/2024-03-01/webpubsub/id_replicasharedprivatelinkresource.go new file mode 100644 index 00000000000..90da19e9abd --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/id_replicasharedprivatelinkresource.go @@ -0,0 +1,148 @@ +package webpubsub + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ReplicaSharedPrivateLinkResourceId{}) +} + +var _ resourceids.ResourceId = &ReplicaSharedPrivateLinkResourceId{} + +// ReplicaSharedPrivateLinkResourceId is a struct representing the Resource ID for a Replica Shared Private Link Resource +type ReplicaSharedPrivateLinkResourceId struct { + SubscriptionId string + ResourceGroupName string + WebPubSubName string + ReplicaName string + SharedPrivateLinkResourceName string +} + +// NewReplicaSharedPrivateLinkResourceID returns a new ReplicaSharedPrivateLinkResourceId struct +func NewReplicaSharedPrivateLinkResourceID(subscriptionId string, resourceGroupName string, webPubSubName string, replicaName string, sharedPrivateLinkResourceName string) ReplicaSharedPrivateLinkResourceId { + return ReplicaSharedPrivateLinkResourceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WebPubSubName: webPubSubName, + ReplicaName: replicaName, + SharedPrivateLinkResourceName: sharedPrivateLinkResourceName, + } +} + +// ParseReplicaSharedPrivateLinkResourceID parses 'input' into a ReplicaSharedPrivateLinkResourceId +func ParseReplicaSharedPrivateLinkResourceID(input string) (*ReplicaSharedPrivateLinkResourceId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicaSharedPrivateLinkResourceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicaSharedPrivateLinkResourceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicaSharedPrivateLinkResourceIDInsensitively parses 'input' case-insensitively into a ReplicaSharedPrivateLinkResourceId +// note: this method should only be used for API response data and not user input +func ParseReplicaSharedPrivateLinkResourceIDInsensitively(input string) (*ReplicaSharedPrivateLinkResourceId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicaSharedPrivateLinkResourceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicaSharedPrivateLinkResourceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicaSharedPrivateLinkResourceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WebPubSubName, ok = input.Parsed["webPubSubName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "webPubSubName", input) + } + + if id.ReplicaName, ok = input.Parsed["replicaName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicaName", input) + } + + if id.SharedPrivateLinkResourceName, ok = input.Parsed["sharedPrivateLinkResourceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "sharedPrivateLinkResourceName", input) + } + + return nil +} + +// ValidateReplicaSharedPrivateLinkResourceID checks that 'input' can be parsed as a Replica Shared Private Link Resource ID +func ValidateReplicaSharedPrivateLinkResourceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseReplicaSharedPrivateLinkResourceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replica Shared Private Link Resource ID +func (id ReplicaSharedPrivateLinkResourceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.SignalRService/webPubSub/%s/replicas/%s/sharedPrivateLinkResources/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WebPubSubName, id.ReplicaName, id.SharedPrivateLinkResourceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replica Shared Private Link Resource ID +func (id ReplicaSharedPrivateLinkResourceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftSignalRService", "Microsoft.SignalRService", "Microsoft.SignalRService"), + resourceids.StaticSegment("staticWebPubSub", "webPubSub", "webPubSub"), + resourceids.UserSpecifiedSegment("webPubSubName", "webPubSubValue"), + resourceids.StaticSegment("staticReplicas", "replicas", "replicas"), + resourceids.UserSpecifiedSegment("replicaName", "replicaValue"), + resourceids.StaticSegment("staticSharedPrivateLinkResources", "sharedPrivateLinkResources", "sharedPrivateLinkResources"), + resourceids.UserSpecifiedSegment("sharedPrivateLinkResourceName", "sharedPrivateLinkResourceValue"), + } +} + +// String returns a human-readable description of this Replica Shared Private Link Resource ID +func (id ReplicaSharedPrivateLinkResourceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Web Pub Sub Name: %q", id.WebPubSubName), + fmt.Sprintf("Replica Name: %q", id.ReplicaName), + fmt.Sprintf("Shared Private Link Resource Name: %q", id.SharedPrivateLinkResourceName), + } + return fmt.Sprintf("Replica Shared Private Link Resource (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/id_replicasharedprivatelinkresource_test.go b/resource-manager/webpubsub/2024-03-01/webpubsub/id_replicasharedprivatelinkresource_test.go new file mode 100644 index 00000000000..87da8491782 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/id_replicasharedprivatelinkresource_test.go @@ -0,0 +1,372 @@ +package webpubsub + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ReplicaSharedPrivateLinkResourceId{} + +func TestNewReplicaSharedPrivateLinkResourceID(t *testing.T) { + id := NewReplicaSharedPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue", "replicaValue", "sharedPrivateLinkResourceValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WebPubSubName != "webPubSubValue" { + t.Fatalf("Expected %q but got %q for Segment 'WebPubSubName'", id.WebPubSubName, "webPubSubValue") + } + + if id.ReplicaName != "replicaValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicaName'", id.ReplicaName, "replicaValue") + } + + if id.SharedPrivateLinkResourceName != "sharedPrivateLinkResourceValue" { + t.Fatalf("Expected %q but got %q for Segment 'SharedPrivateLinkResourceName'", id.SharedPrivateLinkResourceName, "sharedPrivateLinkResourceValue") + } +} + +func TestFormatReplicaSharedPrivateLinkResourceID(t *testing.T) { + actual := NewReplicaSharedPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue", "replicaValue", "sharedPrivateLinkResourceValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/replicas/replicaValue/sharedPrivateLinkResources/sharedPrivateLinkResourceValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicaSharedPrivateLinkResourceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicaSharedPrivateLinkResourceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/replicas", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/replicas/replicaValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/replicas/replicaValue/sharedPrivateLinkResources", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/replicas/replicaValue/sharedPrivateLinkResources/sharedPrivateLinkResourceValue", + Expected: &ReplicaSharedPrivateLinkResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WebPubSubName: "webPubSubValue", + ReplicaName: "replicaValue", + SharedPrivateLinkResourceName: "sharedPrivateLinkResourceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/replicas/replicaValue/sharedPrivateLinkResources/sharedPrivateLinkResourceValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicaSharedPrivateLinkResourceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WebPubSubName != v.Expected.WebPubSubName { + t.Fatalf("Expected %q but got %q for WebPubSubName", v.Expected.WebPubSubName, actual.WebPubSubName) + } + + if actual.ReplicaName != v.Expected.ReplicaName { + t.Fatalf("Expected %q but got %q for ReplicaName", v.Expected.ReplicaName, actual.ReplicaName) + } + + if actual.SharedPrivateLinkResourceName != v.Expected.SharedPrivateLinkResourceName { + t.Fatalf("Expected %q but got %q for SharedPrivateLinkResourceName", v.Expected.SharedPrivateLinkResourceName, actual.SharedPrivateLinkResourceName) + } + + } +} + +func TestParseReplicaSharedPrivateLinkResourceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicaSharedPrivateLinkResourceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/wEbPuBsUb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/wEbPuBsUb/wEbPuBsUbVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/replicas", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/wEbPuBsUb/wEbPuBsUbVaLuE/rEpLiCaS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/replicas/replicaValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/wEbPuBsUb/wEbPuBsUbVaLuE/rEpLiCaS/rEpLiCaVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/replicas/replicaValue/sharedPrivateLinkResources", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/wEbPuBsUb/wEbPuBsUbVaLuE/rEpLiCaS/rEpLiCaVaLuE/sHaReDpRiVaTeLiNkReSoUrCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/replicas/replicaValue/sharedPrivateLinkResources/sharedPrivateLinkResourceValue", + Expected: &ReplicaSharedPrivateLinkResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WebPubSubName: "webPubSubValue", + ReplicaName: "replicaValue", + SharedPrivateLinkResourceName: "sharedPrivateLinkResourceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/replicas/replicaValue/sharedPrivateLinkResources/sharedPrivateLinkResourceValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/wEbPuBsUb/wEbPuBsUbVaLuE/rEpLiCaS/rEpLiCaVaLuE/sHaReDpRiVaTeLiNkReSoUrCeS/sHaReDpRiVaTeLiNkReSoUrCeVaLuE", + Expected: &ReplicaSharedPrivateLinkResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WebPubSubName: "wEbPuBsUbVaLuE", + ReplicaName: "rEpLiCaVaLuE", + SharedPrivateLinkResourceName: "sHaReDpRiVaTeLiNkReSoUrCeVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/wEbPuBsUb/wEbPuBsUbVaLuE/rEpLiCaS/rEpLiCaVaLuE/sHaReDpRiVaTeLiNkReSoUrCeS/sHaReDpRiVaTeLiNkReSoUrCeVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicaSharedPrivateLinkResourceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WebPubSubName != v.Expected.WebPubSubName { + t.Fatalf("Expected %q but got %q for WebPubSubName", v.Expected.WebPubSubName, actual.WebPubSubName) + } + + if actual.ReplicaName != v.Expected.ReplicaName { + t.Fatalf("Expected %q but got %q for ReplicaName", v.Expected.ReplicaName, actual.ReplicaName) + } + + if actual.SharedPrivateLinkResourceName != v.Expected.SharedPrivateLinkResourceName { + t.Fatalf("Expected %q but got %q for SharedPrivateLinkResourceName", v.Expected.SharedPrivateLinkResourceName, actual.SharedPrivateLinkResourceName) + } + + } +} + +func TestSegmentsForReplicaSharedPrivateLinkResourceId(t *testing.T) { + segments := ReplicaSharedPrivateLinkResourceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicaSharedPrivateLinkResourceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/id_sharedprivatelinkresource.go b/resource-manager/webpubsub/2024-03-01/webpubsub/id_sharedprivatelinkresource.go new file mode 100644 index 00000000000..da0a3fe2cfa --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/id_sharedprivatelinkresource.go @@ -0,0 +1,139 @@ +package webpubsub + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SharedPrivateLinkResourceId{}) +} + +var _ resourceids.ResourceId = &SharedPrivateLinkResourceId{} + +// SharedPrivateLinkResourceId is a struct representing the Resource ID for a Shared Private Link Resource +type SharedPrivateLinkResourceId struct { + SubscriptionId string + ResourceGroupName string + WebPubSubName string + SharedPrivateLinkResourceName string +} + +// NewSharedPrivateLinkResourceID returns a new SharedPrivateLinkResourceId struct +func NewSharedPrivateLinkResourceID(subscriptionId string, resourceGroupName string, webPubSubName string, sharedPrivateLinkResourceName string) SharedPrivateLinkResourceId { + return SharedPrivateLinkResourceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WebPubSubName: webPubSubName, + SharedPrivateLinkResourceName: sharedPrivateLinkResourceName, + } +} + +// ParseSharedPrivateLinkResourceID parses 'input' into a SharedPrivateLinkResourceId +func ParseSharedPrivateLinkResourceID(input string) (*SharedPrivateLinkResourceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SharedPrivateLinkResourceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SharedPrivateLinkResourceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSharedPrivateLinkResourceIDInsensitively parses 'input' case-insensitively into a SharedPrivateLinkResourceId +// note: this method should only be used for API response data and not user input +func ParseSharedPrivateLinkResourceIDInsensitively(input string) (*SharedPrivateLinkResourceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SharedPrivateLinkResourceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SharedPrivateLinkResourceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SharedPrivateLinkResourceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WebPubSubName, ok = input.Parsed["webPubSubName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "webPubSubName", input) + } + + if id.SharedPrivateLinkResourceName, ok = input.Parsed["sharedPrivateLinkResourceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "sharedPrivateLinkResourceName", input) + } + + return nil +} + +// ValidateSharedPrivateLinkResourceID checks that 'input' can be parsed as a Shared Private Link Resource ID +func ValidateSharedPrivateLinkResourceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSharedPrivateLinkResourceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Shared Private Link Resource ID +func (id SharedPrivateLinkResourceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.SignalRService/webPubSub/%s/sharedPrivateLinkResources/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WebPubSubName, id.SharedPrivateLinkResourceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Shared Private Link Resource ID +func (id SharedPrivateLinkResourceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftSignalRService", "Microsoft.SignalRService", "Microsoft.SignalRService"), + resourceids.StaticSegment("staticWebPubSub", "webPubSub", "webPubSub"), + resourceids.UserSpecifiedSegment("webPubSubName", "webPubSubValue"), + resourceids.StaticSegment("staticSharedPrivateLinkResources", "sharedPrivateLinkResources", "sharedPrivateLinkResources"), + resourceids.UserSpecifiedSegment("sharedPrivateLinkResourceName", "sharedPrivateLinkResourceValue"), + } +} + +// String returns a human-readable description of this Shared Private Link Resource ID +func (id SharedPrivateLinkResourceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Web Pub Sub Name: %q", id.WebPubSubName), + fmt.Sprintf("Shared Private Link Resource Name: %q", id.SharedPrivateLinkResourceName), + } + return fmt.Sprintf("Shared Private Link Resource (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/id_sharedprivatelinkresource_test.go b/resource-manager/webpubsub/2024-03-01/webpubsub/id_sharedprivatelinkresource_test.go new file mode 100644 index 00000000000..1358eb5bc01 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/id_sharedprivatelinkresource_test.go @@ -0,0 +1,327 @@ +package webpubsub + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SharedPrivateLinkResourceId{} + +func TestNewSharedPrivateLinkResourceID(t *testing.T) { + id := NewSharedPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue", "sharedPrivateLinkResourceValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WebPubSubName != "webPubSubValue" { + t.Fatalf("Expected %q but got %q for Segment 'WebPubSubName'", id.WebPubSubName, "webPubSubValue") + } + + if id.SharedPrivateLinkResourceName != "sharedPrivateLinkResourceValue" { + t.Fatalf("Expected %q but got %q for Segment 'SharedPrivateLinkResourceName'", id.SharedPrivateLinkResourceName, "sharedPrivateLinkResourceValue") + } +} + +func TestFormatSharedPrivateLinkResourceID(t *testing.T) { + actual := NewSharedPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue", "sharedPrivateLinkResourceValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/sharedPrivateLinkResources/sharedPrivateLinkResourceValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSharedPrivateLinkResourceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SharedPrivateLinkResourceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/sharedPrivateLinkResources", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/sharedPrivateLinkResources/sharedPrivateLinkResourceValue", + Expected: &SharedPrivateLinkResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WebPubSubName: "webPubSubValue", + SharedPrivateLinkResourceName: "sharedPrivateLinkResourceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/sharedPrivateLinkResources/sharedPrivateLinkResourceValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSharedPrivateLinkResourceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WebPubSubName != v.Expected.WebPubSubName { + t.Fatalf("Expected %q but got %q for WebPubSubName", v.Expected.WebPubSubName, actual.WebPubSubName) + } + + if actual.SharedPrivateLinkResourceName != v.Expected.SharedPrivateLinkResourceName { + t.Fatalf("Expected %q but got %q for SharedPrivateLinkResourceName", v.Expected.SharedPrivateLinkResourceName, actual.SharedPrivateLinkResourceName) + } + + } +} + +func TestParseSharedPrivateLinkResourceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SharedPrivateLinkResourceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/wEbPuBsUb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/wEbPuBsUb/wEbPuBsUbVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/sharedPrivateLinkResources", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/wEbPuBsUb/wEbPuBsUbVaLuE/sHaReDpRiVaTeLiNkReSoUrCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/sharedPrivateLinkResources/sharedPrivateLinkResourceValue", + Expected: &SharedPrivateLinkResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WebPubSubName: "webPubSubValue", + SharedPrivateLinkResourceName: "sharedPrivateLinkResourceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/sharedPrivateLinkResources/sharedPrivateLinkResourceValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/wEbPuBsUb/wEbPuBsUbVaLuE/sHaReDpRiVaTeLiNkReSoUrCeS/sHaReDpRiVaTeLiNkReSoUrCeVaLuE", + Expected: &SharedPrivateLinkResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WebPubSubName: "wEbPuBsUbVaLuE", + SharedPrivateLinkResourceName: "sHaReDpRiVaTeLiNkReSoUrCeVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/wEbPuBsUb/wEbPuBsUbVaLuE/sHaReDpRiVaTeLiNkReSoUrCeS/sHaReDpRiVaTeLiNkReSoUrCeVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSharedPrivateLinkResourceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WebPubSubName != v.Expected.WebPubSubName { + t.Fatalf("Expected %q but got %q for WebPubSubName", v.Expected.WebPubSubName, actual.WebPubSubName) + } + + if actual.SharedPrivateLinkResourceName != v.Expected.SharedPrivateLinkResourceName { + t.Fatalf("Expected %q but got %q for SharedPrivateLinkResourceName", v.Expected.SharedPrivateLinkResourceName, actual.SharedPrivateLinkResourceName) + } + + } +} + +func TestSegmentsForSharedPrivateLinkResourceId(t *testing.T) { + segments := SharedPrivateLinkResourceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SharedPrivateLinkResourceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/id_webpubsub.go b/resource-manager/webpubsub/2024-03-01/webpubsub/id_webpubsub.go new file mode 100644 index 00000000000..44a3174132e --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/id_webpubsub.go @@ -0,0 +1,130 @@ +package webpubsub + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&WebPubSubId{}) +} + +var _ resourceids.ResourceId = &WebPubSubId{} + +// WebPubSubId is a struct representing the Resource ID for a Web Pub Sub +type WebPubSubId struct { + SubscriptionId string + ResourceGroupName string + WebPubSubName string +} + +// NewWebPubSubID returns a new WebPubSubId struct +func NewWebPubSubID(subscriptionId string, resourceGroupName string, webPubSubName string) WebPubSubId { + return WebPubSubId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WebPubSubName: webPubSubName, + } +} + +// ParseWebPubSubID parses 'input' into a WebPubSubId +func ParseWebPubSubID(input string) (*WebPubSubId, error) { + parser := resourceids.NewParserFromResourceIdType(&WebPubSubId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WebPubSubId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWebPubSubIDInsensitively parses 'input' case-insensitively into a WebPubSubId +// note: this method should only be used for API response data and not user input +func ParseWebPubSubIDInsensitively(input string) (*WebPubSubId, error) { + parser := resourceids.NewParserFromResourceIdType(&WebPubSubId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WebPubSubId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WebPubSubId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WebPubSubName, ok = input.Parsed["webPubSubName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "webPubSubName", input) + } + + return nil +} + +// ValidateWebPubSubID checks that 'input' can be parsed as a Web Pub Sub ID +func ValidateWebPubSubID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseWebPubSubID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Web Pub Sub ID +func (id WebPubSubId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.SignalRService/webPubSub/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WebPubSubName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Web Pub Sub ID +func (id WebPubSubId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftSignalRService", "Microsoft.SignalRService", "Microsoft.SignalRService"), + resourceids.StaticSegment("staticWebPubSub", "webPubSub", "webPubSub"), + resourceids.UserSpecifiedSegment("webPubSubName", "webPubSubValue"), + } +} + +// String returns a human-readable description of this Web Pub Sub ID +func (id WebPubSubId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Web Pub Sub Name: %q", id.WebPubSubName), + } + return fmt.Sprintf("Web Pub Sub (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/id_webpubsub_test.go b/resource-manager/webpubsub/2024-03-01/webpubsub/id_webpubsub_test.go new file mode 100644 index 00000000000..5dba4b567c5 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/id_webpubsub_test.go @@ -0,0 +1,282 @@ +package webpubsub + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &WebPubSubId{} + +func TestNewWebPubSubID(t *testing.T) { + id := NewWebPubSubID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WebPubSubName != "webPubSubValue" { + t.Fatalf("Expected %q but got %q for Segment 'WebPubSubName'", id.WebPubSubName, "webPubSubValue") + } +} + +func TestFormatWebPubSubID(t *testing.T) { + actual := NewWebPubSubID("12345678-1234-9876-4563-123456789012", "example-resource-group", "webPubSubValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWebPubSubID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WebPubSubId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue", + Expected: &WebPubSubId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WebPubSubName: "webPubSubValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWebPubSubID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WebPubSubName != v.Expected.WebPubSubName { + t.Fatalf("Expected %q but got %q for WebPubSubName", v.Expected.WebPubSubName, actual.WebPubSubName) + } + + } +} + +func TestParseWebPubSubIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WebPubSubId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/wEbPuBsUb", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue", + Expected: &WebPubSubId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WebPubSubName: "webPubSubValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SignalRService/webPubSub/webPubSubValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/wEbPuBsUb/wEbPuBsUbVaLuE", + Expected: &WebPubSubId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WebPubSubName: "wEbPuBsUbVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sIgNaLrSeRvIcE/wEbPuBsUb/wEbPuBsUbVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWebPubSubIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WebPubSubName != v.Expected.WebPubSubName { + t.Fatalf("Expected %q but got %q for WebPubSubName", v.Expected.WebPubSubName, actual.WebPubSubName) + } + + } +} + +func TestSegmentsForWebPubSubId(t *testing.T) { + segments := WebPubSubId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WebPubSubId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/method_checknameavailability.go b/resource-manager/webpubsub/2024-03-01/webpubsub/method_checknameavailability.go new file mode 100644 index 00000000000..89b7609aa6f --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/method_checknameavailability.go @@ -0,0 +1,59 @@ +package webpubsub + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NameAvailability +} + +// CheckNameAvailability ... +func (c WebPubSubClient) CheckNameAvailability(ctx context.Context, id LocationId, input NameAvailabilityParameters) (result CheckNameAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/checkNameAvailability", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NameAvailability + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/method_createorupdate.go b/resource-manager/webpubsub/2024-03-01/webpubsub/method_createorupdate.go new file mode 100644 index 00000000000..3496744a0df --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/method_createorupdate.go @@ -0,0 +1,76 @@ +package webpubsub + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *WebPubSubResource +} + +// CreateOrUpdate ... +func (c WebPubSubClient) CreateOrUpdate(ctx context.Context, id WebPubSubId, input WebPubSubResource) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c WebPubSubClient) CreateOrUpdateThenPoll(ctx context.Context, id WebPubSubId, input WebPubSubResource) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/method_customcertificatescreateorupdate.go b/resource-manager/webpubsub/2024-03-01/webpubsub/method_customcertificatescreateorupdate.go new file mode 100644 index 00000000000..f267642033f --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/method_customcertificatescreateorupdate.go @@ -0,0 +1,75 @@ +package webpubsub + +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 CustomCertificatesCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *CustomCertificate +} + +// CustomCertificatesCreateOrUpdate ... +func (c WebPubSubClient) CustomCertificatesCreateOrUpdate(ctx context.Context, id CustomCertificateId, input CustomCertificate) (result CustomCertificatesCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CustomCertificatesCreateOrUpdateThenPoll performs CustomCertificatesCreateOrUpdate then polls until it's completed +func (c WebPubSubClient) CustomCertificatesCreateOrUpdateThenPoll(ctx context.Context, id CustomCertificateId, input CustomCertificate) error { + result, err := c.CustomCertificatesCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CustomCertificatesCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CustomCertificatesCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/method_customcertificatesdelete.go b/resource-manager/webpubsub/2024-03-01/webpubsub/method_customcertificatesdelete.go new file mode 100644 index 00000000000..3cfa28c039d --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/method_customcertificatesdelete.go @@ -0,0 +1,47 @@ +package webpubsub + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomCertificatesDeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// CustomCertificatesDelete ... +func (c WebPubSubClient) CustomCertificatesDelete(ctx context.Context, id CustomCertificateId) (result CustomCertificatesDeleteOperationResponse, 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/webpubsub/2024-03-01/webpubsub/method_customcertificatesget.go b/resource-manager/webpubsub/2024-03-01/webpubsub/method_customcertificatesget.go new file mode 100644 index 00000000000..6307e5d3f88 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/method_customcertificatesget.go @@ -0,0 +1,54 @@ +package webpubsub + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomCertificatesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CustomCertificate +} + +// CustomCertificatesGet ... +func (c WebPubSubClient) CustomCertificatesGet(ctx context.Context, id CustomCertificateId) (result CustomCertificatesGetOperationResponse, 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 CustomCertificate + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/method_customcertificateslist.go b/resource-manager/webpubsub/2024-03-01/webpubsub/method_customcertificateslist.go new file mode 100644 index 00000000000..c0852ec3fd0 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/method_customcertificateslist.go @@ -0,0 +1,92 @@ +package webpubsub + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomCertificatesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CustomCertificate +} + +type CustomCertificatesListCompleteResult struct { + LatestHttpResponse *http.Response + Items []CustomCertificate +} + +// CustomCertificatesList ... +func (c WebPubSubClient) CustomCertificatesList(ctx context.Context, id WebPubSubId) (result CustomCertificatesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/customCertificates", 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 *[]CustomCertificate `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// CustomCertificatesListComplete retrieves all the results into a single object +func (c WebPubSubClient) CustomCertificatesListComplete(ctx context.Context, id WebPubSubId) (CustomCertificatesListCompleteResult, error) { + return c.CustomCertificatesListCompleteMatchingPredicate(ctx, id, CustomCertificateOperationPredicate{}) +} + +// CustomCertificatesListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebPubSubClient) CustomCertificatesListCompleteMatchingPredicate(ctx context.Context, id WebPubSubId, predicate CustomCertificateOperationPredicate) (result CustomCertificatesListCompleteResult, err error) { + items := make([]CustomCertificate, 0) + + resp, err := c.CustomCertificatesList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = CustomCertificatesListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/method_customdomainscreateorupdate.go b/resource-manager/webpubsub/2024-03-01/webpubsub/method_customdomainscreateorupdate.go new file mode 100644 index 00000000000..f893c8f579f --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/method_customdomainscreateorupdate.go @@ -0,0 +1,74 @@ +package webpubsub + +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 CustomDomainsCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *CustomDomain +} + +// CustomDomainsCreateOrUpdate ... +func (c WebPubSubClient) CustomDomainsCreateOrUpdate(ctx context.Context, id CustomDomainId, input CustomDomain) (result CustomDomainsCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CustomDomainsCreateOrUpdateThenPoll performs CustomDomainsCreateOrUpdate then polls until it's completed +func (c WebPubSubClient) CustomDomainsCreateOrUpdateThenPoll(ctx context.Context, id CustomDomainId, input CustomDomain) error { + result, err := c.CustomDomainsCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CustomDomainsCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CustomDomainsCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/method_customdomainsdelete.go b/resource-manager/webpubsub/2024-03-01/webpubsub/method_customdomainsdelete.go new file mode 100644 index 00000000000..7636cb2504f --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/method_customdomainsdelete.go @@ -0,0 +1,71 @@ +package webpubsub + +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 CustomDomainsDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CustomDomainsDelete ... +func (c WebPubSubClient) CustomDomainsDelete(ctx context.Context, id CustomDomainId) (result CustomDomainsDeleteOperationResponse, 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 +} + +// CustomDomainsDeleteThenPoll performs CustomDomainsDelete then polls until it's completed +func (c WebPubSubClient) CustomDomainsDeleteThenPoll(ctx context.Context, id CustomDomainId) error { + result, err := c.CustomDomainsDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing CustomDomainsDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CustomDomainsDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/method_customdomainsget.go b/resource-manager/webpubsub/2024-03-01/webpubsub/method_customdomainsget.go new file mode 100644 index 00000000000..4416471ea19 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/method_customdomainsget.go @@ -0,0 +1,54 @@ +package webpubsub + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomDomainsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CustomDomain +} + +// CustomDomainsGet ... +func (c WebPubSubClient) CustomDomainsGet(ctx context.Context, id CustomDomainId) (result CustomDomainsGetOperationResponse, 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 CustomDomain + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/method_customdomainslist.go b/resource-manager/webpubsub/2024-03-01/webpubsub/method_customdomainslist.go new file mode 100644 index 00000000000..1f812009879 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/method_customdomainslist.go @@ -0,0 +1,92 @@ +package webpubsub + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomDomainsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CustomDomain +} + +type CustomDomainsListCompleteResult struct { + LatestHttpResponse *http.Response + Items []CustomDomain +} + +// CustomDomainsList ... +func (c WebPubSubClient) CustomDomainsList(ctx context.Context, id WebPubSubId) (result CustomDomainsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/customDomains", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]CustomDomain `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// CustomDomainsListComplete retrieves all the results into a single object +func (c WebPubSubClient) CustomDomainsListComplete(ctx context.Context, id WebPubSubId) (CustomDomainsListCompleteResult, error) { + return c.CustomDomainsListCompleteMatchingPredicate(ctx, id, CustomDomainOperationPredicate{}) +} + +// CustomDomainsListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebPubSubClient) CustomDomainsListCompleteMatchingPredicate(ctx context.Context, id WebPubSubId, predicate CustomDomainOperationPredicate) (result CustomDomainsListCompleteResult, err error) { + items := make([]CustomDomain, 0) + + resp, err := c.CustomDomainsList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = CustomDomainsListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/method_delete.go b/resource-manager/webpubsub/2024-03-01/webpubsub/method_delete.go new file mode 100644 index 00000000000..a4d031a8fec --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/method_delete.go @@ -0,0 +1,71 @@ +package webpubsub + +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 WebPubSubClient) Delete(ctx context.Context, id WebPubSubId) (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 WebPubSubClient) DeleteThenPoll(ctx context.Context, id WebPubSubId) 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/webpubsub/2024-03-01/webpubsub/method_get.go b/resource-manager/webpubsub/2024-03-01/webpubsub/method_get.go new file mode 100644 index 00000000000..32c93820294 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/method_get.go @@ -0,0 +1,54 @@ +package webpubsub + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *WebPubSubResource +} + +// Get ... +func (c WebPubSubClient) Get(ctx context.Context, id WebPubSubId) (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 WebPubSubResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/method_hubscreateorupdate.go b/resource-manager/webpubsub/2024-03-01/webpubsub/method_hubscreateorupdate.go new file mode 100644 index 00000000000..a790728bc36 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/method_hubscreateorupdate.go @@ -0,0 +1,75 @@ +package webpubsub + +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 HubsCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *WebPubSubHub +} + +// HubsCreateOrUpdate ... +func (c WebPubSubClient) HubsCreateOrUpdate(ctx context.Context, id HubId, input WebPubSubHub) (result HubsCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// HubsCreateOrUpdateThenPoll performs HubsCreateOrUpdate then polls until it's completed +func (c WebPubSubClient) HubsCreateOrUpdateThenPoll(ctx context.Context, id HubId, input WebPubSubHub) error { + result, err := c.HubsCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing HubsCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after HubsCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/method_hubsdelete.go b/resource-manager/webpubsub/2024-03-01/webpubsub/method_hubsdelete.go new file mode 100644 index 00000000000..73d78731b24 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/method_hubsdelete.go @@ -0,0 +1,71 @@ +package webpubsub + +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 HubsDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// HubsDelete ... +func (c WebPubSubClient) HubsDelete(ctx context.Context, id HubId) (result HubsDeleteOperationResponse, 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 +} + +// HubsDeleteThenPoll performs HubsDelete then polls until it's completed +func (c WebPubSubClient) HubsDeleteThenPoll(ctx context.Context, id HubId) error { + result, err := c.HubsDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing HubsDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after HubsDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/method_hubsget.go b/resource-manager/webpubsub/2024-03-01/webpubsub/method_hubsget.go new file mode 100644 index 00000000000..75afae05de3 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/method_hubsget.go @@ -0,0 +1,54 @@ +package webpubsub + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HubsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WebPubSubHub +} + +// HubsGet ... +func (c WebPubSubClient) HubsGet(ctx context.Context, id HubId) (result HubsGetOperationResponse, 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 WebPubSubHub + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/method_hubslist.go b/resource-manager/webpubsub/2024-03-01/webpubsub/method_hubslist.go new file mode 100644 index 00000000000..d0e19d3da0e --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/method_hubslist.go @@ -0,0 +1,92 @@ +package webpubsub + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HubsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WebPubSubHub +} + +type HubsListCompleteResult struct { + LatestHttpResponse *http.Response + Items []WebPubSubHub +} + +// HubsList ... +func (c WebPubSubClient) HubsList(ctx context.Context, id WebPubSubId) (result HubsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/hubs", 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 *[]WebPubSubHub `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// HubsListComplete retrieves all the results into a single object +func (c WebPubSubClient) HubsListComplete(ctx context.Context, id WebPubSubId) (HubsListCompleteResult, error) { + return c.HubsListCompleteMatchingPredicate(ctx, id, WebPubSubHubOperationPredicate{}) +} + +// HubsListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebPubSubClient) HubsListCompleteMatchingPredicate(ctx context.Context, id WebPubSubId, predicate WebPubSubHubOperationPredicate) (result HubsListCompleteResult, err error) { + items := make([]WebPubSubHub, 0) + + resp, err := c.HubsList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = HubsListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/method_listbyresourcegroup.go b/resource-manager/webpubsub/2024-03-01/webpubsub/method_listbyresourcegroup.go new file mode 100644 index 00000000000..f2ae9bcec3d --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/method_listbyresourcegroup.go @@ -0,0 +1,93 @@ +package webpubsub + +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 *[]WebPubSubResource +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []WebPubSubResource +} + +// ListByResourceGroup ... +func (c WebPubSubClient) 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.SignalRService/webPubSub", 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 *[]WebPubSubResource `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 WebPubSubClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, WebPubSubResourceOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebPubSubClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate WebPubSubResourceOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]WebPubSubResource, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/method_listbysubscription.go b/resource-manager/webpubsub/2024-03-01/webpubsub/method_listbysubscription.go new file mode 100644 index 00000000000..4c5190e0b4b --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/method_listbysubscription.go @@ -0,0 +1,93 @@ +package webpubsub + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WebPubSubResource +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []WebPubSubResource +} + +// ListBySubscription ... +func (c WebPubSubClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.SignalRService/webPubSub", 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 *[]WebPubSubResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c WebPubSubClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, WebPubSubResourceOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebPubSubClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate WebPubSubResourceOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]WebPubSubResource, 0) + + resp, err := c.ListBySubscription(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/method_listkeys.go b/resource-manager/webpubsub/2024-03-01/webpubsub/method_listkeys.go new file mode 100644 index 00000000000..1f9b5d99b1a --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/method_listkeys.go @@ -0,0 +1,55 @@ +package webpubsub + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WebPubSubKeys +} + +// ListKeys ... +func (c WebPubSubClient) ListKeys(ctx context.Context, id WebPubSubId) (result ListKeysOperationResponse, 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 WebPubSubKeys + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/method_listreplicaskus.go b/resource-manager/webpubsub/2024-03-01/webpubsub/method_listreplicaskus.go new file mode 100644 index 00000000000..b17613cf2ba --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/method_listreplicaskus.go @@ -0,0 +1,92 @@ +package webpubsub + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListReplicaSkusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Sku +} + +type ListReplicaSkusCompleteResult struct { + LatestHttpResponse *http.Response + Items []Sku +} + +// ListReplicaSkus ... +func (c WebPubSubClient) ListReplicaSkus(ctx context.Context, id ReplicaId) (result ListReplicaSkusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/skus", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Sku `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListReplicaSkusComplete retrieves all the results into a single object +func (c WebPubSubClient) ListReplicaSkusComplete(ctx context.Context, id ReplicaId) (ListReplicaSkusCompleteResult, error) { + return c.ListReplicaSkusCompleteMatchingPredicate(ctx, id, SkuOperationPredicate{}) +} + +// ListReplicaSkusCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebPubSubClient) ListReplicaSkusCompleteMatchingPredicate(ctx context.Context, id ReplicaId, predicate SkuOperationPredicate) (result ListReplicaSkusCompleteResult, err error) { + items := make([]Sku, 0) + + resp, err := c.ListReplicaSkus(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListReplicaSkusCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/method_listskus.go b/resource-manager/webpubsub/2024-03-01/webpubsub/method_listskus.go new file mode 100644 index 00000000000..720e7f3b4b9 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/method_listskus.go @@ -0,0 +1,92 @@ +package webpubsub + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListSkusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Sku +} + +type ListSkusCompleteResult struct { + LatestHttpResponse *http.Response + Items []Sku +} + +// ListSkus ... +func (c WebPubSubClient) ListSkus(ctx context.Context, id WebPubSubId) (result ListSkusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/skus", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Sku `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSkusComplete retrieves all the results into a single object +func (c WebPubSubClient) ListSkusComplete(ctx context.Context, id WebPubSubId) (ListSkusCompleteResult, error) { + return c.ListSkusCompleteMatchingPredicate(ctx, id, SkuOperationPredicate{}) +} + +// ListSkusCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebPubSubClient) ListSkusCompleteMatchingPredicate(ctx context.Context, id WebPubSubId, predicate SkuOperationPredicate) (result ListSkusCompleteResult, err error) { + items := make([]Sku, 0) + + resp, err := c.ListSkus(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSkusCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/method_privateendpointconnectionsdelete.go b/resource-manager/webpubsub/2024-03-01/webpubsub/method_privateendpointconnectionsdelete.go new file mode 100644 index 00000000000..8eda7a0abdb --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/method_privateendpointconnectionsdelete.go @@ -0,0 +1,71 @@ +package webpubsub + +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 PrivateEndpointConnectionsDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// PrivateEndpointConnectionsDelete ... +func (c WebPubSubClient) PrivateEndpointConnectionsDelete(ctx context.Context, id PrivateEndpointConnectionId) (result PrivateEndpointConnectionsDeleteOperationResponse, 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 +} + +// PrivateEndpointConnectionsDeleteThenPoll performs PrivateEndpointConnectionsDelete then polls until it's completed +func (c WebPubSubClient) PrivateEndpointConnectionsDeleteThenPoll(ctx context.Context, id PrivateEndpointConnectionId) error { + result, err := c.PrivateEndpointConnectionsDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing PrivateEndpointConnectionsDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after PrivateEndpointConnectionsDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/method_privateendpointconnectionsget.go b/resource-manager/webpubsub/2024-03-01/webpubsub/method_privateendpointconnectionsget.go new file mode 100644 index 00000000000..5ef25c532d7 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/method_privateendpointconnectionsget.go @@ -0,0 +1,54 @@ +package webpubsub + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnection +} + +// PrivateEndpointConnectionsGet ... +func (c WebPubSubClient) PrivateEndpointConnectionsGet(ctx context.Context, id PrivateEndpointConnectionId) (result PrivateEndpointConnectionsGetOperationResponse, 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/webpubsub/2024-03-01/webpubsub/method_privateendpointconnectionslist.go b/resource-manager/webpubsub/2024-03-01/webpubsub/method_privateendpointconnectionslist.go new file mode 100644 index 00000000000..3f6d1c32ecb --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/method_privateendpointconnectionslist.go @@ -0,0 +1,92 @@ +package webpubsub + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PrivateEndpointConnection +} + +type PrivateEndpointConnectionsListCompleteResult struct { + LatestHttpResponse *http.Response + Items []PrivateEndpointConnection +} + +// PrivateEndpointConnectionsList ... +func (c WebPubSubClient) PrivateEndpointConnectionsList(ctx context.Context, id WebPubSubId) (result PrivateEndpointConnectionsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateEndpointConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PrivateEndpointConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// PrivateEndpointConnectionsListComplete retrieves all the results into a single object +func (c WebPubSubClient) PrivateEndpointConnectionsListComplete(ctx context.Context, id WebPubSubId) (PrivateEndpointConnectionsListCompleteResult, error) { + return c.PrivateEndpointConnectionsListCompleteMatchingPredicate(ctx, id, PrivateEndpointConnectionOperationPredicate{}) +} + +// PrivateEndpointConnectionsListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebPubSubClient) PrivateEndpointConnectionsListCompleteMatchingPredicate(ctx context.Context, id WebPubSubId, predicate PrivateEndpointConnectionOperationPredicate) (result PrivateEndpointConnectionsListCompleteResult, err error) { + items := make([]PrivateEndpointConnection, 0) + + resp, err := c.PrivateEndpointConnectionsList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = PrivateEndpointConnectionsListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/method_privateendpointconnectionsupdate.go b/resource-manager/webpubsub/2024-03-01/webpubsub/method_privateendpointconnectionsupdate.go new file mode 100644 index 00000000000..e7ec8ee1fff --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/method_privateendpointconnectionsupdate.go @@ -0,0 +1,58 @@ +package webpubsub + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionsUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnection +} + +// PrivateEndpointConnectionsUpdate ... +func (c WebPubSubClient) PrivateEndpointConnectionsUpdate(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) (result PrivateEndpointConnectionsUpdateOperationResponse, 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 PrivateEndpointConnection + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/method_privatelinkresourceslist.go b/resource-manager/webpubsub/2024-03-01/webpubsub/method_privatelinkresourceslist.go new file mode 100644 index 00000000000..4ec1e54a235 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/method_privatelinkresourceslist.go @@ -0,0 +1,92 @@ +package webpubsub + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourcesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PrivateLinkResource +} + +type PrivateLinkResourcesListCompleteResult struct { + LatestHttpResponse *http.Response + Items []PrivateLinkResource +} + +// PrivateLinkResourcesList ... +func (c WebPubSubClient) PrivateLinkResourcesList(ctx context.Context, id WebPubSubId) (result PrivateLinkResourcesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateLinkResources", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PrivateLinkResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// PrivateLinkResourcesListComplete retrieves all the results into a single object +func (c WebPubSubClient) PrivateLinkResourcesListComplete(ctx context.Context, id WebPubSubId) (PrivateLinkResourcesListCompleteResult, error) { + return c.PrivateLinkResourcesListCompleteMatchingPredicate(ctx, id, PrivateLinkResourceOperationPredicate{}) +} + +// PrivateLinkResourcesListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebPubSubClient) PrivateLinkResourcesListCompleteMatchingPredicate(ctx context.Context, id WebPubSubId, predicate PrivateLinkResourceOperationPredicate) (result PrivateLinkResourcesListCompleteResult, err error) { + items := make([]PrivateLinkResource, 0) + + resp, err := c.PrivateLinkResourcesList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = PrivateLinkResourcesListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/method_regeneratekey.go b/resource-manager/webpubsub/2024-03-01/webpubsub/method_regeneratekey.go new file mode 100644 index 00000000000..de1cc85d5af --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/method_regeneratekey.go @@ -0,0 +1,75 @@ +package webpubsub + +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 RegenerateKeyOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *WebPubSubKeys +} + +// RegenerateKey ... +func (c WebPubSubClient) RegenerateKey(ctx context.Context, id WebPubSubId, input RegenerateKeyParameters) (result RegenerateKeyOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/regenerateKey", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + 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 +} + +// RegenerateKeyThenPoll performs RegenerateKey then polls until it's completed +func (c WebPubSubClient) RegenerateKeyThenPoll(ctx context.Context, id WebPubSubId, input RegenerateKeyParameters) error { + result, err := c.RegenerateKey(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RegenerateKey: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RegenerateKey: %+v", err) + } + + return nil +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/method_replicascreateorupdate.go b/resource-manager/webpubsub/2024-03-01/webpubsub/method_replicascreateorupdate.go new file mode 100644 index 00000000000..0b164951117 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/method_replicascreateorupdate.go @@ -0,0 +1,75 @@ +package webpubsub + +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 ReplicasCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Replica +} + +// ReplicasCreateOrUpdate ... +func (c WebPubSubClient) ReplicasCreateOrUpdate(ctx context.Context, id ReplicaId, input Replica) (result ReplicasCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ReplicasCreateOrUpdateThenPoll performs ReplicasCreateOrUpdate then polls until it's completed +func (c WebPubSubClient) ReplicasCreateOrUpdateThenPoll(ctx context.Context, id ReplicaId, input Replica) error { + result, err := c.ReplicasCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ReplicasCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ReplicasCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/method_replicasdelete.go b/resource-manager/webpubsub/2024-03-01/webpubsub/method_replicasdelete.go new file mode 100644 index 00000000000..9b8eea4d889 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/method_replicasdelete.go @@ -0,0 +1,47 @@ +package webpubsub + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicasDeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ReplicasDelete ... +func (c WebPubSubClient) ReplicasDelete(ctx context.Context, id ReplicaId) (result ReplicasDeleteOperationResponse, 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/webpubsub/2024-03-01/webpubsub/method_replicasget.go b/resource-manager/webpubsub/2024-03-01/webpubsub/method_replicasget.go new file mode 100644 index 00000000000..33c7f26d47e --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/method_replicasget.go @@ -0,0 +1,54 @@ +package webpubsub + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicasGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Replica +} + +// ReplicasGet ... +func (c WebPubSubClient) ReplicasGet(ctx context.Context, id ReplicaId) (result ReplicasGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Replica + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/method_replicasharedprivatelinkresourcescreateorupdate.go b/resource-manager/webpubsub/2024-03-01/webpubsub/method_replicasharedprivatelinkresourcescreateorupdate.go new file mode 100644 index 00000000000..e5d2498bfac --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/method_replicasharedprivatelinkresourcescreateorupdate.go @@ -0,0 +1,75 @@ +package webpubsub + +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 ReplicaSharedPrivateLinkResourcesCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SharedPrivateLinkResource +} + +// ReplicaSharedPrivateLinkResourcesCreateOrUpdate ... +func (c WebPubSubClient) ReplicaSharedPrivateLinkResourcesCreateOrUpdate(ctx context.Context, id ReplicaSharedPrivateLinkResourceId, input SharedPrivateLinkResource) (result ReplicaSharedPrivateLinkResourcesCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ReplicaSharedPrivateLinkResourcesCreateOrUpdateThenPoll performs ReplicaSharedPrivateLinkResourcesCreateOrUpdate then polls until it's completed +func (c WebPubSubClient) ReplicaSharedPrivateLinkResourcesCreateOrUpdateThenPoll(ctx context.Context, id ReplicaSharedPrivateLinkResourceId, input SharedPrivateLinkResource) error { + result, err := c.ReplicaSharedPrivateLinkResourcesCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ReplicaSharedPrivateLinkResourcesCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ReplicaSharedPrivateLinkResourcesCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/method_replicasharedprivatelinkresourcesget.go b/resource-manager/webpubsub/2024-03-01/webpubsub/method_replicasharedprivatelinkresourcesget.go new file mode 100644 index 00000000000..2d12df1bbef --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/method_replicasharedprivatelinkresourcesget.go @@ -0,0 +1,54 @@ +package webpubsub + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicaSharedPrivateLinkResourcesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SharedPrivateLinkResource +} + +// ReplicaSharedPrivateLinkResourcesGet ... +func (c WebPubSubClient) ReplicaSharedPrivateLinkResourcesGet(ctx context.Context, id ReplicaSharedPrivateLinkResourceId) (result ReplicaSharedPrivateLinkResourcesGetOperationResponse, 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 SharedPrivateLinkResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/method_replicasharedprivatelinkresourceslist.go b/resource-manager/webpubsub/2024-03-01/webpubsub/method_replicasharedprivatelinkresourceslist.go new file mode 100644 index 00000000000..d6ee1c0dd7e --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/method_replicasharedprivatelinkresourceslist.go @@ -0,0 +1,92 @@ +package webpubsub + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicaSharedPrivateLinkResourcesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SharedPrivateLinkResource +} + +type ReplicaSharedPrivateLinkResourcesListCompleteResult struct { + LatestHttpResponse *http.Response + Items []SharedPrivateLinkResource +} + +// ReplicaSharedPrivateLinkResourcesList ... +func (c WebPubSubClient) ReplicaSharedPrivateLinkResourcesList(ctx context.Context, id ReplicaId) (result ReplicaSharedPrivateLinkResourcesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/sharedPrivateLinkResources", 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 *[]SharedPrivateLinkResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ReplicaSharedPrivateLinkResourcesListComplete retrieves all the results into a single object +func (c WebPubSubClient) ReplicaSharedPrivateLinkResourcesListComplete(ctx context.Context, id ReplicaId) (ReplicaSharedPrivateLinkResourcesListCompleteResult, error) { + return c.ReplicaSharedPrivateLinkResourcesListCompleteMatchingPredicate(ctx, id, SharedPrivateLinkResourceOperationPredicate{}) +} + +// ReplicaSharedPrivateLinkResourcesListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebPubSubClient) ReplicaSharedPrivateLinkResourcesListCompleteMatchingPredicate(ctx context.Context, id ReplicaId, predicate SharedPrivateLinkResourceOperationPredicate) (result ReplicaSharedPrivateLinkResourcesListCompleteResult, err error) { + items := make([]SharedPrivateLinkResource, 0) + + resp, err := c.ReplicaSharedPrivateLinkResourcesList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ReplicaSharedPrivateLinkResourcesListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/method_replicaslist.go b/resource-manager/webpubsub/2024-03-01/webpubsub/method_replicaslist.go new file mode 100644 index 00000000000..0d91ea46087 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/method_replicaslist.go @@ -0,0 +1,92 @@ +package webpubsub + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicasListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Replica +} + +type ReplicasListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Replica +} + +// ReplicasList ... +func (c WebPubSubClient) ReplicasList(ctx context.Context, id WebPubSubId) (result ReplicasListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/replicas", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Replica `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ReplicasListComplete retrieves all the results into a single object +func (c WebPubSubClient) ReplicasListComplete(ctx context.Context, id WebPubSubId) (ReplicasListCompleteResult, error) { + return c.ReplicasListCompleteMatchingPredicate(ctx, id, ReplicaOperationPredicate{}) +} + +// ReplicasListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebPubSubClient) ReplicasListCompleteMatchingPredicate(ctx context.Context, id WebPubSubId, predicate ReplicaOperationPredicate) (result ReplicasListCompleteResult, err error) { + items := make([]Replica, 0) + + resp, err := c.ReplicasList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ReplicasListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/method_replicasrestart.go b/resource-manager/webpubsub/2024-03-01/webpubsub/method_replicasrestart.go new file mode 100644 index 00000000000..5d1e484a2de --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/method_replicasrestart.go @@ -0,0 +1,70 @@ +package webpubsub + +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 ReplicasRestartOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ReplicasRestart ... +func (c WebPubSubClient) ReplicasRestart(ctx context.Context, id ReplicaId) (result ReplicasRestartOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restart", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ReplicasRestartThenPoll performs ReplicasRestart then polls until it's completed +func (c WebPubSubClient) ReplicasRestartThenPoll(ctx context.Context, id ReplicaId) error { + result, err := c.ReplicasRestart(ctx, id) + if err != nil { + return fmt.Errorf("performing ReplicasRestart: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ReplicasRestart: %+v", err) + } + + return nil +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/method_replicasupdate.go b/resource-manager/webpubsub/2024-03-01/webpubsub/method_replicasupdate.go new file mode 100644 index 00000000000..66fc21776ea --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/method_replicasupdate.go @@ -0,0 +1,75 @@ +package webpubsub + +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 ReplicasUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Replica +} + +// ReplicasUpdate ... +func (c WebPubSubClient) ReplicasUpdate(ctx context.Context, id ReplicaId, input Replica) (result ReplicasUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ReplicasUpdateThenPoll performs ReplicasUpdate then polls until it's completed +func (c WebPubSubClient) ReplicasUpdateThenPoll(ctx context.Context, id ReplicaId, input Replica) error { + result, err := c.ReplicasUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ReplicasUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ReplicasUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/method_restart.go b/resource-manager/webpubsub/2024-03-01/webpubsub/method_restart.go new file mode 100644 index 00000000000..1dccc25a857 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/method_restart.go @@ -0,0 +1,70 @@ +package webpubsub + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestartOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Restart ... +func (c WebPubSubClient) Restart(ctx context.Context, id WebPubSubId) (result RestartOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restart", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RestartThenPoll performs Restart then polls until it's completed +func (c WebPubSubClient) RestartThenPoll(ctx context.Context, id WebPubSubId) error { + result, err := c.Restart(ctx, id) + if err != nil { + return fmt.Errorf("performing Restart: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Restart: %+v", err) + } + + return nil +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/method_sharedprivatelinkresourcescreateorupdate.go b/resource-manager/webpubsub/2024-03-01/webpubsub/method_sharedprivatelinkresourcescreateorupdate.go new file mode 100644 index 00000000000..05377788613 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/method_sharedprivatelinkresourcescreateorupdate.go @@ -0,0 +1,75 @@ +package webpubsub + +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 SharedPrivateLinkResourcesCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SharedPrivateLinkResource +} + +// SharedPrivateLinkResourcesCreateOrUpdate ... +func (c WebPubSubClient) SharedPrivateLinkResourcesCreateOrUpdate(ctx context.Context, id SharedPrivateLinkResourceId, input SharedPrivateLinkResource) (result SharedPrivateLinkResourcesCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// SharedPrivateLinkResourcesCreateOrUpdateThenPoll performs SharedPrivateLinkResourcesCreateOrUpdate then polls until it's completed +func (c WebPubSubClient) SharedPrivateLinkResourcesCreateOrUpdateThenPoll(ctx context.Context, id SharedPrivateLinkResourceId, input SharedPrivateLinkResource) error { + result, err := c.SharedPrivateLinkResourcesCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing SharedPrivateLinkResourcesCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SharedPrivateLinkResourcesCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/method_sharedprivatelinkresourcesdelete.go b/resource-manager/webpubsub/2024-03-01/webpubsub/method_sharedprivatelinkresourcesdelete.go new file mode 100644 index 00000000000..c0e985619ed --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/method_sharedprivatelinkresourcesdelete.go @@ -0,0 +1,71 @@ +package webpubsub + +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 SharedPrivateLinkResourcesDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// SharedPrivateLinkResourcesDelete ... +func (c WebPubSubClient) SharedPrivateLinkResourcesDelete(ctx context.Context, id SharedPrivateLinkResourceId) (result SharedPrivateLinkResourcesDeleteOperationResponse, 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 +} + +// SharedPrivateLinkResourcesDeleteThenPoll performs SharedPrivateLinkResourcesDelete then polls until it's completed +func (c WebPubSubClient) SharedPrivateLinkResourcesDeleteThenPoll(ctx context.Context, id SharedPrivateLinkResourceId) error { + result, err := c.SharedPrivateLinkResourcesDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing SharedPrivateLinkResourcesDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SharedPrivateLinkResourcesDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/method_sharedprivatelinkresourcesget.go b/resource-manager/webpubsub/2024-03-01/webpubsub/method_sharedprivatelinkresourcesget.go new file mode 100644 index 00000000000..b48243eb18f --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/method_sharedprivatelinkresourcesget.go @@ -0,0 +1,54 @@ +package webpubsub + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SharedPrivateLinkResourcesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SharedPrivateLinkResource +} + +// SharedPrivateLinkResourcesGet ... +func (c WebPubSubClient) SharedPrivateLinkResourcesGet(ctx context.Context, id SharedPrivateLinkResourceId) (result SharedPrivateLinkResourcesGetOperationResponse, 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 SharedPrivateLinkResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/method_sharedprivatelinkresourceslist.go b/resource-manager/webpubsub/2024-03-01/webpubsub/method_sharedprivatelinkresourceslist.go new file mode 100644 index 00000000000..3d12753e7df --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/method_sharedprivatelinkresourceslist.go @@ -0,0 +1,92 @@ +package webpubsub + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SharedPrivateLinkResourcesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SharedPrivateLinkResource +} + +type SharedPrivateLinkResourcesListCompleteResult struct { + LatestHttpResponse *http.Response + Items []SharedPrivateLinkResource +} + +// SharedPrivateLinkResourcesList ... +func (c WebPubSubClient) SharedPrivateLinkResourcesList(ctx context.Context, id WebPubSubId) (result SharedPrivateLinkResourcesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/sharedPrivateLinkResources", 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 *[]SharedPrivateLinkResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// SharedPrivateLinkResourcesListComplete retrieves all the results into a single object +func (c WebPubSubClient) SharedPrivateLinkResourcesListComplete(ctx context.Context, id WebPubSubId) (SharedPrivateLinkResourcesListCompleteResult, error) { + return c.SharedPrivateLinkResourcesListCompleteMatchingPredicate(ctx, id, SharedPrivateLinkResourceOperationPredicate{}) +} + +// SharedPrivateLinkResourcesListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebPubSubClient) SharedPrivateLinkResourcesListCompleteMatchingPredicate(ctx context.Context, id WebPubSubId, predicate SharedPrivateLinkResourceOperationPredicate) (result SharedPrivateLinkResourcesListCompleteResult, err error) { + items := make([]SharedPrivateLinkResource, 0) + + resp, err := c.SharedPrivateLinkResourcesList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = SharedPrivateLinkResourcesListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/method_update.go b/resource-manager/webpubsub/2024-03-01/webpubsub/method_update.go new file mode 100644 index 00000000000..9af6f957048 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/method_update.go @@ -0,0 +1,75 @@ +package webpubsub + +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 *WebPubSubResource +} + +// Update ... +func (c WebPubSubClient) Update(ctx context.Context, id WebPubSubId, input WebPubSubResource) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c WebPubSubClient) UpdateThenPoll(ctx context.Context, id WebPubSubId, input WebPubSubResource) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/method_usageslist.go b/resource-manager/webpubsub/2024-03-01/webpubsub/method_usageslist.go new file mode 100644 index 00000000000..47ef8d96d18 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/method_usageslist.go @@ -0,0 +1,92 @@ +package webpubsub + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UsagesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SignalRServiceUsage +} + +type UsagesListCompleteResult struct { + LatestHttpResponse *http.Response + Items []SignalRServiceUsage +} + +// UsagesList ... +func (c WebPubSubClient) UsagesList(ctx context.Context, id LocationId) (result UsagesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/usages", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SignalRServiceUsage `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// UsagesListComplete retrieves all the results into a single object +func (c WebPubSubClient) UsagesListComplete(ctx context.Context, id LocationId) (UsagesListCompleteResult, error) { + return c.UsagesListCompleteMatchingPredicate(ctx, id, SignalRServiceUsageOperationPredicate{}) +} + +// UsagesListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebPubSubClient) UsagesListCompleteMatchingPredicate(ctx context.Context, id LocationId, predicate SignalRServiceUsageOperationPredicate) (result UsagesListCompleteResult, err error) { + items := make([]SignalRServiceUsage, 0) + + resp, err := c.UsagesList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = UsagesListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/model_customcertificate.go b/resource-manager/webpubsub/2024-03-01/webpubsub/model_customcertificate.go new file mode 100644 index 00000000000..34ae5c01616 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/model_customcertificate.go @@ -0,0 +1,16 @@ +package webpubsub + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomCertificate struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties CustomCertificateProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/model_customcertificateproperties.go b/resource-manager/webpubsub/2024-03-01/webpubsub/model_customcertificateproperties.go new file mode 100644 index 00000000000..575e62cf8db --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/model_customcertificateproperties.go @@ -0,0 +1,11 @@ +package webpubsub + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomCertificateProperties struct { + KeyVaultBaseUri string `json:"keyVaultBaseUri"` + KeyVaultSecretName string `json:"keyVaultSecretName"` + KeyVaultSecretVersion *string `json:"keyVaultSecretVersion,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/model_customdomain.go b/resource-manager/webpubsub/2024-03-01/webpubsub/model_customdomain.go new file mode 100644 index 00000000000..88b7f901e11 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/model_customdomain.go @@ -0,0 +1,16 @@ +package webpubsub + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomDomain struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties CustomDomainProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/model_customdomainproperties.go b/resource-manager/webpubsub/2024-03-01/webpubsub/model_customdomainproperties.go new file mode 100644 index 00000000000..9d174af7c37 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/model_customdomainproperties.go @@ -0,0 +1,10 @@ +package webpubsub + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomDomainProperties struct { + CustomCertificate ResourceReference `json:"customCertificate"` + DomainName string `json:"domainName"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/model_eventhandler.go b/resource-manager/webpubsub/2024-03-01/webpubsub/model_eventhandler.go new file mode 100644 index 00000000000..40e7c23a86c --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/model_eventhandler.go @@ -0,0 +1,11 @@ +package webpubsub + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EventHandler struct { + Auth *UpstreamAuthSettings `json:"auth,omitempty"` + SystemEvents *[]string `json:"systemEvents,omitempty"` + UrlTemplate string `json:"urlTemplate"` + UserEventPattern *string `json:"userEventPattern,omitempty"` +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/model_eventhubendpoint.go b/resource-manager/webpubsub/2024-03-01/webpubsub/model_eventhubendpoint.go new file mode 100644 index 00000000000..b4b3bfbb021 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/model_eventhubendpoint.go @@ -0,0 +1,42 @@ +package webpubsub + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ EventListenerEndpoint = EventHubEndpoint{} + +type EventHubEndpoint struct { + EventHubName string `json:"eventHubName"` + FullyQualifiedNamespace string `json:"fullyQualifiedNamespace"` + + // Fields inherited from EventListenerEndpoint +} + +var _ json.Marshaler = EventHubEndpoint{} + +func (s EventHubEndpoint) MarshalJSON() ([]byte, error) { + type wrapper EventHubEndpoint + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling EventHubEndpoint: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling EventHubEndpoint: %+v", err) + } + decoded["type"] = "EventHub" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling EventHubEndpoint: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/model_eventlistener.go b/resource-manager/webpubsub/2024-03-01/webpubsub/model_eventlistener.go new file mode 100644 index 00000000000..90cf91c8ab5 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/model_eventlistener.go @@ -0,0 +1,41 @@ +package webpubsub + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EventListener struct { + Endpoint EventListenerEndpoint `json:"endpoint"` + Filter EventListenerFilter `json:"filter"` +} + +var _ json.Unmarshaler = &EventListener{} + +func (s *EventListener) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling EventListener into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["endpoint"]; ok { + impl, err := unmarshalEventListenerEndpointImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Endpoint' for 'EventListener': %+v", err) + } + s.Endpoint = impl + } + + if v, ok := temp["filter"]; ok { + impl, err := unmarshalEventListenerFilterImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Filter' for 'EventListener': %+v", err) + } + s.Filter = impl + } + return nil +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/model_eventlistenerendpoint.go b/resource-manager/webpubsub/2024-03-01/webpubsub/model_eventlistenerendpoint.go new file mode 100644 index 00000000000..ce6a41e8688 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/model_eventlistenerendpoint.go @@ -0,0 +1,53 @@ +package webpubsub + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EventListenerEndpoint interface { +} + +// RawEventListenerEndpointImpl is returned when the Discriminated Value +// doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawEventListenerEndpointImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalEventListenerEndpointImplementation(input []byte) (EventListenerEndpoint, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling EventListenerEndpoint into map[string]interface: %+v", err) + } + + value, ok := temp["type"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "EventHub") { + var out EventHubEndpoint + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into EventHubEndpoint: %+v", err) + } + return out, nil + } + + out := RawEventListenerEndpointImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/model_eventlistenerfilter.go b/resource-manager/webpubsub/2024-03-01/webpubsub/model_eventlistenerfilter.go new file mode 100644 index 00000000000..113e67a18be --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/model_eventlistenerfilter.go @@ -0,0 +1,53 @@ +package webpubsub + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EventListenerFilter interface { +} + +// RawEventListenerFilterImpl is returned when the Discriminated Value +// doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawEventListenerFilterImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalEventListenerFilterImplementation(input []byte) (EventListenerFilter, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling EventListenerFilter into map[string]interface: %+v", err) + } + + value, ok := temp["type"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "EventName") { + var out EventNameFilter + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into EventNameFilter: %+v", err) + } + return out, nil + } + + out := RawEventListenerFilterImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/model_eventnamefilter.go b/resource-manager/webpubsub/2024-03-01/webpubsub/model_eventnamefilter.go new file mode 100644 index 00000000000..463f1dc90e6 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/model_eventnamefilter.go @@ -0,0 +1,42 @@ +package webpubsub + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ EventListenerFilter = EventNameFilter{} + +type EventNameFilter struct { + SystemEvents *[]string `json:"systemEvents,omitempty"` + UserEventPattern *string `json:"userEventPattern,omitempty"` + + // Fields inherited from EventListenerFilter +} + +var _ json.Marshaler = EventNameFilter{} + +func (s EventNameFilter) MarshalJSON() ([]byte, error) { + type wrapper EventNameFilter + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling EventNameFilter: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling EventNameFilter: %+v", err) + } + decoded["type"] = "EventName" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling EventNameFilter: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/model_iprule.go b/resource-manager/webpubsub/2024-03-01/webpubsub/model_iprule.go new file mode 100644 index 00000000000..6082f3ce062 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/model_iprule.go @@ -0,0 +1,9 @@ +package webpubsub + +// 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 *ACLAction `json:"action,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/model_livetracecategory.go b/resource-manager/webpubsub/2024-03-01/webpubsub/model_livetracecategory.go new file mode 100644 index 00000000000..ff3f83b52fd --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/model_livetracecategory.go @@ -0,0 +1,9 @@ +package webpubsub + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LiveTraceCategory struct { + Enabled *string `json:"enabled,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/model_livetraceconfiguration.go b/resource-manager/webpubsub/2024-03-01/webpubsub/model_livetraceconfiguration.go new file mode 100644 index 00000000000..77ef6113750 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/model_livetraceconfiguration.go @@ -0,0 +1,9 @@ +package webpubsub + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LiveTraceConfiguration struct { + Categories *[]LiveTraceCategory `json:"categories,omitempty"` + Enabled *string `json:"enabled,omitempty"` +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/model_managedidentitysettings.go b/resource-manager/webpubsub/2024-03-01/webpubsub/model_managedidentitysettings.go new file mode 100644 index 00000000000..b7f74ab307d --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/model_managedidentitysettings.go @@ -0,0 +1,8 @@ +package webpubsub + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedIdentitySettings struct { + Resource *string `json:"resource,omitempty"` +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/model_nameavailability.go b/resource-manager/webpubsub/2024-03-01/webpubsub/model_nameavailability.go new file mode 100644 index 00000000000..0fe7d3a1e28 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/model_nameavailability.go @@ -0,0 +1,10 @@ +package webpubsub + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NameAvailability struct { + Message *string `json:"message,omitempty"` + NameAvailable *bool `json:"nameAvailable,omitempty"` + Reason *string `json:"reason,omitempty"` +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/model_nameavailabilityparameters.go b/resource-manager/webpubsub/2024-03-01/webpubsub/model_nameavailabilityparameters.go new file mode 100644 index 00000000000..25cb3ef8050 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/model_nameavailabilityparameters.go @@ -0,0 +1,9 @@ +package webpubsub + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NameAvailabilityParameters struct { + Name string `json:"name"` + Type string `json:"type"` +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/model_networkacl.go b/resource-manager/webpubsub/2024-03-01/webpubsub/model_networkacl.go new file mode 100644 index 00000000000..094d10f8585 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/model_networkacl.go @@ -0,0 +1,9 @@ +package webpubsub + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkACL struct { + Allow *[]WebPubSubRequestType `json:"allow,omitempty"` + Deny *[]WebPubSubRequestType `json:"deny,omitempty"` +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/model_privateendpoint.go b/resource-manager/webpubsub/2024-03-01/webpubsub/model_privateendpoint.go new file mode 100644 index 00000000000..8f4efa3fed6 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/model_privateendpoint.go @@ -0,0 +1,8 @@ +package webpubsub + +// 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/webpubsub/2024-03-01/webpubsub/model_privateendpointacl.go b/resource-manager/webpubsub/2024-03-01/webpubsub/model_privateendpointacl.go new file mode 100644 index 00000000000..f67306d29fc --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/model_privateendpointacl.go @@ -0,0 +1,10 @@ +package webpubsub + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointACL struct { + Allow *[]WebPubSubRequestType `json:"allow,omitempty"` + Deny *[]WebPubSubRequestType `json:"deny,omitempty"` + Name string `json:"name"` +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/model_privateendpointconnection.go b/resource-manager/webpubsub/2024-03-01/webpubsub/model_privateendpointconnection.go new file mode 100644 index 00000000000..aa992a97737 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/model_privateendpointconnection.go @@ -0,0 +1,16 @@ +package webpubsub + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/model_privateendpointconnectionproperties.go b/resource-manager/webpubsub/2024-03-01/webpubsub/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..33dbc1679d1 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/model_privateendpointconnectionproperties.go @@ -0,0 +1,11 @@ +package webpubsub + +// 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 *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/model_privatelinkresource.go b/resource-manager/webpubsub/2024-03-01/webpubsub/model_privatelinkresource.go new file mode 100644 index 00000000000..7eab39926a3 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/model_privatelinkresource.go @@ -0,0 +1,16 @@ +package webpubsub + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkResourceProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/model_privatelinkresourceproperties.go b/resource-manager/webpubsub/2024-03-01/webpubsub/model_privatelinkresourceproperties.go new file mode 100644 index 00000000000..b5a4a0b2bff --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/model_privatelinkresourceproperties.go @@ -0,0 +1,11 @@ +package webpubsub + +// 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"` + ShareablePrivateLinkResourceTypes *[]ShareablePrivateLinkResourceType `json:"shareablePrivateLinkResourceTypes,omitempty"` +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/model_privatelinkserviceconnectionstate.go b/resource-manager/webpubsub/2024-03-01/webpubsub/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..8fc24854c88 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package webpubsub + +// 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,omitempty"` +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/model_regeneratekeyparameters.go b/resource-manager/webpubsub/2024-03-01/webpubsub/model_regeneratekeyparameters.go new file mode 100644 index 00000000000..ba779dc889c --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/model_regeneratekeyparameters.go @@ -0,0 +1,8 @@ +package webpubsub + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegenerateKeyParameters struct { + KeyType *KeyType `json:"keyType,omitempty"` +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/model_replica.go b/resource-manager/webpubsub/2024-03-01/webpubsub/model_replica.go new file mode 100644 index 00000000000..fddeff9b3ca --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/model_replica.go @@ -0,0 +1,19 @@ +package webpubsub + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Replica struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *ReplicaProperties `json:"properties,omitempty"` + Sku *ResourceSku `json:"sku,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/model_replicaproperties.go b/resource-manager/webpubsub/2024-03-01/webpubsub/model_replicaproperties.go new file mode 100644 index 00000000000..66bc03f4f48 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/model_replicaproperties.go @@ -0,0 +1,10 @@ +package webpubsub + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicaProperties struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RegionEndpointEnabled *string `json:"regionEndpointEnabled,omitempty"` + ResourceStopped *string `json:"resourceStopped,omitempty"` +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/model_resourcelogcategory.go b/resource-manager/webpubsub/2024-03-01/webpubsub/model_resourcelogcategory.go new file mode 100644 index 00000000000..d0c22062b89 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/model_resourcelogcategory.go @@ -0,0 +1,9 @@ +package webpubsub + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceLogCategory struct { + Enabled *string `json:"enabled,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/model_resourcelogconfiguration.go b/resource-manager/webpubsub/2024-03-01/webpubsub/model_resourcelogconfiguration.go new file mode 100644 index 00000000000..32bc381d5e3 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/model_resourcelogconfiguration.go @@ -0,0 +1,8 @@ +package webpubsub + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceLogConfiguration struct { + Categories *[]ResourceLogCategory `json:"categories,omitempty"` +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/model_resourcereference.go b/resource-manager/webpubsub/2024-03-01/webpubsub/model_resourcereference.go new file mode 100644 index 00000000000..840024a75cb --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/model_resourcereference.go @@ -0,0 +1,8 @@ +package webpubsub + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceReference struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/model_resourcesku.go b/resource-manager/webpubsub/2024-03-01/webpubsub/model_resourcesku.go new file mode 100644 index 00000000000..d8c057983d9 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/model_resourcesku.go @@ -0,0 +1,12 @@ +package webpubsub + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceSku struct { + Capacity *int64 `json:"capacity,omitempty"` + Family *string `json:"family,omitempty"` + Name string `json:"name"` + Size *string `json:"size,omitempty"` + Tier *WebPubSubSkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/model_shareableprivatelinkresourceproperties.go b/resource-manager/webpubsub/2024-03-01/webpubsub/model_shareableprivatelinkresourceproperties.go new file mode 100644 index 00000000000..087f82ce696 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/model_shareableprivatelinkresourceproperties.go @@ -0,0 +1,10 @@ +package webpubsub + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ShareablePrivateLinkResourceProperties struct { + Description *string `json:"description,omitempty"` + GroupId *string `json:"groupId,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/model_shareableprivatelinkresourcetype.go b/resource-manager/webpubsub/2024-03-01/webpubsub/model_shareableprivatelinkresourcetype.go new file mode 100644 index 00000000000..28dca622f86 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/model_shareableprivatelinkresourcetype.go @@ -0,0 +1,9 @@ +package webpubsub + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ShareablePrivateLinkResourceType struct { + Name *string `json:"name,omitempty"` + Properties *ShareablePrivateLinkResourceProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/model_sharedprivatelinkresource.go b/resource-manager/webpubsub/2024-03-01/webpubsub/model_sharedprivatelinkresource.go new file mode 100644 index 00000000000..c88fe5206b6 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/model_sharedprivatelinkresource.go @@ -0,0 +1,16 @@ +package webpubsub + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SharedPrivateLinkResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SharedPrivateLinkResourceProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/model_sharedprivatelinkresourceproperties.go b/resource-manager/webpubsub/2024-03-01/webpubsub/model_sharedprivatelinkresourceproperties.go new file mode 100644 index 00000000000..2dc1a04a7f0 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/model_sharedprivatelinkresourceproperties.go @@ -0,0 +1,12 @@ +package webpubsub + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SharedPrivateLinkResourceProperties struct { + GroupId string `json:"groupId"` + PrivateLinkResourceId string `json:"privateLinkResourceId"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RequestMessage *string `json:"requestMessage,omitempty"` + Status *SharedPrivateLinkResourceStatus `json:"status,omitempty"` +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/model_signalrserviceusage.go b/resource-manager/webpubsub/2024-03-01/webpubsub/model_signalrserviceusage.go new file mode 100644 index 00000000000..be99716017d --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/model_signalrserviceusage.go @@ -0,0 +1,12 @@ +package webpubsub + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SignalRServiceUsage struct { + CurrentValue *int64 `json:"currentValue,omitempty"` + Id *string `json:"id,omitempty"` + Limit *int64 `json:"limit,omitempty"` + Name *SignalRServiceUsageName `json:"name,omitempty"` + Unit *string `json:"unit,omitempty"` +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/model_signalrserviceusagename.go b/resource-manager/webpubsub/2024-03-01/webpubsub/model_signalrserviceusagename.go new file mode 100644 index 00000000000..5a9e390b6e0 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/model_signalrserviceusagename.go @@ -0,0 +1,9 @@ +package webpubsub + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SignalRServiceUsageName struct { + LocalizedValue *string `json:"localizedValue,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/model_sku.go b/resource-manager/webpubsub/2024-03-01/webpubsub/model_sku.go new file mode 100644 index 00000000000..e1b1b8cca15 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/model_sku.go @@ -0,0 +1,10 @@ +package webpubsub + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Sku struct { + Capacity *SkuCapacity `json:"capacity,omitempty"` + ResourceType *string `json:"resourceType,omitempty"` + Sku *ResourceSku `json:"sku,omitempty"` +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/model_skucapacity.go b/resource-manager/webpubsub/2024-03-01/webpubsub/model_skucapacity.go new file mode 100644 index 00000000000..40b1840f099 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/model_skucapacity.go @@ -0,0 +1,12 @@ +package webpubsub + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SkuCapacity struct { + AllowedValues *[]int64 `json:"allowedValues,omitempty"` + Default *int64 `json:"default,omitempty"` + Maximum *int64 `json:"maximum,omitempty"` + Minimum *int64 `json:"minimum,omitempty"` + ScaleType *ScaleType `json:"scaleType,omitempty"` +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/model_upstreamauthsettings.go b/resource-manager/webpubsub/2024-03-01/webpubsub/model_upstreamauthsettings.go new file mode 100644 index 00000000000..14040c68d7b --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/model_upstreamauthsettings.go @@ -0,0 +1,9 @@ +package webpubsub + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpstreamAuthSettings struct { + ManagedIdentity *ManagedIdentitySettings `json:"managedIdentity,omitempty"` + Type *UpstreamAuthType `json:"type,omitempty"` +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/model_webpubsubhub.go b/resource-manager/webpubsub/2024-03-01/webpubsub/model_webpubsubhub.go new file mode 100644 index 00000000000..be327da6dd0 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/model_webpubsubhub.go @@ -0,0 +1,16 @@ +package webpubsub + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebPubSubHub struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties WebPubSubHubProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/model_webpubsubhubproperties.go b/resource-manager/webpubsub/2024-03-01/webpubsub/model_webpubsubhubproperties.go new file mode 100644 index 00000000000..ecb0c26e83f --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/model_webpubsubhubproperties.go @@ -0,0 +1,11 @@ +package webpubsub + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebPubSubHubProperties struct { + AnonymousConnectPolicy *string `json:"anonymousConnectPolicy,omitempty"` + EventHandlers *[]EventHandler `json:"eventHandlers,omitempty"` + EventListeners *[]EventListener `json:"eventListeners,omitempty"` + WebSocketKeepAliveIntervalInSeconds *int64 `json:"webSocketKeepAliveIntervalInSeconds,omitempty"` +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/model_webpubsubkeys.go b/resource-manager/webpubsub/2024-03-01/webpubsub/model_webpubsubkeys.go new file mode 100644 index 00000000000..3b4c98384f0 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/model_webpubsubkeys.go @@ -0,0 +1,11 @@ +package webpubsub + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebPubSubKeys struct { + PrimaryConnectionString *string `json:"primaryConnectionString,omitempty"` + PrimaryKey *string `json:"primaryKey,omitempty"` + SecondaryConnectionString *string `json:"secondaryConnectionString,omitempty"` + SecondaryKey *string `json:"secondaryKey,omitempty"` +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/model_webpubsubnetworkacls.go b/resource-manager/webpubsub/2024-03-01/webpubsub/model_webpubsubnetworkacls.go new file mode 100644 index 00000000000..daa4ce9dd65 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/model_webpubsubnetworkacls.go @@ -0,0 +1,11 @@ +package webpubsub + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebPubSubNetworkACLs struct { + DefaultAction *ACLAction `json:"defaultAction,omitempty"` + IPRules *[]IPRule `json:"ipRules,omitempty"` + PrivateEndpoints *[]PrivateEndpointACL `json:"privateEndpoints,omitempty"` + PublicNetwork *NetworkACL `json:"publicNetwork,omitempty"` +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/model_webpubsubproperties.go b/resource-manager/webpubsub/2024-03-01/webpubsub/model_webpubsubproperties.go new file mode 100644 index 00000000000..94da8b9243b --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/model_webpubsubproperties.go @@ -0,0 +1,26 @@ +package webpubsub + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebPubSubProperties struct { + DisableAadAuth *bool `json:"disableAadAuth,omitempty"` + DisableLocalAuth *bool `json:"disableLocalAuth,omitempty"` + ExternalIP *string `json:"externalIP,omitempty"` + HostName *string `json:"hostName,omitempty"` + HostNamePrefix *string `json:"hostNamePrefix,omitempty"` + LiveTraceConfiguration *LiveTraceConfiguration `json:"liveTraceConfiguration,omitempty"` + NetworkACLs *WebPubSubNetworkACLs `json:"networkACLs,omitempty"` + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicNetworkAccess *string `json:"publicNetworkAccess,omitempty"` + PublicPort *int64 `json:"publicPort,omitempty"` + RegionEndpointEnabled *string `json:"regionEndpointEnabled,omitempty"` + ResourceLogConfiguration *ResourceLogConfiguration `json:"resourceLogConfiguration,omitempty"` + ResourceStopped *string `json:"resourceStopped,omitempty"` + ServerPort *int64 `json:"serverPort,omitempty"` + SharedPrivateLinkResources *[]SharedPrivateLinkResource `json:"sharedPrivateLinkResources,omitempty"` + SocketIO *WebPubSubSocketIOSettings `json:"socketIO,omitempty"` + Tls *WebPubSubTlsSettings `json:"tls,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/model_webpubsubresource.go b/resource-manager/webpubsub/2024-03-01/webpubsub/model_webpubsubresource.go new file mode 100644 index 00000000000..8c8e9c0f9fc --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/model_webpubsubresource.go @@ -0,0 +1,22 @@ +package webpubsub + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebPubSubResource struct { + Id *string `json:"id,omitempty"` + Identity *identity.SystemOrUserAssignedMap `json:"identity,omitempty"` + Kind *ServiceKind `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *WebPubSubProperties `json:"properties,omitempty"` + Sku *ResourceSku `json:"sku,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/model_webpubsubsocketiosettings.go b/resource-manager/webpubsub/2024-03-01/webpubsub/model_webpubsubsocketiosettings.go new file mode 100644 index 00000000000..cb101c4a160 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/model_webpubsubsocketiosettings.go @@ -0,0 +1,8 @@ +package webpubsub + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebPubSubSocketIOSettings struct { + ServiceMode *string `json:"serviceMode,omitempty"` +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/model_webpubsubtlssettings.go b/resource-manager/webpubsub/2024-03-01/webpubsub/model_webpubsubtlssettings.go new file mode 100644 index 00000000000..86fe02ce896 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/model_webpubsubtlssettings.go @@ -0,0 +1,8 @@ +package webpubsub + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebPubSubTlsSettings struct { + ClientCertEnabled *bool `json:"clientCertEnabled,omitempty"` +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/predicates.go b/resource-manager/webpubsub/2024-03-01/webpubsub/predicates.go new file mode 100644 index 00000000000..e9c7900076d --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/predicates.go @@ -0,0 +1,239 @@ +package webpubsub + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomCertificateOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p CustomCertificateOperationPredicate) Matches(input CustomCertificate) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type CustomDomainOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p CustomDomainOperationPredicate) Matches(input CustomDomain) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type PrivateEndpointConnectionOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p PrivateEndpointConnectionOperationPredicate) Matches(input PrivateEndpointConnection) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type PrivateLinkResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p PrivateLinkResourceOperationPredicate) Matches(input PrivateLinkResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type ReplicaOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p ReplicaOperationPredicate) Matches(input Replica) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type SharedPrivateLinkResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p SharedPrivateLinkResourceOperationPredicate) Matches(input SharedPrivateLinkResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type SignalRServiceUsageOperationPredicate struct { + CurrentValue *int64 + Id *string + Limit *int64 + Unit *string +} + +func (p SignalRServiceUsageOperationPredicate) Matches(input SignalRServiceUsage) bool { + + if p.CurrentValue != nil && (input.CurrentValue == nil || *p.CurrentValue != *input.CurrentValue) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Limit != nil && (input.Limit == nil || *p.Limit != *input.Limit) { + return false + } + + if p.Unit != nil && (input.Unit == nil || *p.Unit != *input.Unit) { + return false + } + + return true +} + +type SkuOperationPredicate struct { + ResourceType *string +} + +func (p SkuOperationPredicate) Matches(input Sku) bool { + + if p.ResourceType != nil && (input.ResourceType == nil || *p.ResourceType != *input.ResourceType) { + return false + } + + return true +} + +type WebPubSubHubOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p WebPubSubHubOperationPredicate) Matches(input WebPubSubHub) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type WebPubSubResourceOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p WebPubSubResourceOperationPredicate) Matches(input WebPubSubResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/webpubsub/2024-03-01/webpubsub/version.go b/resource-manager/webpubsub/2024-03-01/webpubsub/version.go new file mode 100644 index 00000000000..101d0ed7df1 --- /dev/null +++ b/resource-manager/webpubsub/2024-03-01/webpubsub/version.go @@ -0,0 +1,12 @@ +package webpubsub + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-03-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/webpubsub/%s", defaultApiVersion) +}