From 771e2c5f917f179490f18b1e72489d084bbeb14b Mon Sep 17 00:00:00 2001 From: hc-github-team-tf-azure <> Date: Thu, 12 Dec 2024 11:16:50 +0000 Subject: [PATCH] Updating based on 83b85c8b9 --- .../activesessionhostconfiguration/README.md | 53 ++ .../activesessionhostconfiguration/client.go | 26 + .../constants.go | 180 ++++ .../id_hostpool.go | 130 +++ .../id_hostpool_test.go | 282 +++++++ .../method_get.go | 54 ++ .../method_listbyhostpool.go | 105 +++ .../model_activedirectoryinfoproperties.go | 10 + .../model_activesessionhostconfiguration.go | 16 + ...ctivesessionhostconfigurationproperties.go | 41 + ...odel_azureactivedirectoryinfoproperties.go | 8 + .../model_bootdiagnosticsinfoproperties.go | 9 + .../model_custominfoproperties.go | 8 + .../model_diskinfoproperties.go | 8 + .../model_domaininfoproperties.go | 10 + .../model_imageinfoproperties.go | 10 + .../model_keyvaultcredentialsproperties.go | 9 + .../model_marketplaceinfoproperties.go | 11 + .../model_networkinfoproperties.go | 9 + .../model_securityinfoproperties.go | 10 + .../predicates.go | 27 + .../activesessionhostconfiguration/version.go | 10 + .../appattachpackage/README.md | 129 +++ .../appattachpackage/client.go | 26 + .../appattachpackage/constants.go | 142 ++++ .../appattachpackage/id_appattachpackage.go | 130 +++ .../id_appattachpackage_test.go | 282 +++++++ .../appattachpackage/method_createorupdate.go | 58 ++ .../appattachpackage/method_delete.go | 77 ++ .../appattachpackage/method_get.go | 53 ++ .../method_listbyresourcegroup.go | 135 +++ .../method_listbysubscription.go | 135 +++ .../appattachpackage/method_update.go | 57 ++ .../model_appattachpackage.go | 18 + .../model_appattachpackageinfoproperties.go | 53 ++ .../model_appattachpackagepatch.go | 17 + .../model_appattachpackagepatchproperties.go | 13 + .../model_appattachpackageproperties.go | 15 + .../model_msixpackageapplications.go | 14 + .../model_msixpackagedependencies.go | 10 + .../appattachpackage/predicates.go | 32 + .../appattachpackage/version.go | 10 + .../appattachpackageinfo/README.md | 42 + .../appattachpackageinfo/client.go | 26 + .../appattachpackageinfo/constants.go | 198 +++++ .../appattachpackageinfo/id_hostpool.go | 130 +++ .../appattachpackageinfo/id_hostpool_test.go | 282 +++++++ .../appattachpackageinfo/method_import.go | 105 +++ .../model_appattachpackage.go | 18 + .../model_appattachpackageinfoproperties.go | 53 ++ .../model_appattachpackageproperties.go | 15 + .../model_importpackageinforequest.go | 9 + .../model_msixpackageapplications.go | 14 + .../model_msixpackagedependencies.go | 10 + .../appattachpackageinfo/predicates.go | 32 + .../appattachpackageinfo/version.go | 10 + .../2024-04-08-preview/application/README.md | 111 +++ .../2024-04-08-preview/application/client.go | 26 + .../application/constants.go | 95 +++ .../application/id_application.go | 139 ++++ .../application/id_application_test.go | 327 ++++++++ .../application/id_applicationgroup.go | 130 +++ .../application/id_applicationgroup_test.go | 282 +++++++ .../application/method_createorupdate.go | 58 ++ .../application/method_delete.go | 47 ++ .../application/method_get.go | 53 ++ .../application/method_list.go | 142 ++++ .../application/method_update.go | 57 ++ .../application/model_application.go | 16 + .../application/model_applicationpatch.go | 9 + .../model_applicationpatchproperties.go | 18 + .../model_applicationproperties.go | 21 + .../application/predicates.go | 27 + .../2024-04-08-preview/application/version.go | 10 + .../applicationgroup/README.md | 129 +++ .../applicationgroup/client.go | 26 + .../applicationgroup/constants.go | 98 +++ .../applicationgroup/id_applicationgroup.go | 130 +++ .../id_applicationgroup_test.go | 282 +++++++ .../applicationgroup/method_createorupdate.go | 58 ++ .../applicationgroup/method_delete.go | 47 ++ .../applicationgroup/method_get.go | 53 ++ .../method_listbyresourcegroup.go | 147 ++++ .../method_listbysubscription.go | 135 +++ .../applicationgroup/method_update.go | 57 ++ .../model_applicationgroup.go | 25 + .../model_applicationgrouppatch.go | 17 + .../model_applicationgrouppatchproperties.go | 10 + .../model_applicationgroupproperties.go | 15 + .../applicationgroup/model_plan.go | 12 + .../applicationgroup/model_sku.go | 12 + .../applicationgroup/predicates.go | 47 ++ .../applicationgroup/version.go | 10 + .../2024-04-08-preview/client.go | 199 +++++ .../2024-04-08-preview/desktop/README.md | 74 ++ .../2024-04-08-preview/desktop/client.go | 26 + .../desktop/id_applicationgroup.go | 130 +++ .../desktop/id_applicationgroup_test.go | 282 +++++++ .../2024-04-08-preview/desktop/id_desktop.go | 139 ++++ .../desktop/id_desktop_test.go | 327 ++++++++ .../2024-04-08-preview/desktop/method_get.go | 53 ++ .../2024-04-08-preview/desktop/method_list.go | 142 ++++ .../desktop/method_update.go | 57 ++ .../desktop/model_desktop.go | 16 + .../desktop/model_desktoppatch.go | 9 + .../desktop/model_desktoppatchproperties.go | 9 + .../desktop/model_desktopproperties.go | 12 + .../2024-04-08-preview/desktop/predicates.go | 27 + .../2024-04-08-preview/desktop/version.go | 10 + .../2024-04-08-preview/hostpool/README.md | 162 ++++ .../2024-04-08-preview/hostpool/client.go | 26 + .../2024-04-08-preview/hostpool/constants.go | 776 ++++++++++++++++++ .../hostpool/id_hostpool.go | 130 +++ .../hostpool/id_hostpool_test.go | 282 +++++++ .../hostpool/method_createorupdate.go | 58 ++ .../hostpool/method_delete.go | 77 ++ .../2024-04-08-preview/hostpool/method_get.go | 53 ++ .../hostpool/method_list.go | 143 ++++ .../hostpool/method_listbyresourcegroup.go | 143 ++++ .../hostpool/method_listregistrationtokens.go | 105 +++ .../method_retrieveregistrationtoken.go | 54 ++ .../hostpool/method_update.go | 57 ++ .../model_agentupdatepatchproperties.go | 11 + .../hostpool/model_agentupdateproperties.go | 11 + .../hostpool/model_hostpool.go | 25 + .../hostpool/model_hostpoolpatch.go | 17 + .../hostpool/model_hostpoolpatchproperties.go | 29 + .../hostpool/model_hostpoolproperties.go | 36 + .../model_maintenancewindowpatchproperties.go | 9 + .../model_maintenancewindowproperties.go | 9 + .../2024-04-08-preview/hostpool/model_plan.go | 12 + .../hostpool/model_privateendpoint.go | 8 + .../model_privateendpointconnection.go | 16 + ...del_privateendpointconnectionproperties.go | 11 + ...model_privatelinkserviceconnectionstate.go | 10 + .../hostpool/model_registrationinfo.go | 28 + .../hostpool/model_registrationinfopatch.go | 27 + .../model_registrationtokenminimal.go | 27 + .../2024-04-08-preview/hostpool/model_sku.go | 12 + .../2024-04-08-preview/hostpool/predicates.go | 65 ++ .../2024-04-08-preview/hostpool/version.go | 10 + .../2024-04-08-preview/msiximage/README.md | 42 + .../2024-04-08-preview/msiximage/client.go | 26 + .../msiximage/id_hostpool.go | 130 +++ .../msiximage/id_hostpool_test.go | 282 +++++++ .../msiximage/method_expand.go | 105 +++ .../msiximage/model_expandmsiximage.go | 16 + .../model_expandmsiximageproperties.go | 52 ++ .../msiximage/model_msiximageuri.go | 8 + .../model_msixpackageapplications.go | 14 + .../model_msixpackagedependencies.go | 10 + .../msiximage/predicates.go | 27 + .../2024-04-08-preview/msiximage/version.go | 10 + .../2024-04-08-preview/msixpackage/README.md | 111 +++ .../2024-04-08-preview/msixpackage/client.go | 26 + .../msixpackage/id_hostpool.go | 130 +++ .../msixpackage/id_hostpool_test.go | 282 +++++++ .../msixpackage/id_msixpackage.go | 139 ++++ .../msixpackage/id_msixpackage_test.go | 327 ++++++++ .../msixpackage/method_createorupdate.go | 58 ++ .../msixpackage/method_delete.go | 47 ++ .../msixpackage/method_get.go | 53 ++ .../msixpackage/method_list.go | 142 ++++ .../msixpackage/method_update.go | 57 ++ .../msixpackage/model_msixpackage.go | 16 + .../model_msixpackageapplications.go | 14 + .../model_msixpackagedependencies.go | 10 + .../msixpackage/model_msixpackagepatch.go | 16 + .../model_msixpackagepatchproperties.go | 10 + .../model_msixpackageproperties.go | 36 + .../msixpackage/predicates.go | 27 + .../2024-04-08-preview/msixpackage/version.go | 10 + .../2024-04-08-preview/privatelink/README.md | 194 +++++ .../2024-04-08-preview/privatelink/client.go | 26 + .../privatelink/constants.go | 101 +++ .../privatelink/id_hostpool.go | 130 +++ .../privatelink/id_hostpool_test.go | 282 +++++++ .../id_privateendpointconnection.go | 139 ++++ .../id_privateendpointconnection_test.go | 327 ++++++++ .../privatelink/id_workspace.go | 130 +++ .../privatelink/id_workspace_test.go | 282 +++++++ .../id_workspaceprivateendpointconnection.go | 139 ++++ ...workspaceprivateendpointconnection_test.go | 327 ++++++++ ...vateendpointconnectionsdeletebyhostpool.go | 47 ++ ...ateendpointconnectionsdeletebyworkspace.go | 47 ++ ...privateendpointconnectionsgetbyhostpool.go | 53 ++ ...rivateendpointconnectionsgetbyworkspace.go | 53 ++ ...rivateendpointconnectionslistbyhostpool.go | 142 ++++ ...ivateendpointconnectionslistbyworkspace.go | 105 +++ ...vateendpointconnectionsupdatebyhostpool.go | 57 ++ ...ateendpointconnectionsupdatebyworkspace.go | 57 ++ .../method_resourceslistbyhostpool.go | 142 ++++ .../method_resourceslistbyworkspace.go | 142 ++++ .../privatelink/model_privateendpoint.go | 8 + .../model_privateendpointconnection.go | 16 + ...del_privateendpointconnectionproperties.go | 11 + .../privatelink/model_privatelinkresource.go | 16 + .../model_privatelinkresourceproperties.go | 10 + ...model_privatelinkserviceconnectionstate.go | 10 + .../privatelink/predicates.go | 50 ++ .../2024-04-08-preview/privatelink/version.go | 10 + .../2024-04-08-preview/scalingplan/README.md | 146 ++++ .../2024-04-08-preview/scalingplan/client.go | 26 + .../scalingplan/constants.go | 236 ++++++ .../scalingplan/id_hostpool.go | 130 +++ .../scalingplan/id_hostpool_test.go | 282 +++++++ .../scalingplan/id_scalingplan.go | 130 +++ .../scalingplan/id_scalingplan_test.go | 282 +++++++ .../scalingplan/method_create.go | 58 ++ .../scalingplan/method_delete.go | 47 ++ .../scalingplan/method_get.go | 53 ++ .../scalingplan/method_listbyhostpool.go | 142 ++++ .../scalingplan/method_listbyresourcegroup.go | 143 ++++ .../scalingplan/method_listbysubscription.go | 143 ++++ .../scalingplan/method_update.go | 57 ++ .../scalingplan/model_plan.go | 12 + .../model_scalinghostpoolreference.go | 9 + .../scalingplan/model_scalingplan.go | 25 + .../scalingplan/model_scalingplanpatch.go | 9 + .../model_scalingplanpatchproperties.go | 13 + .../model_scalingplanproperties.go | 15 + .../scalingplan/model_scalingschedule.go | 25 + .../scalingplan/model_sku.go | 12 + .../scalingplan/model_time.go | 9 + .../scalingplan/predicates.go | 47 ++ .../2024-04-08-preview/scalingplan/version.go | 10 + .../scalingplanpersonalschedule/README.md | 111 +++ .../scalingplanpersonalschedule/client.go | 26 + .../scalingplanpersonalschedule/constants.go | 195 +++++ .../id_personalschedule.go | 139 ++++ .../id_personalschedule_test.go | 327 ++++++++ .../id_scalingplan.go | 130 +++ .../id_scalingplan_test.go | 282 +++++++ .../method_create.go | 58 ++ .../method_delete.go | 47 ++ .../scalingplanpersonalschedule/method_get.go | 53 ++ .../method_list.go | 142 ++++ .../method_update.go | 57 ++ .../model_scalingplanpersonalschedule.go | 16 + .../model_scalingplanpersonalschedulepatch.go | 8 + ...l_scalingplanpersonalscheduleproperties.go | 33 + .../scalingplanpersonalschedule/model_time.go | 9 + .../scalingplanpersonalschedule/predicates.go | 27 + .../scalingplanpersonalschedule/version.go | 10 + .../scalingplanpooledschedule/README.md | 111 +++ .../scalingplanpooledschedule/client.go | 26 + .../scalingplanpooledschedule/constants.go | 148 ++++ .../id_pooledschedule.go | 139 ++++ .../id_pooledschedule_test.go | 327 ++++++++ .../id_scalingplan.go | 130 +++ .../id_scalingplan_test.go | 282 +++++++ .../method_create.go | 58 ++ .../method_delete.go | 47 ++ .../scalingplanpooledschedule/method_get.go | 53 ++ .../scalingplanpooledschedule/method_list.go | 142 ++++ .../method_update.go | 57 ++ .../model_scalingplanpooledschedule.go | 16 + .../model_scalingplanpooledschedulepatch.go | 16 + ...del_scalingplanpooledscheduleproperties.go | 24 + .../scalingplanpooledschedule/model_time.go | 9 + .../scalingplanpooledschedule/predicates.go | 27 + .../scalingplanpooledschedule/version.go | 10 + .../2024-04-08-preview/sessionhost/README.md | 106 +++ .../2024-04-08-preview/sessionhost/client.go | 26 + .../sessionhost/constants.go | 246 ++++++ .../sessionhost/id_hostpool.go | 130 +++ .../sessionhost/id_hostpool_test.go | 282 +++++++ .../sessionhost/id_sessionhost.go | 139 ++++ .../sessionhost/id_sessionhost_test.go | 327 ++++++++ .../sessionhost/method_delete.go | 77 ++ .../sessionhost/method_get.go | 53 ++ .../sessionhost/method_list.go | 146 ++++ .../sessionhost/method_retryprovisioning.go | 47 ++ .../sessionhost/method_update.go | 87 ++ .../sessionhost/model_sessionhost.go | 16 + ...el_sessionhosthealthcheckfailuredetails.go | 28 + .../model_sessionhosthealthcheckreport.go | 10 + .../sessionhost/model_sessionhostpatch.go | 16 + .../model_sessionhostpatchproperties.go | 10 + .../model_sessionhostproperties.go | 80 ++ .../sessionhost/predicates.go | 27 + .../2024-04-08-preview/sessionhost/version.go | 10 + .../sessionhostconfiguration/README.md | 87 ++ .../sessionhostconfiguration/client.go | 26 + .../sessionhostconfiguration/constants.go | 227 +++++ .../sessionhostconfiguration/id_hostpool.go | 130 +++ .../id_hostpool_test.go | 282 +++++++ .../method_createorupdate.go | 75 ++ .../sessionhostconfiguration/method_get.go | 54 ++ .../method_listbyhostpool.go | 105 +++ .../sessionhostconfiguration/method_update.go | 75 ++ ...odel_activedirectoryinfopatchproperties.go | 8 + .../model_activedirectoryinfoproperties.go | 10 + ...odel_azureactivedirectoryinfoproperties.go | 8 + ...odel_bootdiagnosticsinfopatchproperties.go | 9 + .../model_bootdiagnosticsinfoproperties.go | 9 + .../model_custominfopatchproperties.go | 8 + .../model_custominfoproperties.go | 8 + .../model_diskinfopatchproperties.go | 8 + .../model_diskinfoproperties.go | 8 + .../model_domaininfopatchproperties.go | 8 + .../model_domaininfoproperties.go | 10 + .../model_imageinfopatchproperties.go | 10 + .../model_imageinfoproperties.go | 10 + ...odel_keyvaultcredentialspatchproperties.go | 9 + .../model_keyvaultcredentialsproperties.go | 9 + .../model_marketplaceinfopatchproperties.go | 11 + .../model_marketplaceinfoproperties.go | 11 + .../model_networkinfopatchproperties.go | 9 + .../model_networkinfoproperties.go | 9 + .../model_securityinfopatchproperties.go | 10 + .../model_securityinfoproperties.go | 10 + .../model_sessionhostconfiguration.go | 16 + .../model_sessionhostconfigurationpatch.go | 8 + ...sessionhostconfigurationpatchproperties.go | 22 + ...odel_sessionhostconfigurationproperties.go | 42 + .../sessionhostconfiguration/predicates.go | 27 + .../sessionhostconfiguration/version.go | 10 + .../sessionhostmanagement/README.md | 116 +++ .../sessionhostmanagement/client.go | 26 + .../sessionhostmanagement/constants.go | 60 ++ .../sessionhostmanagement/id_hostpool.go | 130 +++ .../sessionhostmanagement/id_hostpool_test.go | 282 +++++++ .../method_controlsessionhostupdatepost.go | 73 ++ .../method_createorupdate.go | 59 ++ .../method_initiatesessionhostupdatepost.go | 51 ++ .../sessionhostmanagement/method_update.go | 58 ++ .../method_updatestatusget.go | 54 ++ .../model_erroradditionalinfo.go | 9 + .../model_errordetail.go | 12 + ...tpoolupdateconfigurationpatchproperties.go | 11 + ...l_hostpoolupdateconfigurationproperties.go | 11 + .../model_hostpoolupdatecontrolparameter.go | 9 + .../model_sessionhostmanagement.go | 16 + ..._sessionhostmanagementoperationprogress.go | 30 + .../model_sessionhostmanagementpatch.go | 8 + ...el_sessionhostmanagementpatchproperties.go | 9 + .../model_sessionhostmanagementproperties.go | 9 + ...model_sessionhostmanagementupdatestatus.go | 45 + ...ionhostmanagementupdatestatusproperties.go | 29 + .../model_updatesessionhostsrequestbody.go | 28 + .../sessionhostmanagement/version.go | 10 + .../sessionhostmanagements/README.md | 53 ++ .../sessionhostmanagements/client.go | 26 + .../sessionhostmanagements/id_hostpool.go | 130 +++ .../id_hostpool_test.go | 282 +++++++ .../sessionhostmanagements/method_get.go | 54 ++ .../method_listbyhostpool.go | 105 +++ ...l_hostpoolupdateconfigurationproperties.go | 11 + .../model_sessionhostmanagement.go | 16 + .../model_sessionhostmanagementproperties.go | 9 + .../sessionhostmanagements/predicates.go | 27 + .../sessionhostmanagements/version.go | 10 + .../startmenuitem/README.md | 37 + .../startmenuitem/client.go | 26 + .../startmenuitem/id_applicationgroup.go | 130 +++ .../startmenuitem/id_applicationgroup_test.go | 282 +++++++ .../startmenuitem/method_list.go | 142 ++++ .../startmenuitem/model_startmenuitem.go | 16 + .../model_startmenuitemproperties.go | 12 + .../startmenuitem/predicates.go | 27 + .../startmenuitem/version.go | 10 + .../2024-04-08-preview/usersession/README.md | 123 +++ .../2024-04-08-preview/usersession/client.go | 26 + .../usersession/constants.go | 104 +++ .../usersession/id_hostpool.go | 130 +++ .../usersession/id_hostpool_test.go | 282 +++++++ .../usersession/id_sessionhost.go | 139 ++++ .../usersession/id_sessionhost_test.go | 327 ++++++++ .../usersession/id_usersession.go | 148 ++++ .../usersession/id_usersession_test.go | 372 +++++++++ .../usersession/method_delete.go | 77 ++ .../usersession/method_disconnect.go | 47 ++ .../usersession/method_get.go | 53 ++ .../usersession/method_list.go | 142 ++++ .../usersession/method_listbyhostpool.go | 146 ++++ .../usersession/method_sendmessage.go | 51 ++ .../usersession/model_sendmessage.go | 9 + .../usersession/model_usersession.go | 16 + .../model_usersessionproperties.go | 31 + .../usersession/predicates.go | 27 + .../2024-04-08-preview/usersession/version.go | 10 + .../2024-04-08-preview/workspace/README.md | 129 +++ .../2024-04-08-preview/workspace/client.go | 26 + .../2024-04-08-preview/workspace/constants.go | 189 +++++ .../workspace/id_workspace.go | 130 +++ .../workspace/id_workspace_test.go | 282 +++++++ .../workspace/method_createorupdate.go | 58 ++ .../workspace/method_delete.go | 47 ++ .../workspace/method_get.go | 53 ++ .../workspace/method_listbyresourcegroup.go | 143 ++++ .../workspace/method_listbysubscription.go | 106 +++ .../workspace/method_update.go | 57 ++ .../workspace/model_plan.go | 12 + .../workspace/model_privateendpoint.go | 8 + .../model_privateendpointconnection.go | 16 + ...del_privateendpointconnectionproperties.go | 11 + ...model_privatelinkserviceconnectionstate.go | 10 + .../2024-04-08-preview/workspace/model_sku.go | 12 + .../workspace/model_workspace.go | 25 + .../workspace/model_workspacepatch.go | 9 + .../model_workspacepatchproperties.go | 11 + .../workspace/model_workspaceproperties.go | 14 + .../workspace/predicates.go | 47 ++ .../2024-04-08-preview/workspace/version.go | 10 + .../constants.go | 6 + .../constants.go | 6 + 407 files changed, 30312 insertions(+) create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/README.md create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/client.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/constants.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/id_hostpool.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/id_hostpool_test.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/method_get.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/method_listbyhostpool.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_activedirectoryinfoproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_activesessionhostconfiguration.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_activesessionhostconfigurationproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_azureactivedirectoryinfoproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_bootdiagnosticsinfoproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_custominfoproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_diskinfoproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_domaininfoproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_imageinfoproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_keyvaultcredentialsproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_marketplaceinfoproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_networkinfoproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_securityinfoproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/predicates.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/version.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/README.md create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/client.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/constants.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/id_appattachpackage.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/id_appattachpackage_test.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/method_createorupdate.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/method_delete.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/method_get.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/method_listbyresourcegroup.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/method_listbysubscription.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/method_update.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/model_appattachpackage.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/model_appattachpackageinfoproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/model_appattachpackagepatch.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/model_appattachpackagepatchproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/model_appattachpackageproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/model_msixpackageapplications.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/model_msixpackagedependencies.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/predicates.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/version.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/README.md create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/client.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/constants.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/id_hostpool.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/id_hostpool_test.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/method_import.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/model_appattachpackage.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/model_appattachpackageinfoproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/model_appattachpackageproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/model_importpackageinforequest.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/model_msixpackageapplications.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/model_msixpackagedependencies.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/predicates.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/version.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/application/README.md create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/application/client.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/application/constants.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/application/id_application.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/application/id_application_test.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/application/id_applicationgroup.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/application/id_applicationgroup_test.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/application/method_createorupdate.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/application/method_delete.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/application/method_get.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/application/method_list.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/application/method_update.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/application/model_application.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/application/model_applicationpatch.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/application/model_applicationpatchproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/application/model_applicationproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/application/predicates.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/application/version.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/README.md create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/client.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/constants.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/id_applicationgroup.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/id_applicationgroup_test.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/method_createorupdate.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/method_delete.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/method_get.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/method_listbyresourcegroup.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/method_listbysubscription.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/method_update.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/model_applicationgroup.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/model_applicationgrouppatch.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/model_applicationgrouppatchproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/model_applicationgroupproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/model_plan.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/model_sku.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/predicates.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/version.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/client.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/desktop/README.md create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/desktop/client.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/desktop/id_applicationgroup.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/desktop/id_applicationgroup_test.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/desktop/id_desktop.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/desktop/id_desktop_test.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/desktop/method_get.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/desktop/method_list.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/desktop/method_update.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/desktop/model_desktop.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/desktop/model_desktoppatch.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/desktop/model_desktoppatchproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/desktop/model_desktopproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/desktop/predicates.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/desktop/version.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/README.md create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/client.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/constants.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/id_hostpool.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/id_hostpool_test.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/method_createorupdate.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/method_delete.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/method_get.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/method_list.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/method_listbyresourcegroup.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/method_listregistrationtokens.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/method_retrieveregistrationtoken.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/method_update.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_agentupdatepatchproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_agentupdateproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_hostpool.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_hostpoolpatch.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_hostpoolpatchproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_hostpoolproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_maintenancewindowpatchproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_maintenancewindowproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_plan.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_privateendpoint.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_privateendpointconnection.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_privateendpointconnectionproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_privatelinkserviceconnectionstate.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_registrationinfo.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_registrationinfopatch.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_registrationtokenminimal.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_sku.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/predicates.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/version.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/msiximage/README.md create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/msiximage/client.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/msiximage/id_hostpool.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/msiximage/id_hostpool_test.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/msiximage/method_expand.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/msiximage/model_expandmsiximage.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/msiximage/model_expandmsiximageproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/msiximage/model_msiximageuri.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/msiximage/model_msixpackageapplications.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/msiximage/model_msixpackagedependencies.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/msiximage/predicates.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/msiximage/version.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/README.md create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/client.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/id_hostpool.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/id_hostpool_test.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/id_msixpackage.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/id_msixpackage_test.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/method_createorupdate.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/method_delete.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/method_get.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/method_list.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/method_update.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/model_msixpackage.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/model_msixpackageapplications.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/model_msixpackagedependencies.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/model_msixpackagepatch.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/model_msixpackagepatchproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/model_msixpackageproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/predicates.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/version.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/README.md create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/client.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/constants.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/id_hostpool.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/id_hostpool_test.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/id_privateendpointconnection.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/id_privateendpointconnection_test.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/id_workspace.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/id_workspace_test.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/id_workspaceprivateendpointconnection.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/id_workspaceprivateendpointconnection_test.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/method_privateendpointconnectionsdeletebyhostpool.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/method_privateendpointconnectionsdeletebyworkspace.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/method_privateendpointconnectionsgetbyhostpool.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/method_privateendpointconnectionsgetbyworkspace.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/method_privateendpointconnectionslistbyhostpool.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/method_privateendpointconnectionslistbyworkspace.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/method_privateendpointconnectionsupdatebyhostpool.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/method_privateendpointconnectionsupdatebyworkspace.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/method_resourceslistbyhostpool.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/method_resourceslistbyworkspace.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/model_privateendpoint.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/model_privateendpointconnection.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/model_privateendpointconnectionproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/model_privatelinkresource.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/model_privatelinkresourceproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/model_privatelinkserviceconnectionstate.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/predicates.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/version.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/README.md create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/client.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/constants.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/id_hostpool.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/id_hostpool_test.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/id_scalingplan.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/id_scalingplan_test.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/method_create.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/method_delete.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/method_get.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/method_listbyhostpool.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/method_listbyresourcegroup.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/method_listbysubscription.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/method_update.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/model_plan.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/model_scalinghostpoolreference.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/model_scalingplan.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/model_scalingplanpatch.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/model_scalingplanpatchproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/model_scalingplanproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/model_scalingschedule.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/model_sku.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/model_time.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/predicates.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/version.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/README.md create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/client.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/constants.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/id_personalschedule.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/id_personalschedule_test.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/id_scalingplan.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/id_scalingplan_test.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/method_create.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/method_delete.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/method_get.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/method_list.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/method_update.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/model_scalingplanpersonalschedule.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/model_scalingplanpersonalschedulepatch.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/model_scalingplanpersonalscheduleproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/model_time.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/predicates.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/version.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/README.md create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/client.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/constants.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/id_pooledschedule.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/id_pooledschedule_test.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/id_scalingplan.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/id_scalingplan_test.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/method_create.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/method_delete.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/method_get.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/method_list.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/method_update.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/model_scalingplanpooledschedule.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/model_scalingplanpooledschedulepatch.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/model_scalingplanpooledscheduleproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/model_time.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/predicates.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/version.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/README.md create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/client.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/constants.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/id_hostpool.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/id_hostpool_test.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/id_sessionhost.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/id_sessionhost_test.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/method_delete.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/method_get.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/method_list.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/method_retryprovisioning.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/method_update.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/model_sessionhost.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/model_sessionhosthealthcheckfailuredetails.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/model_sessionhosthealthcheckreport.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/model_sessionhostpatch.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/model_sessionhostpatchproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/model_sessionhostproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/predicates.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/version.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/README.md create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/client.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/constants.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/id_hostpool.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/id_hostpool_test.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/method_createorupdate.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/method_get.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/method_listbyhostpool.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/method_update.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_activedirectoryinfopatchproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_activedirectoryinfoproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_azureactivedirectoryinfoproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_bootdiagnosticsinfopatchproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_bootdiagnosticsinfoproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_custominfopatchproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_custominfoproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_diskinfopatchproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_diskinfoproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_domaininfopatchproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_domaininfoproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_imageinfopatchproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_imageinfoproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_keyvaultcredentialspatchproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_keyvaultcredentialsproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_marketplaceinfopatchproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_marketplaceinfoproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_networkinfopatchproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_networkinfoproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_securityinfopatchproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_securityinfoproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_sessionhostconfiguration.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_sessionhostconfigurationpatch.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_sessionhostconfigurationpatchproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_sessionhostconfigurationproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/predicates.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/version.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/README.md create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/client.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/constants.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/id_hostpool.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/id_hostpool_test.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/method_controlsessionhostupdatepost.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/method_createorupdate.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/method_initiatesessionhostupdatepost.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/method_update.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/method_updatestatusget.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_erroradditionalinfo.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_errordetail.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_hostpoolupdateconfigurationpatchproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_hostpoolupdateconfigurationproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_hostpoolupdatecontrolparameter.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_sessionhostmanagement.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_sessionhostmanagementoperationprogress.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_sessionhostmanagementpatch.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_sessionhostmanagementpatchproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_sessionhostmanagementproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_sessionhostmanagementupdatestatus.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_sessionhostmanagementupdatestatusproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_updatesessionhostsrequestbody.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/version.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagements/README.md create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagements/client.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagements/id_hostpool.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagements/id_hostpool_test.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagements/method_get.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagements/method_listbyhostpool.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagements/model_hostpoolupdateconfigurationproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagements/model_sessionhostmanagement.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagements/model_sessionhostmanagementproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagements/predicates.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagements/version.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/startmenuitem/README.md create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/startmenuitem/client.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/startmenuitem/id_applicationgroup.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/startmenuitem/id_applicationgroup_test.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/startmenuitem/method_list.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/startmenuitem/model_startmenuitem.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/startmenuitem/model_startmenuitemproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/startmenuitem/predicates.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/startmenuitem/version.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/usersession/README.md create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/usersession/client.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/usersession/constants.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/usersession/id_hostpool.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/usersession/id_hostpool_test.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/usersession/id_sessionhost.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/usersession/id_sessionhost_test.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/usersession/id_usersession.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/usersession/id_usersession_test.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/usersession/method_delete.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/usersession/method_disconnect.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/usersession/method_get.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/usersession/method_list.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/usersession/method_listbyhostpool.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/usersession/method_sendmessage.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/usersession/model_sendmessage.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/usersession/model_usersession.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/usersession/model_usersessionproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/usersession/predicates.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/usersession/version.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/workspace/README.md create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/workspace/client.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/workspace/constants.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/workspace/id_workspace.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/workspace/id_workspace_test.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/workspace/method_createorupdate.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/workspace/method_delete.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/workspace/method_get.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/workspace/method_listbyresourcegroup.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/workspace/method_listbysubscription.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/workspace/method_update.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/workspace/model_plan.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/workspace/model_privateendpoint.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/workspace/model_privateendpointconnection.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/workspace/model_privateendpointconnectionproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/workspace/model_privatelinkserviceconnectionstate.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/workspace/model_sku.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/workspace/model_workspace.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/workspace/model_workspacepatch.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/workspace/model_workspacepatchproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/workspace/model_workspaceproperties.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/workspace/predicates.go create mode 100644 resource-manager/desktopvirtualization/2024-04-08-preview/workspace/version.go diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/README.md b/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/README.md new file mode 100644 index 00000000000..2db006d3a50 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration` Documentation + +The `activesessionhostconfiguration` SDK allows for interaction with Azure Resource Manager `desktopvirtualization` (API Version `2024-04-08-preview`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration" +``` + + +### Client Initialization + +```go +client := activesessionhostconfiguration.NewActiveSessionHostConfigurationClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ActiveSessionHostConfigurationClient.Get` + +```go +ctx := context.TODO() +id := activesessionhostconfiguration.NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName") + +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: `ActiveSessionHostConfigurationClient.ListByHostPool` + +```go +ctx := context.TODO() +id := activesessionhostconfiguration.NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName") + +// alternatively `client.ListByHostPool(ctx, id)` can be used to do batched pagination +items, err := client.ListByHostPoolComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/client.go b/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/client.go new file mode 100644 index 00000000000..aeca0750442 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/client.go @@ -0,0 +1,26 @@ +package activesessionhostconfiguration + +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 ActiveSessionHostConfigurationClient struct { + Client *resourcemanager.Client +} + +func NewActiveSessionHostConfigurationClientWithBaseURI(sdkApi sdkEnv.Api) (*ActiveSessionHostConfigurationClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "activesessionhostconfiguration", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ActiveSessionHostConfigurationClient: %+v", err) + } + + return &ActiveSessionHostConfigurationClient{ + Client: client, + }, nil +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/constants.go b/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/constants.go new file mode 100644 index 00000000000..0f2f08464fb --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/constants.go @@ -0,0 +1,180 @@ +package activesessionhostconfiguration + +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 DomainJoinType string + +const ( + DomainJoinTypeActiveDirectory DomainJoinType = "ActiveDirectory" + DomainJoinTypeAzureActiveDirectory DomainJoinType = "AzureActiveDirectory" +) + +func PossibleValuesForDomainJoinType() []string { + return []string{ + string(DomainJoinTypeActiveDirectory), + string(DomainJoinTypeAzureActiveDirectory), + } +} + +func (s *DomainJoinType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDomainJoinType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDomainJoinType(input string) (*DomainJoinType, error) { + vals := map[string]DomainJoinType{ + "activedirectory": DomainJoinTypeActiveDirectory, + "azureactivedirectory": DomainJoinTypeAzureActiveDirectory, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DomainJoinType(input) + return &out, nil +} + +type Type string + +const ( + TypeCustom Type = "Custom" + TypeMarketplace Type = "Marketplace" +) + +func PossibleValuesForType() []string { + return []string{ + string(TypeCustom), + string(TypeMarketplace), + } +} + +func (s *Type) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseType(input string) (*Type, error) { + vals := map[string]Type{ + "custom": TypeCustom, + "marketplace": TypeMarketplace, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Type(input) + return &out, nil +} + +type VirtualMachineDiskType string + +const ( + VirtualMachineDiskTypePremiumLRS VirtualMachineDiskType = "Premium_LRS" + VirtualMachineDiskTypeStandardLRS VirtualMachineDiskType = "Standard_LRS" + VirtualMachineDiskTypeStandardSSDLRS VirtualMachineDiskType = "StandardSSD_LRS" +) + +func PossibleValuesForVirtualMachineDiskType() []string { + return []string{ + string(VirtualMachineDiskTypePremiumLRS), + string(VirtualMachineDiskTypeStandardLRS), + string(VirtualMachineDiskTypeStandardSSDLRS), + } +} + +func (s *VirtualMachineDiskType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualMachineDiskType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualMachineDiskType(input string) (*VirtualMachineDiskType, error) { + vals := map[string]VirtualMachineDiskType{ + "premium_lrs": VirtualMachineDiskTypePremiumLRS, + "standard_lrs": VirtualMachineDiskTypeStandardLRS, + "standardssd_lrs": VirtualMachineDiskTypeStandardSSDLRS, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualMachineDiskType(input) + return &out, nil +} + +type VirtualMachineSecurityType string + +const ( + VirtualMachineSecurityTypeConfidentialVM VirtualMachineSecurityType = "ConfidentialVM" + VirtualMachineSecurityTypeStandard VirtualMachineSecurityType = "Standard" + VirtualMachineSecurityTypeTrustedLaunch VirtualMachineSecurityType = "TrustedLaunch" +) + +func PossibleValuesForVirtualMachineSecurityType() []string { + return []string{ + string(VirtualMachineSecurityTypeConfidentialVM), + string(VirtualMachineSecurityTypeStandard), + string(VirtualMachineSecurityTypeTrustedLaunch), + } +} + +func (s *VirtualMachineSecurityType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualMachineSecurityType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualMachineSecurityType(input string) (*VirtualMachineSecurityType, error) { + vals := map[string]VirtualMachineSecurityType{ + "confidentialvm": VirtualMachineSecurityTypeConfidentialVM, + "standard": VirtualMachineSecurityTypeStandard, + "trustedlaunch": VirtualMachineSecurityTypeTrustedLaunch, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualMachineSecurityType(input) + return &out, nil +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/id_hostpool.go b/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/id_hostpool.go new file mode 100644 index 00000000000..a657ca503dc --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/id_hostpool.go @@ -0,0 +1,130 @@ +package activesessionhostconfiguration + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&HostPoolId{}) +} + +var _ resourceids.ResourceId = &HostPoolId{} + +// HostPoolId is a struct representing the Resource ID for a Host Pool +type HostPoolId struct { + SubscriptionId string + ResourceGroupName string + HostPoolName string +} + +// NewHostPoolID returns a new HostPoolId struct +func NewHostPoolID(subscriptionId string, resourceGroupName string, hostPoolName string) HostPoolId { + return HostPoolId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + HostPoolName: hostPoolName, + } +} + +// ParseHostPoolID parses 'input' into a HostPoolId +func ParseHostPoolID(input string) (*HostPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostPoolId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostPoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseHostPoolIDInsensitively parses 'input' case-insensitively into a HostPoolId +// note: this method should only be used for API response data and not user input +func ParseHostPoolIDInsensitively(input string) (*HostPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostPoolId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostPoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *HostPoolId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.HostPoolName, ok = input.Parsed["hostPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hostPoolName", input) + } + + return nil +} + +// ValidateHostPoolID checks that 'input' can be parsed as a Host Pool ID +func ValidateHostPoolID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseHostPoolID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Host Pool ID +func (id HostPoolId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DesktopVirtualization/hostPools/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.HostPoolName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Host Pool ID +func (id HostPoolId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDesktopVirtualization", "Microsoft.DesktopVirtualization", "Microsoft.DesktopVirtualization"), + resourceids.StaticSegment("staticHostPools", "hostPools", "hostPools"), + resourceids.UserSpecifiedSegment("hostPoolName", "hostPoolName"), + } +} + +// String returns a human-readable description of this Host Pool ID +func (id HostPoolId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Host Pool Name: %q", id.HostPoolName), + } + return fmt.Sprintf("Host Pool (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/id_hostpool_test.go b/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/id_hostpool_test.go new file mode 100644 index 00000000000..3d2ff94a569 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/id_hostpool_test.go @@ -0,0 +1,282 @@ +package activesessionhostconfiguration + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &HostPoolId{} + +func TestNewHostPoolID(t *testing.T) { + id := NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.HostPoolName != "hostPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'HostPoolName'", id.HostPoolName, "hostPoolName") + } +} + +func TestFormatHostPoolID(t *testing.T) { + actual := NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseHostPoolID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostPoolId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName", + Expected: &HostPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostPoolName: "hostPoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostPoolID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostPoolName != v.Expected.HostPoolName { + t.Fatalf("Expected %q but got %q for HostPoolName", v.Expected.HostPoolName, actual.HostPoolName) + } + + } +} + +func TestParseHostPoolIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostPoolId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName", + Expected: &HostPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostPoolName: "hostPoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs/hOsTpOoLnAmE", + Expected: &HostPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + HostPoolName: "hOsTpOoLnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs/hOsTpOoLnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostPoolIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostPoolName != v.Expected.HostPoolName { + t.Fatalf("Expected %q but got %q for HostPoolName", v.Expected.HostPoolName, actual.HostPoolName) + } + + } +} + +func TestSegmentsForHostPoolId(t *testing.T) { + segments := HostPoolId{}.Segments() + if len(segments) == 0 { + t.Fatalf("HostPoolId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/method_get.go b/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/method_get.go new file mode 100644 index 00000000000..8c4979b24d4 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/method_get.go @@ -0,0 +1,54 @@ +package activesessionhostconfiguration + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *ActiveSessionHostConfiguration +} + +// Get ... +func (c ActiveSessionHostConfigurationClient) Get(ctx context.Context, id HostPoolId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/activeSessionHostConfigurations/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ActiveSessionHostConfiguration + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/method_listbyhostpool.go b/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/method_listbyhostpool.go new file mode 100644 index 00000000000..cdc313718ef --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/method_listbyhostpool.go @@ -0,0 +1,105 @@ +package activesessionhostconfiguration + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByHostPoolOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ActiveSessionHostConfiguration +} + +type ListByHostPoolCompleteResult struct { + LatestHttpResponse *http.Response + Items []ActiveSessionHostConfiguration +} + +type ListByHostPoolCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByHostPoolCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByHostPool ... +func (c ActiveSessionHostConfigurationClient) ListByHostPool(ctx context.Context, id HostPoolId) (result ListByHostPoolOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByHostPoolCustomPager{}, + Path: fmt.Sprintf("%s/activeSessionHostConfigurations", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ActiveSessionHostConfiguration `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByHostPoolComplete retrieves all the results into a single object +func (c ActiveSessionHostConfigurationClient) ListByHostPoolComplete(ctx context.Context, id HostPoolId) (ListByHostPoolCompleteResult, error) { + return c.ListByHostPoolCompleteMatchingPredicate(ctx, id, ActiveSessionHostConfigurationOperationPredicate{}) +} + +// ListByHostPoolCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ActiveSessionHostConfigurationClient) ListByHostPoolCompleteMatchingPredicate(ctx context.Context, id HostPoolId, predicate ActiveSessionHostConfigurationOperationPredicate) (result ListByHostPoolCompleteResult, err error) { + items := make([]ActiveSessionHostConfiguration, 0) + + resp, err := c.ListByHostPool(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 = ListByHostPoolCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_activedirectoryinfoproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_activedirectoryinfoproperties.go new file mode 100644 index 00000000000..bd488489f3e --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_activedirectoryinfoproperties.go @@ -0,0 +1,10 @@ +package activesessionhostconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ActiveDirectoryInfoProperties struct { + DomainCredentials KeyVaultCredentialsProperties `json:"domainCredentials"` + DomainName *string `json:"domainName,omitempty"` + OuPath string `json:"ouPath"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_activesessionhostconfiguration.go b/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_activesessionhostconfiguration.go new file mode 100644 index 00000000000..30ff8f3befb --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_activesessionhostconfiguration.go @@ -0,0 +1,16 @@ +package activesessionhostconfiguration + +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 ActiveSessionHostConfiguration struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties ActiveSessionHostConfigurationProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_activesessionhostconfigurationproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_activesessionhostconfigurationproperties.go new file mode 100644 index 00000000000..57154777ee1 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_activesessionhostconfigurationproperties.go @@ -0,0 +1,41 @@ +package activesessionhostconfiguration + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ActiveSessionHostConfigurationProperties struct { + AvailabilityZones *[]int64 `json:"availabilityZones,omitempty"` + BootDiagnosticsInfo *BootDiagnosticsInfoProperties `json:"bootDiagnosticsInfo,omitempty"` + CustomConfigurationScriptURL *string `json:"customConfigurationScriptUrl,omitempty"` + DiskInfo DiskInfoProperties `json:"diskInfo"` + DomainInfo DomainInfoProperties `json:"domainInfo"` + FriendlyName *string `json:"friendlyName,omitempty"` + ImageInfo ImageInfoProperties `json:"imageInfo"` + NetworkInfo NetworkInfoProperties `json:"networkInfo"` + SecurityInfo *SecurityInfoProperties `json:"securityInfo,omitempty"` + VMAdminCredentials KeyVaultCredentialsProperties `json:"vmAdminCredentials"` + VMLocation *string `json:"vmLocation,omitempty"` + VMNamePrefix string `json:"vmNamePrefix"` + VMResourceGroup *string `json:"vmResourceGroup,omitempty"` + VMSizeId string `json:"vmSizeId"` + VMTags *map[string]string `json:"vmTags,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *ActiveSessionHostConfigurationProperties) GetVersionAsTime() (*time.Time, error) { + if o.Version == nil { + return nil, nil + } + return dates.ParseAsFormat(o.Version, "2006-01-02T15:04:05Z07:00") +} + +func (o *ActiveSessionHostConfigurationProperties) SetVersionAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.Version = &formatted +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_azureactivedirectoryinfoproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_azureactivedirectoryinfoproperties.go new file mode 100644 index 00000000000..28ac3315c7f --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_azureactivedirectoryinfoproperties.go @@ -0,0 +1,8 @@ +package activesessionhostconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureActiveDirectoryInfoProperties struct { + MdmProviderGuid string `json:"mdmProviderGuid"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_bootdiagnosticsinfoproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_bootdiagnosticsinfoproperties.go new file mode 100644 index 00000000000..cb0e58c3ad9 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_bootdiagnosticsinfoproperties.go @@ -0,0 +1,9 @@ +package activesessionhostconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BootDiagnosticsInfoProperties struct { + Enabled *bool `json:"enabled,omitempty"` + StorageUri *string `json:"storageUri,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_custominfoproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_custominfoproperties.go new file mode 100644 index 00000000000..201c051d317 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_custominfoproperties.go @@ -0,0 +1,8 @@ +package activesessionhostconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomInfoProperties struct { + ResourceId string `json:"resourceId"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_diskinfoproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_diskinfoproperties.go new file mode 100644 index 00000000000..12a3356da0f --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_diskinfoproperties.go @@ -0,0 +1,8 @@ +package activesessionhostconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiskInfoProperties struct { + Type VirtualMachineDiskType `json:"type"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_domaininfoproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_domaininfoproperties.go new file mode 100644 index 00000000000..928ac8045a0 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_domaininfoproperties.go @@ -0,0 +1,10 @@ +package activesessionhostconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DomainInfoProperties struct { + ActiveDirectoryInfo *ActiveDirectoryInfoProperties `json:"activeDirectoryInfo,omitempty"` + AzureActiveDirectoryInfo *AzureActiveDirectoryInfoProperties `json:"azureActiveDirectoryInfo,omitempty"` + JoinType DomainJoinType `json:"joinType"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_imageinfoproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_imageinfoproperties.go new file mode 100644 index 00000000000..be782b67e35 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_imageinfoproperties.go @@ -0,0 +1,10 @@ +package activesessionhostconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ImageInfoProperties struct { + CustomInfo *CustomInfoProperties `json:"customInfo,omitempty"` + MarketplaceInfo *MarketplaceInfoProperties `json:"marketplaceInfo,omitempty"` + Type Type `json:"type"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_keyvaultcredentialsproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_keyvaultcredentialsproperties.go new file mode 100644 index 00000000000..344958ab802 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_keyvaultcredentialsproperties.go @@ -0,0 +1,9 @@ +package activesessionhostconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyVaultCredentialsProperties struct { + PasswordKeyVaultSecretUri string `json:"passwordKeyVaultSecretUri"` + UsernameKeyVaultSecretUri string `json:"usernameKeyVaultSecretUri"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_marketplaceinfoproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_marketplaceinfoproperties.go new file mode 100644 index 00000000000..4fa46eafd08 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_marketplaceinfoproperties.go @@ -0,0 +1,11 @@ +package activesessionhostconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MarketplaceInfoProperties struct { + ExactVersion string `json:"exactVersion"` + Offer string `json:"offer"` + Publisher string `json:"publisher"` + Sku string `json:"sku"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_networkinfoproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_networkinfoproperties.go new file mode 100644 index 00000000000..3d31187ef11 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_networkinfoproperties.go @@ -0,0 +1,9 @@ +package activesessionhostconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInfoProperties struct { + SecurityGroupId *string `json:"securityGroupId,omitempty"` + SubnetId string `json:"subnetId"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_securityinfoproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_securityinfoproperties.go new file mode 100644 index 00000000000..8c2fc50f195 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/model_securityinfoproperties.go @@ -0,0 +1,10 @@ +package activesessionhostconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityInfoProperties struct { + SecureBootEnabled *bool `json:"secureBootEnabled,omitempty"` + Type *VirtualMachineSecurityType `json:"type,omitempty"` + VTpmEnabled *bool `json:"vTpmEnabled,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/predicates.go b/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/predicates.go new file mode 100644 index 00000000000..002e2f91724 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/predicates.go @@ -0,0 +1,27 @@ +package activesessionhostconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ActiveSessionHostConfigurationOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p ActiveSessionHostConfigurationOperationPredicate) Matches(input ActiveSessionHostConfiguration) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/version.go b/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/version.go new file mode 100644 index 00000000000..d07d3bea6fc --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration/version.go @@ -0,0 +1,10 @@ +package activesessionhostconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-08-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/activesessionhostconfiguration/2024-04-08-preview" +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/README.md b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/README.md new file mode 100644 index 00000000000..82ea637f626 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/README.md @@ -0,0 +1,129 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage` Documentation + +The `appattachpackage` SDK allows for interaction with Azure Resource Manager `desktopvirtualization` (API Version `2024-04-08-preview`). + +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/desktopvirtualization/2024-04-08-preview/appattachpackage" +``` + + +### Client Initialization + +```go +client := appattachpackage.NewAppAttachPackageClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AppAttachPackageClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := appattachpackage.NewAppAttachPackageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "appAttachPackageName") + +payload := appattachpackage.AppAttachPackage{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppAttachPackageClient.Delete` + +```go +ctx := context.TODO() +id := appattachpackage.NewAppAttachPackageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "appAttachPackageName") + +read, err := client.Delete(ctx, id, appattachpackage.DefaultDeleteOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppAttachPackageClient.Get` + +```go +ctx := context.TODO() +id := appattachpackage.NewAppAttachPackageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "appAttachPackageName") + +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: `AppAttachPackageClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id, appattachpackage.DefaultListByResourceGroupOperationOptions())` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id, appattachpackage.DefaultListByResourceGroupOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppAttachPackageClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id, appattachpackage.DefaultListBySubscriptionOperationOptions())` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id, appattachpackage.DefaultListBySubscriptionOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppAttachPackageClient.Update` + +```go +ctx := context.TODO() +id := appattachpackage.NewAppAttachPackageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "appAttachPackageName") + +payload := appattachpackage.AppAttachPackagePatch{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/client.go b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/client.go new file mode 100644 index 00000000000..61089b3900c --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/client.go @@ -0,0 +1,26 @@ +package appattachpackage + +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 AppAttachPackageClient struct { + Client *resourcemanager.Client +} + +func NewAppAttachPackageClientWithBaseURI(sdkApi sdkEnv.Api) (*AppAttachPackageClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "appattachpackage", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AppAttachPackageClient: %+v", err) + } + + return &AppAttachPackageClient{ + Client: client, + }, nil +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/constants.go b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/constants.go new file mode 100644 index 00000000000..ebe46f75c99 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/constants.go @@ -0,0 +1,142 @@ +package appattachpackage + +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 FailHealthCheckOnStagingFailure string + +const ( + FailHealthCheckOnStagingFailureDoNotFail FailHealthCheckOnStagingFailure = "DoNotFail" + FailHealthCheckOnStagingFailureNeedsAssistance FailHealthCheckOnStagingFailure = "NeedsAssistance" + FailHealthCheckOnStagingFailureUnhealthy FailHealthCheckOnStagingFailure = "Unhealthy" +) + +func PossibleValuesForFailHealthCheckOnStagingFailure() []string { + return []string{ + string(FailHealthCheckOnStagingFailureDoNotFail), + string(FailHealthCheckOnStagingFailureNeedsAssistance), + string(FailHealthCheckOnStagingFailureUnhealthy), + } +} + +func (s *FailHealthCheckOnStagingFailure) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFailHealthCheckOnStagingFailure(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFailHealthCheckOnStagingFailure(input string) (*FailHealthCheckOnStagingFailure, error) { + vals := map[string]FailHealthCheckOnStagingFailure{ + "donotfail": FailHealthCheckOnStagingFailureDoNotFail, + "needsassistance": FailHealthCheckOnStagingFailureNeedsAssistance, + "unhealthy": FailHealthCheckOnStagingFailureUnhealthy, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FailHealthCheckOnStagingFailure(input) + return &out, nil +} + +type PackageTimestamped string + +const ( + PackageTimestampedNotTimestamped PackageTimestamped = "NotTimestamped" + PackageTimestampedTimestamped PackageTimestamped = "Timestamped" +) + +func PossibleValuesForPackageTimestamped() []string { + return []string{ + string(PackageTimestampedNotTimestamped), + string(PackageTimestampedTimestamped), + } +} + +func (s *PackageTimestamped) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePackageTimestamped(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePackageTimestamped(input string) (*PackageTimestamped, error) { + vals := map[string]PackageTimestamped{ + "nottimestamped": PackageTimestampedNotTimestamped, + "timestamped": PackageTimestampedTimestamped, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PackageTimestamped(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateProvisioning ProvisioningState = "Provisioning" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateFailed), + string(ProvisioningStateProvisioning), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "failed": ProvisioningStateFailed, + "provisioning": ProvisioningStateProvisioning, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/id_appattachpackage.go b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/id_appattachpackage.go new file mode 100644 index 00000000000..01dbcf79f4a --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/id_appattachpackage.go @@ -0,0 +1,130 @@ +package appattachpackage + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&AppAttachPackageId{}) +} + +var _ resourceids.ResourceId = &AppAttachPackageId{} + +// AppAttachPackageId is a struct representing the Resource ID for a App Attach Package +type AppAttachPackageId struct { + SubscriptionId string + ResourceGroupName string + AppAttachPackageName string +} + +// NewAppAttachPackageID returns a new AppAttachPackageId struct +func NewAppAttachPackageID(subscriptionId string, resourceGroupName string, appAttachPackageName string) AppAttachPackageId { + return AppAttachPackageId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + AppAttachPackageName: appAttachPackageName, + } +} + +// ParseAppAttachPackageID parses 'input' into a AppAttachPackageId +func ParseAppAttachPackageID(input string) (*AppAttachPackageId, error) { + parser := resourceids.NewParserFromResourceIdType(&AppAttachPackageId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AppAttachPackageId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAppAttachPackageIDInsensitively parses 'input' case-insensitively into a AppAttachPackageId +// note: this method should only be used for API response data and not user input +func ParseAppAttachPackageIDInsensitively(input string) (*AppAttachPackageId, error) { + parser := resourceids.NewParserFromResourceIdType(&AppAttachPackageId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AppAttachPackageId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AppAttachPackageId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.AppAttachPackageName, ok = input.Parsed["appAttachPackageName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "appAttachPackageName", input) + } + + return nil +} + +// ValidateAppAttachPackageID checks that 'input' can be parsed as a App Attach Package ID +func ValidateAppAttachPackageID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseAppAttachPackageID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted App Attach Package ID +func (id AppAttachPackageId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DesktopVirtualization/appAttachPackages/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.AppAttachPackageName) +} + +// Segments returns a slice of Resource ID Segments which comprise this App Attach Package ID +func (id AppAttachPackageId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDesktopVirtualization", "Microsoft.DesktopVirtualization", "Microsoft.DesktopVirtualization"), + resourceids.StaticSegment("staticAppAttachPackages", "appAttachPackages", "appAttachPackages"), + resourceids.UserSpecifiedSegment("appAttachPackageName", "appAttachPackageName"), + } +} + +// String returns a human-readable description of this App Attach Package ID +func (id AppAttachPackageId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("App Attach Package Name: %q", id.AppAttachPackageName), + } + return fmt.Sprintf("App Attach Package (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/id_appattachpackage_test.go b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/id_appattachpackage_test.go new file mode 100644 index 00000000000..ae15ac67470 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/id_appattachpackage_test.go @@ -0,0 +1,282 @@ +package appattachpackage + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &AppAttachPackageId{} + +func TestNewAppAttachPackageID(t *testing.T) { + id := NewAppAttachPackageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "appAttachPackageName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.AppAttachPackageName != "appAttachPackageName" { + t.Fatalf("Expected %q but got %q for Segment 'AppAttachPackageName'", id.AppAttachPackageName, "appAttachPackageName") + } +} + +func TestFormatAppAttachPackageID(t *testing.T) { + actual := NewAppAttachPackageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "appAttachPackageName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/appAttachPackages/appAttachPackageName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseAppAttachPackageID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AppAttachPackageId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/appAttachPackages", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/appAttachPackages/appAttachPackageName", + Expected: &AppAttachPackageId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + AppAttachPackageName: "appAttachPackageName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/appAttachPackages/appAttachPackageName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAppAttachPackageID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.AppAttachPackageName != v.Expected.AppAttachPackageName { + t.Fatalf("Expected %q but got %q for AppAttachPackageName", v.Expected.AppAttachPackageName, actual.AppAttachPackageName) + } + + } +} + +func TestParseAppAttachPackageIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AppAttachPackageId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/appAttachPackages", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/aPpAtTaChPaCkAgEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/appAttachPackages/appAttachPackageName", + Expected: &AppAttachPackageId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + AppAttachPackageName: "appAttachPackageName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/appAttachPackages/appAttachPackageName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/aPpAtTaChPaCkAgEs/aPpAtTaChPaCkAgEnAmE", + Expected: &AppAttachPackageId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + AppAttachPackageName: "aPpAtTaChPaCkAgEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/aPpAtTaChPaCkAgEs/aPpAtTaChPaCkAgEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAppAttachPackageIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.AppAttachPackageName != v.Expected.AppAttachPackageName { + t.Fatalf("Expected %q but got %q for AppAttachPackageName", v.Expected.AppAttachPackageName, actual.AppAttachPackageName) + } + + } +} + +func TestSegmentsForAppAttachPackageId(t *testing.T) { + segments := AppAttachPackageId{}.Segments() + if len(segments) == 0 { + t.Fatalf("AppAttachPackageId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/method_createorupdate.go b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/method_createorupdate.go new file mode 100644 index 00000000000..93ce3d4705d --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/method_createorupdate.go @@ -0,0 +1,58 @@ +package appattachpackage + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AppAttachPackage +} + +// CreateOrUpdate ... +func (c AppAttachPackageClient) CreateOrUpdate(ctx context.Context, id AppAttachPackageId, input AppAttachPackage) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AppAttachPackage + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/method_delete.go b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/method_delete.go new file mode 100644 index 00000000000..0feb4e8763b --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/method_delete.go @@ -0,0 +1,77 @@ +package appattachpackage + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + Force *bool +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Force != nil { + out.Append("force", fmt.Sprintf("%v", *o.Force)) + } + return &out +} + +// Delete ... +func (c AppAttachPackageClient) Delete(ctx context.Context, id AppAttachPackageId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + 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/desktopvirtualization/2024-04-08-preview/appattachpackage/method_get.go b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/method_get.go new file mode 100644 index 00000000000..b8675cd5960 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/method_get.go @@ -0,0 +1,53 @@ +package appattachpackage + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *AppAttachPackage +} + +// Get ... +func (c AppAttachPackageClient) Get(ctx context.Context, id AppAttachPackageId) (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 AppAttachPackage + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/method_listbyresourcegroup.go b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/method_listbyresourcegroup.go new file mode 100644 index 00000000000..5ec4fe855b1 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/method_listbyresourcegroup.go @@ -0,0 +1,135 @@ +package appattachpackage + +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 *[]AppAttachPackage +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []AppAttachPackage +} + +type ListByResourceGroupOperationOptions struct { + Filter *string +} + +func DefaultListByResourceGroupOperationOptions() ListByResourceGroupOperationOptions { + return ListByResourceGroupOperationOptions{} +} + +func (o ListByResourceGroupOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByResourceGroupOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListByResourceGroupOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c AppAttachPackageClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DesktopVirtualization/appAttachPackages", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AppAttachPackage `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 AppAttachPackageClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, options, AppAttachPackageOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppAttachPackageClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions, predicate AppAttachPackageOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]AppAttachPackage, 0) + + resp, err := c.ListByResourceGroup(ctx, id, options) + 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/desktopvirtualization/2024-04-08-preview/appattachpackage/method_listbysubscription.go b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/method_listbysubscription.go new file mode 100644 index 00000000000..19ace254ec1 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/method_listbysubscription.go @@ -0,0 +1,135 @@ +package appattachpackage + +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 *[]AppAttachPackage +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []AppAttachPackage +} + +type ListBySubscriptionOperationOptions struct { + Filter *string +} + +func DefaultListBySubscriptionOperationOptions() ListBySubscriptionOperationOptions { + return ListBySubscriptionOperationOptions{} +} + +func (o ListBySubscriptionOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListBySubscriptionOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListBySubscriptionOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +type ListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySubscription ... +func (c AppAttachPackageClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DesktopVirtualization/appAttachPackages", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AppAttachPackage `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 AppAttachPackageClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, options, AppAttachPackageOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppAttachPackageClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions, predicate AppAttachPackageOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]AppAttachPackage, 0) + + resp, err := c.ListBySubscription(ctx, id, options) + 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/desktopvirtualization/2024-04-08-preview/appattachpackage/method_update.go b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/method_update.go new file mode 100644 index 00000000000..2d3d680eb2e --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/method_update.go @@ -0,0 +1,57 @@ +package appattachpackage + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AppAttachPackage +} + +// Update ... +func (c AppAttachPackageClient) Update(ctx context.Context, id AppAttachPackageId, input AppAttachPackagePatch) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AppAttachPackage + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/model_appattachpackage.go b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/model_appattachpackage.go new file mode 100644 index 00000000000..31f124ce62f --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/model_appattachpackage.go @@ -0,0 +1,18 @@ +package appattachpackage + +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 AppAttachPackage struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties AppAttachPackageProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/model_appattachpackageinfoproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/model_appattachpackageinfoproperties.go new file mode 100644 index 00000000000..1decd9837ab --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/model_appattachpackageinfoproperties.go @@ -0,0 +1,53 @@ +package appattachpackage + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppAttachPackageInfoProperties struct { + CertificateExpiry *string `json:"certificateExpiry,omitempty"` + CertificateName *string `json:"certificateName,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + ImagePath *string `json:"imagePath,omitempty"` + IsActive *bool `json:"isActive,omitempty"` + IsPackageTimestamped *PackageTimestamped `json:"isPackageTimestamped,omitempty"` + IsRegularRegistration *bool `json:"isRegularRegistration,omitempty"` + LastUpdated *string `json:"lastUpdated,omitempty"` + PackageAlias *string `json:"packageAlias,omitempty"` + PackageApplications *[]MsixPackageApplications `json:"packageApplications,omitempty"` + PackageDependencies *[]MsixPackageDependencies `json:"packageDependencies,omitempty"` + PackageFamilyName *string `json:"packageFamilyName,omitempty"` + PackageFullName *string `json:"packageFullName,omitempty"` + PackageName *string `json:"packageName,omitempty"` + PackageRelativePath *string `json:"packageRelativePath,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *AppAttachPackageInfoProperties) GetCertificateExpiryAsTime() (*time.Time, error) { + if o.CertificateExpiry == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CertificateExpiry, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppAttachPackageInfoProperties) SetCertificateExpiryAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CertificateExpiry = &formatted +} + +func (o *AppAttachPackageInfoProperties) GetLastUpdatedAsTime() (*time.Time, error) { + if o.LastUpdated == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastUpdated, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppAttachPackageInfoProperties) SetLastUpdatedAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastUpdated = &formatted +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/model_appattachpackagepatch.go b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/model_appattachpackagepatch.go new file mode 100644 index 00000000000..586a76d5627 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/model_appattachpackagepatch.go @@ -0,0 +1,17 @@ +package appattachpackage + +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 AppAttachPackagePatch struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AppAttachPackagePatchProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/model_appattachpackagepatchproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/model_appattachpackagepatchproperties.go new file mode 100644 index 00000000000..6a499d9c7a6 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/model_appattachpackagepatchproperties.go @@ -0,0 +1,13 @@ +package appattachpackage + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppAttachPackagePatchProperties struct { + CustomData *string `json:"customData,omitempty"` + FailHealthCheckOnStagingFailure *FailHealthCheckOnStagingFailure `json:"failHealthCheckOnStagingFailure,omitempty"` + HostPoolReferences *[]string `json:"hostPoolReferences,omitempty"` + Image *AppAttachPackageInfoProperties `json:"image,omitempty"` + KeyVaultURL *string `json:"keyVaultURL,omitempty"` + PackageLookbackURL *string `json:"packageLookbackUrl,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/model_appattachpackageproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/model_appattachpackageproperties.go new file mode 100644 index 00000000000..42953cae409 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/model_appattachpackageproperties.go @@ -0,0 +1,15 @@ +package appattachpackage + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppAttachPackageProperties struct { + CustomData *string `json:"customData,omitempty"` + FailHealthCheckOnStagingFailure *FailHealthCheckOnStagingFailure `json:"failHealthCheckOnStagingFailure,omitempty"` + HostPoolReferences *[]string `json:"hostPoolReferences,omitempty"` + Image *AppAttachPackageInfoProperties `json:"image,omitempty"` + KeyVaultURL *string `json:"keyVaultURL,omitempty"` + PackageLookbackURL *string `json:"packageLookbackUrl,omitempty"` + PackageOwnerName *string `json:"packageOwnerName,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/model_msixpackageapplications.go b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/model_msixpackageapplications.go new file mode 100644 index 00000000000..4019677d7a2 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/model_msixpackageapplications.go @@ -0,0 +1,14 @@ +package appattachpackage + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MsixPackageApplications struct { + AppId *string `json:"appId,omitempty"` + AppUserModelID *string `json:"appUserModelID,omitempty"` + Description *string `json:"description,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + IconImageName *string `json:"iconImageName,omitempty"` + RawIcon *string `json:"rawIcon,omitempty"` + RawPng *string `json:"rawPng,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/model_msixpackagedependencies.go b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/model_msixpackagedependencies.go new file mode 100644 index 00000000000..28297bd9ad3 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/model_msixpackagedependencies.go @@ -0,0 +1,10 @@ +package appattachpackage + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MsixPackageDependencies struct { + DependencyName *string `json:"dependencyName,omitempty"` + MinVersion *string `json:"minVersion,omitempty"` + Publisher *string `json:"publisher,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/predicates.go b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/predicates.go new file mode 100644 index 00000000000..68d67dea512 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/predicates.go @@ -0,0 +1,32 @@ +package appattachpackage + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppAttachPackageOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p AppAttachPackageOperationPredicate) Matches(input AppAttachPackage) 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/desktopvirtualization/2024-04-08-preview/appattachpackage/version.go b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/version.go new file mode 100644 index 00000000000..63d66c68983 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage/version.go @@ -0,0 +1,10 @@ +package appattachpackage + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-08-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/appattachpackage/2024-04-08-preview" +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/README.md b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/README.md new file mode 100644 index 00000000000..7c762afa22c --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/README.md @@ -0,0 +1,42 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo` Documentation + +The `appattachpackageinfo` SDK allows for interaction with Azure Resource Manager `desktopvirtualization` (API Version `2024-04-08-preview`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo" +``` + + +### Client Initialization + +```go +client := appattachpackageinfo.NewAppAttachPackageInfoClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AppAttachPackageInfoClient.Import` + +```go +ctx := context.TODO() +id := appattachpackageinfo.NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName") + +payload := appattachpackageinfo.ImportPackageInfoRequest{ + // ... +} + + +// alternatively `client.Import(ctx, id, payload)` can be used to do batched pagination +items, err := client.ImportComplete(ctx, id, payload) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/client.go b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/client.go new file mode 100644 index 00000000000..f8ada420dee --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/client.go @@ -0,0 +1,26 @@ +package appattachpackageinfo + +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 AppAttachPackageInfoClient struct { + Client *resourcemanager.Client +} + +func NewAppAttachPackageInfoClientWithBaseURI(sdkApi sdkEnv.Api) (*AppAttachPackageInfoClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "appattachpackageinfo", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AppAttachPackageInfoClient: %+v", err) + } + + return &AppAttachPackageInfoClient{ + Client: client, + }, nil +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/constants.go b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/constants.go new file mode 100644 index 00000000000..0bf2308d55c --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/constants.go @@ -0,0 +1,198 @@ +package appattachpackageinfo + +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 AppAttachPackageArchitectures string + +const ( + AppAttachPackageArchitecturesALL AppAttachPackageArchitectures = "ALL" + AppAttachPackageArchitecturesARM AppAttachPackageArchitectures = "ARM" + AppAttachPackageArchitecturesARMSixFour AppAttachPackageArchitectures = "ARM64" + AppAttachPackageArchitecturesNeutral AppAttachPackageArchitectures = "Neutral" + AppAttachPackageArchitecturesXEightSix AppAttachPackageArchitectures = "x86" + AppAttachPackageArchitecturesXEightSixaSixFour AppAttachPackageArchitectures = "x86a64" + AppAttachPackageArchitecturesXSixFour AppAttachPackageArchitectures = "x64" +) + +func PossibleValuesForAppAttachPackageArchitectures() []string { + return []string{ + string(AppAttachPackageArchitecturesALL), + string(AppAttachPackageArchitecturesARM), + string(AppAttachPackageArchitecturesARMSixFour), + string(AppAttachPackageArchitecturesNeutral), + string(AppAttachPackageArchitecturesXEightSix), + string(AppAttachPackageArchitecturesXEightSixaSixFour), + string(AppAttachPackageArchitecturesXSixFour), + } +} + +func (s *AppAttachPackageArchitectures) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAppAttachPackageArchitectures(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAppAttachPackageArchitectures(input string) (*AppAttachPackageArchitectures, error) { + vals := map[string]AppAttachPackageArchitectures{ + "all": AppAttachPackageArchitecturesALL, + "arm": AppAttachPackageArchitecturesARM, + "arm64": AppAttachPackageArchitecturesARMSixFour, + "neutral": AppAttachPackageArchitecturesNeutral, + "x86": AppAttachPackageArchitecturesXEightSix, + "x86a64": AppAttachPackageArchitecturesXEightSixaSixFour, + "x64": AppAttachPackageArchitecturesXSixFour, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AppAttachPackageArchitectures(input) + return &out, nil +} + +type FailHealthCheckOnStagingFailure string + +const ( + FailHealthCheckOnStagingFailureDoNotFail FailHealthCheckOnStagingFailure = "DoNotFail" + FailHealthCheckOnStagingFailureNeedsAssistance FailHealthCheckOnStagingFailure = "NeedsAssistance" + FailHealthCheckOnStagingFailureUnhealthy FailHealthCheckOnStagingFailure = "Unhealthy" +) + +func PossibleValuesForFailHealthCheckOnStagingFailure() []string { + return []string{ + string(FailHealthCheckOnStagingFailureDoNotFail), + string(FailHealthCheckOnStagingFailureNeedsAssistance), + string(FailHealthCheckOnStagingFailureUnhealthy), + } +} + +func (s *FailHealthCheckOnStagingFailure) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFailHealthCheckOnStagingFailure(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFailHealthCheckOnStagingFailure(input string) (*FailHealthCheckOnStagingFailure, error) { + vals := map[string]FailHealthCheckOnStagingFailure{ + "donotfail": FailHealthCheckOnStagingFailureDoNotFail, + "needsassistance": FailHealthCheckOnStagingFailureNeedsAssistance, + "unhealthy": FailHealthCheckOnStagingFailureUnhealthy, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FailHealthCheckOnStagingFailure(input) + return &out, nil +} + +type PackageTimestamped string + +const ( + PackageTimestampedNotTimestamped PackageTimestamped = "NotTimestamped" + PackageTimestampedTimestamped PackageTimestamped = "Timestamped" +) + +func PossibleValuesForPackageTimestamped() []string { + return []string{ + string(PackageTimestampedNotTimestamped), + string(PackageTimestampedTimestamped), + } +} + +func (s *PackageTimestamped) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePackageTimestamped(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePackageTimestamped(input string) (*PackageTimestamped, error) { + vals := map[string]PackageTimestamped{ + "nottimestamped": PackageTimestampedNotTimestamped, + "timestamped": PackageTimestampedTimestamped, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PackageTimestamped(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateProvisioning ProvisioningState = "Provisioning" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateFailed), + string(ProvisioningStateProvisioning), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "failed": ProvisioningStateFailed, + "provisioning": ProvisioningStateProvisioning, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/id_hostpool.go b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/id_hostpool.go new file mode 100644 index 00000000000..4676a323348 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/id_hostpool.go @@ -0,0 +1,130 @@ +package appattachpackageinfo + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&HostPoolId{}) +} + +var _ resourceids.ResourceId = &HostPoolId{} + +// HostPoolId is a struct representing the Resource ID for a Host Pool +type HostPoolId struct { + SubscriptionId string + ResourceGroupName string + HostPoolName string +} + +// NewHostPoolID returns a new HostPoolId struct +func NewHostPoolID(subscriptionId string, resourceGroupName string, hostPoolName string) HostPoolId { + return HostPoolId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + HostPoolName: hostPoolName, + } +} + +// ParseHostPoolID parses 'input' into a HostPoolId +func ParseHostPoolID(input string) (*HostPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostPoolId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostPoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseHostPoolIDInsensitively parses 'input' case-insensitively into a HostPoolId +// note: this method should only be used for API response data and not user input +func ParseHostPoolIDInsensitively(input string) (*HostPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostPoolId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostPoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *HostPoolId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.HostPoolName, ok = input.Parsed["hostPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hostPoolName", input) + } + + return nil +} + +// ValidateHostPoolID checks that 'input' can be parsed as a Host Pool ID +func ValidateHostPoolID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseHostPoolID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Host Pool ID +func (id HostPoolId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DesktopVirtualization/hostPools/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.HostPoolName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Host Pool ID +func (id HostPoolId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDesktopVirtualization", "Microsoft.DesktopVirtualization", "Microsoft.DesktopVirtualization"), + resourceids.StaticSegment("staticHostPools", "hostPools", "hostPools"), + resourceids.UserSpecifiedSegment("hostPoolName", "hostPoolName"), + } +} + +// String returns a human-readable description of this Host Pool ID +func (id HostPoolId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Host Pool Name: %q", id.HostPoolName), + } + return fmt.Sprintf("Host Pool (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/id_hostpool_test.go b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/id_hostpool_test.go new file mode 100644 index 00000000000..2864dbbb6ca --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/id_hostpool_test.go @@ -0,0 +1,282 @@ +package appattachpackageinfo + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &HostPoolId{} + +func TestNewHostPoolID(t *testing.T) { + id := NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.HostPoolName != "hostPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'HostPoolName'", id.HostPoolName, "hostPoolName") + } +} + +func TestFormatHostPoolID(t *testing.T) { + actual := NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseHostPoolID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostPoolId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName", + Expected: &HostPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostPoolName: "hostPoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostPoolID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostPoolName != v.Expected.HostPoolName { + t.Fatalf("Expected %q but got %q for HostPoolName", v.Expected.HostPoolName, actual.HostPoolName) + } + + } +} + +func TestParseHostPoolIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostPoolId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName", + Expected: &HostPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostPoolName: "hostPoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs/hOsTpOoLnAmE", + Expected: &HostPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + HostPoolName: "hOsTpOoLnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs/hOsTpOoLnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostPoolIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostPoolName != v.Expected.HostPoolName { + t.Fatalf("Expected %q but got %q for HostPoolName", v.Expected.HostPoolName, actual.HostPoolName) + } + + } +} + +func TestSegmentsForHostPoolId(t *testing.T) { + segments := HostPoolId{}.Segments() + if len(segments) == 0 { + t.Fatalf("HostPoolId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/method_import.go b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/method_import.go new file mode 100644 index 00000000000..7797197f65e --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/method_import.go @@ -0,0 +1,105 @@ +package appattachpackageinfo + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ImportOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AppAttachPackage +} + +type ImportCompleteResult struct { + LatestHttpResponse *http.Response + Items []AppAttachPackage +} + +type ImportCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ImportCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// Import ... +func (c AppAttachPackageInfoClient) Import(ctx context.Context, id HostPoolId, input ImportPackageInfoRequest) (result ImportOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ImportCustomPager{}, + Path: fmt.Sprintf("%s/importAppAttachPackageInfo", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AppAttachPackage `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ImportComplete retrieves all the results into a single object +func (c AppAttachPackageInfoClient) ImportComplete(ctx context.Context, id HostPoolId, input ImportPackageInfoRequest) (ImportCompleteResult, error) { + return c.ImportCompleteMatchingPredicate(ctx, id, input, AppAttachPackageOperationPredicate{}) +} + +// ImportCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppAttachPackageInfoClient) ImportCompleteMatchingPredicate(ctx context.Context, id HostPoolId, input ImportPackageInfoRequest, predicate AppAttachPackageOperationPredicate) (result ImportCompleteResult, err error) { + items := make([]AppAttachPackage, 0) + + resp, err := c.Import(ctx, id, input) + 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 = ImportCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/model_appattachpackage.go b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/model_appattachpackage.go new file mode 100644 index 00000000000..8647807cb71 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/model_appattachpackage.go @@ -0,0 +1,18 @@ +package appattachpackageinfo + +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 AppAttachPackage struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties AppAttachPackageProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/model_appattachpackageinfoproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/model_appattachpackageinfoproperties.go new file mode 100644 index 00000000000..6d961a8198f --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/model_appattachpackageinfoproperties.go @@ -0,0 +1,53 @@ +package appattachpackageinfo + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppAttachPackageInfoProperties struct { + CertificateExpiry *string `json:"certificateExpiry,omitempty"` + CertificateName *string `json:"certificateName,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + ImagePath *string `json:"imagePath,omitempty"` + IsActive *bool `json:"isActive,omitempty"` + IsPackageTimestamped *PackageTimestamped `json:"isPackageTimestamped,omitempty"` + IsRegularRegistration *bool `json:"isRegularRegistration,omitempty"` + LastUpdated *string `json:"lastUpdated,omitempty"` + PackageAlias *string `json:"packageAlias,omitempty"` + PackageApplications *[]MsixPackageApplications `json:"packageApplications,omitempty"` + PackageDependencies *[]MsixPackageDependencies `json:"packageDependencies,omitempty"` + PackageFamilyName *string `json:"packageFamilyName,omitempty"` + PackageFullName *string `json:"packageFullName,omitempty"` + PackageName *string `json:"packageName,omitempty"` + PackageRelativePath *string `json:"packageRelativePath,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *AppAttachPackageInfoProperties) GetCertificateExpiryAsTime() (*time.Time, error) { + if o.CertificateExpiry == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CertificateExpiry, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppAttachPackageInfoProperties) SetCertificateExpiryAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CertificateExpiry = &formatted +} + +func (o *AppAttachPackageInfoProperties) GetLastUpdatedAsTime() (*time.Time, error) { + if o.LastUpdated == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastUpdated, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppAttachPackageInfoProperties) SetLastUpdatedAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastUpdated = &formatted +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/model_appattachpackageproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/model_appattachpackageproperties.go new file mode 100644 index 00000000000..8ad62770b32 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/model_appattachpackageproperties.go @@ -0,0 +1,15 @@ +package appattachpackageinfo + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppAttachPackageProperties struct { + CustomData *string `json:"customData,omitempty"` + FailHealthCheckOnStagingFailure *FailHealthCheckOnStagingFailure `json:"failHealthCheckOnStagingFailure,omitempty"` + HostPoolReferences *[]string `json:"hostPoolReferences,omitempty"` + Image *AppAttachPackageInfoProperties `json:"image,omitempty"` + KeyVaultURL *string `json:"keyVaultURL,omitempty"` + PackageLookbackURL *string `json:"packageLookbackUrl,omitempty"` + PackageOwnerName *string `json:"packageOwnerName,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/model_importpackageinforequest.go b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/model_importpackageinforequest.go new file mode 100644 index 00000000000..0fa709347ac --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/model_importpackageinforequest.go @@ -0,0 +1,9 @@ +package appattachpackageinfo + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ImportPackageInfoRequest struct { + PackageArchitecture *AppAttachPackageArchitectures `json:"packageArchitecture,omitempty"` + Path *string `json:"path,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/model_msixpackageapplications.go b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/model_msixpackageapplications.go new file mode 100644 index 00000000000..39c1b13428c --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/model_msixpackageapplications.go @@ -0,0 +1,14 @@ +package appattachpackageinfo + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MsixPackageApplications struct { + AppId *string `json:"appId,omitempty"` + AppUserModelID *string `json:"appUserModelID,omitempty"` + Description *string `json:"description,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + IconImageName *string `json:"iconImageName,omitempty"` + RawIcon *string `json:"rawIcon,omitempty"` + RawPng *string `json:"rawPng,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/model_msixpackagedependencies.go b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/model_msixpackagedependencies.go new file mode 100644 index 00000000000..6be16707fa7 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/model_msixpackagedependencies.go @@ -0,0 +1,10 @@ +package appattachpackageinfo + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MsixPackageDependencies struct { + DependencyName *string `json:"dependencyName,omitempty"` + MinVersion *string `json:"minVersion,omitempty"` + Publisher *string `json:"publisher,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/predicates.go b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/predicates.go new file mode 100644 index 00000000000..cf1e3360fb2 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/predicates.go @@ -0,0 +1,32 @@ +package appattachpackageinfo + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppAttachPackageOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p AppAttachPackageOperationPredicate) Matches(input AppAttachPackage) 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/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/version.go b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/version.go new file mode 100644 index 00000000000..43559b52f10 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo/version.go @@ -0,0 +1,10 @@ +package appattachpackageinfo + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-08-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/appattachpackageinfo/2024-04-08-preview" +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/application/README.md b/resource-manager/desktopvirtualization/2024-04-08-preview/application/README.md new file mode 100644 index 00000000000..f405da0aaac --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/application/README.md @@ -0,0 +1,111 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/application` Documentation + +The `application` SDK allows for interaction with Azure Resource Manager `desktopvirtualization` (API Version `2024-04-08-preview`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/application" +``` + + +### Client Initialization + +```go +client := application.NewApplicationClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ApplicationClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := application.NewApplicationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGroupName", "applicationName") + +payload := application.Application{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ApplicationClient.Delete` + +```go +ctx := context.TODO() +id := application.NewApplicationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGroupName", "applicationName") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ApplicationClient.Get` + +```go +ctx := context.TODO() +id := application.NewApplicationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGroupName", "applicationName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ApplicationClient.List` + +```go +ctx := context.TODO() +id := application.NewApplicationGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGroupName") + +// alternatively `client.List(ctx, id, application.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, application.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ApplicationClient.Update` + +```go +ctx := context.TODO() +id := application.NewApplicationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGroupName", "applicationName") + +payload := application.ApplicationPatch{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/application/client.go b/resource-manager/desktopvirtualization/2024-04-08-preview/application/client.go new file mode 100644 index 00000000000..552cea9994d --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/application/client.go @@ -0,0 +1,26 @@ +package application + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationClient struct { + Client *resourcemanager.Client +} + +func NewApplicationClientWithBaseURI(sdkApi sdkEnv.Api) (*ApplicationClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "application", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApplicationClient: %+v", err) + } + + return &ApplicationClient{ + Client: client, + }, nil +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/application/constants.go b/resource-manager/desktopvirtualization/2024-04-08-preview/application/constants.go new file mode 100644 index 00000000000..9ea57d7d006 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/application/constants.go @@ -0,0 +1,95 @@ +package application + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CommandLineSetting string + +const ( + CommandLineSettingAllow CommandLineSetting = "Allow" + CommandLineSettingDoNotAllow CommandLineSetting = "DoNotAllow" + CommandLineSettingRequire CommandLineSetting = "Require" +) + +func PossibleValuesForCommandLineSetting() []string { + return []string{ + string(CommandLineSettingAllow), + string(CommandLineSettingDoNotAllow), + string(CommandLineSettingRequire), + } +} + +func (s *CommandLineSetting) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCommandLineSetting(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCommandLineSetting(input string) (*CommandLineSetting, error) { + vals := map[string]CommandLineSetting{ + "allow": CommandLineSettingAllow, + "donotallow": CommandLineSettingDoNotAllow, + "require": CommandLineSettingRequire, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CommandLineSetting(input) + return &out, nil +} + +type RemoteApplicationType string + +const ( + RemoteApplicationTypeInBuilt RemoteApplicationType = "InBuilt" + RemoteApplicationTypeMsixApplication RemoteApplicationType = "MsixApplication" +) + +func PossibleValuesForRemoteApplicationType() []string { + return []string{ + string(RemoteApplicationTypeInBuilt), + string(RemoteApplicationTypeMsixApplication), + } +} + +func (s *RemoteApplicationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRemoteApplicationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRemoteApplicationType(input string) (*RemoteApplicationType, error) { + vals := map[string]RemoteApplicationType{ + "inbuilt": RemoteApplicationTypeInBuilt, + "msixapplication": RemoteApplicationTypeMsixApplication, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RemoteApplicationType(input) + return &out, nil +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/application/id_application.go b/resource-manager/desktopvirtualization/2024-04-08-preview/application/id_application.go new file mode 100644 index 00000000000..d2582eb3a20 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/application/id_application.go @@ -0,0 +1,139 @@ +package application + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ApplicationId{}) +} + +var _ resourceids.ResourceId = &ApplicationId{} + +// ApplicationId is a struct representing the Resource ID for a Application +type ApplicationId struct { + SubscriptionId string + ResourceGroupName string + ApplicationGroupName string + ApplicationName string +} + +// NewApplicationID returns a new ApplicationId struct +func NewApplicationID(subscriptionId string, resourceGroupName string, applicationGroupName string, applicationName string) ApplicationId { + return ApplicationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ApplicationGroupName: applicationGroupName, + ApplicationName: applicationName, + } +} + +// ParseApplicationID parses 'input' into a ApplicationId +func ParseApplicationID(input string) (*ApplicationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ApplicationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ApplicationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseApplicationIDInsensitively parses 'input' case-insensitively into a ApplicationId +// note: this method should only be used for API response data and not user input +func ParseApplicationIDInsensitively(input string) (*ApplicationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ApplicationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ApplicationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ApplicationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ApplicationGroupName, ok = input.Parsed["applicationGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "applicationGroupName", input) + } + + if id.ApplicationName, ok = input.Parsed["applicationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "applicationName", input) + } + + return nil +} + +// ValidateApplicationID checks that 'input' can be parsed as a Application ID +func ValidateApplicationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseApplicationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Application ID +func (id ApplicationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DesktopVirtualization/applicationGroups/%s/applications/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ApplicationGroupName, id.ApplicationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Application ID +func (id ApplicationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDesktopVirtualization", "Microsoft.DesktopVirtualization", "Microsoft.DesktopVirtualization"), + resourceids.StaticSegment("staticApplicationGroups", "applicationGroups", "applicationGroups"), + resourceids.UserSpecifiedSegment("applicationGroupName", "applicationGroupName"), + resourceids.StaticSegment("staticApplications", "applications", "applications"), + resourceids.UserSpecifiedSegment("applicationName", "applicationName"), + } +} + +// String returns a human-readable description of this Application ID +func (id ApplicationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Application Group Name: %q", id.ApplicationGroupName), + fmt.Sprintf("Application Name: %q", id.ApplicationName), + } + return fmt.Sprintf("Application (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/application/id_application_test.go b/resource-manager/desktopvirtualization/2024-04-08-preview/application/id_application_test.go new file mode 100644 index 00000000000..f7659597026 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/application/id_application_test.go @@ -0,0 +1,327 @@ +package application + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ApplicationId{} + +func TestNewApplicationID(t *testing.T) { + id := NewApplicationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGroupName", "applicationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ApplicationGroupName != "applicationGroupName" { + t.Fatalf("Expected %q but got %q for Segment 'ApplicationGroupName'", id.ApplicationGroupName, "applicationGroupName") + } + + if id.ApplicationName != "applicationName" { + t.Fatalf("Expected %q but got %q for Segment 'ApplicationName'", id.ApplicationName, "applicationName") + } +} + +func TestFormatApplicationID(t *testing.T) { + actual := NewApplicationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGroupName", "applicationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups/applicationGroupName/applications/applicationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseApplicationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ApplicationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups/applicationGroupName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups/applicationGroupName/applications", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups/applicationGroupName/applications/applicationName", + Expected: &ApplicationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ApplicationGroupName: "applicationGroupName", + ApplicationName: "applicationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups/applicationGroupName/applications/applicationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseApplicationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ApplicationGroupName != v.Expected.ApplicationGroupName { + t.Fatalf("Expected %q but got %q for ApplicationGroupName", v.Expected.ApplicationGroupName, actual.ApplicationGroupName) + } + + if actual.ApplicationName != v.Expected.ApplicationName { + t.Fatalf("Expected %q but got %q for ApplicationName", v.Expected.ApplicationName, actual.ApplicationName) + } + + } +} + +func TestParseApplicationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ApplicationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/aPpLiCaTiOnGrOuPs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups/applicationGroupName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/aPpLiCaTiOnGrOuPs/aPpLiCaTiOnGrOuPnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups/applicationGroupName/applications", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/aPpLiCaTiOnGrOuPs/aPpLiCaTiOnGrOuPnAmE/aPpLiCaTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups/applicationGroupName/applications/applicationName", + Expected: &ApplicationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ApplicationGroupName: "applicationGroupName", + ApplicationName: "applicationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups/applicationGroupName/applications/applicationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/aPpLiCaTiOnGrOuPs/aPpLiCaTiOnGrOuPnAmE/aPpLiCaTiOnS/aPpLiCaTiOnNaMe", + Expected: &ApplicationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ApplicationGroupName: "aPpLiCaTiOnGrOuPnAmE", + ApplicationName: "aPpLiCaTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/aPpLiCaTiOnGrOuPs/aPpLiCaTiOnGrOuPnAmE/aPpLiCaTiOnS/aPpLiCaTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseApplicationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ApplicationGroupName != v.Expected.ApplicationGroupName { + t.Fatalf("Expected %q but got %q for ApplicationGroupName", v.Expected.ApplicationGroupName, actual.ApplicationGroupName) + } + + if actual.ApplicationName != v.Expected.ApplicationName { + t.Fatalf("Expected %q but got %q for ApplicationName", v.Expected.ApplicationName, actual.ApplicationName) + } + + } +} + +func TestSegmentsForApplicationId(t *testing.T) { + segments := ApplicationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ApplicationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/application/id_applicationgroup.go b/resource-manager/desktopvirtualization/2024-04-08-preview/application/id_applicationgroup.go new file mode 100644 index 00000000000..93ce697d10d --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/application/id_applicationgroup.go @@ -0,0 +1,130 @@ +package application + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ApplicationGroupId{}) +} + +var _ resourceids.ResourceId = &ApplicationGroupId{} + +// ApplicationGroupId is a struct representing the Resource ID for a Application Group +type ApplicationGroupId struct { + SubscriptionId string + ResourceGroupName string + ApplicationGroupName string +} + +// NewApplicationGroupID returns a new ApplicationGroupId struct +func NewApplicationGroupID(subscriptionId string, resourceGroupName string, applicationGroupName string) ApplicationGroupId { + return ApplicationGroupId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ApplicationGroupName: applicationGroupName, + } +} + +// ParseApplicationGroupID parses 'input' into a ApplicationGroupId +func ParseApplicationGroupID(input string) (*ApplicationGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&ApplicationGroupId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ApplicationGroupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseApplicationGroupIDInsensitively parses 'input' case-insensitively into a ApplicationGroupId +// note: this method should only be used for API response data and not user input +func ParseApplicationGroupIDInsensitively(input string) (*ApplicationGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&ApplicationGroupId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ApplicationGroupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ApplicationGroupId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ApplicationGroupName, ok = input.Parsed["applicationGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "applicationGroupName", input) + } + + return nil +} + +// ValidateApplicationGroupID checks that 'input' can be parsed as a Application Group ID +func ValidateApplicationGroupID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseApplicationGroupID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Application Group ID +func (id ApplicationGroupId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DesktopVirtualization/applicationGroups/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ApplicationGroupName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Application Group ID +func (id ApplicationGroupId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDesktopVirtualization", "Microsoft.DesktopVirtualization", "Microsoft.DesktopVirtualization"), + resourceids.StaticSegment("staticApplicationGroups", "applicationGroups", "applicationGroups"), + resourceids.UserSpecifiedSegment("applicationGroupName", "applicationGroupName"), + } +} + +// String returns a human-readable description of this Application Group ID +func (id ApplicationGroupId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Application Group Name: %q", id.ApplicationGroupName), + } + return fmt.Sprintf("Application Group (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/application/id_applicationgroup_test.go b/resource-manager/desktopvirtualization/2024-04-08-preview/application/id_applicationgroup_test.go new file mode 100644 index 00000000000..6f51e5fa1a9 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/application/id_applicationgroup_test.go @@ -0,0 +1,282 @@ +package application + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ApplicationGroupId{} + +func TestNewApplicationGroupID(t *testing.T) { + id := NewApplicationGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGroupName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ApplicationGroupName != "applicationGroupName" { + t.Fatalf("Expected %q but got %q for Segment 'ApplicationGroupName'", id.ApplicationGroupName, "applicationGroupName") + } +} + +func TestFormatApplicationGroupID(t *testing.T) { + actual := NewApplicationGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGroupName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups/applicationGroupName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseApplicationGroupID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ApplicationGroupId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups/applicationGroupName", + Expected: &ApplicationGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ApplicationGroupName: "applicationGroupName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups/applicationGroupName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseApplicationGroupID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ApplicationGroupName != v.Expected.ApplicationGroupName { + t.Fatalf("Expected %q but got %q for ApplicationGroupName", v.Expected.ApplicationGroupName, actual.ApplicationGroupName) + } + + } +} + +func TestParseApplicationGroupIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ApplicationGroupId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/aPpLiCaTiOnGrOuPs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups/applicationGroupName", + Expected: &ApplicationGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ApplicationGroupName: "applicationGroupName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups/applicationGroupName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/aPpLiCaTiOnGrOuPs/aPpLiCaTiOnGrOuPnAmE", + Expected: &ApplicationGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ApplicationGroupName: "aPpLiCaTiOnGrOuPnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/aPpLiCaTiOnGrOuPs/aPpLiCaTiOnGrOuPnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseApplicationGroupIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ApplicationGroupName != v.Expected.ApplicationGroupName { + t.Fatalf("Expected %q but got %q for ApplicationGroupName", v.Expected.ApplicationGroupName, actual.ApplicationGroupName) + } + + } +} + +func TestSegmentsForApplicationGroupId(t *testing.T) { + segments := ApplicationGroupId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ApplicationGroupId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/application/method_createorupdate.go b/resource-manager/desktopvirtualization/2024-04-08-preview/application/method_createorupdate.go new file mode 100644 index 00000000000..b708f0b7f4f --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/application/method_createorupdate.go @@ -0,0 +1,58 @@ +package application + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Application +} + +// CreateOrUpdate ... +func (c ApplicationClient) CreateOrUpdate(ctx context.Context, id ApplicationId, input Application) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Application + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/application/method_delete.go b/resource-manager/desktopvirtualization/2024-04-08-preview/application/method_delete.go new file mode 100644 index 00000000000..37bef666ec7 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/application/method_delete.go @@ -0,0 +1,47 @@ +package application + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ApplicationClient) Delete(ctx context.Context, id ApplicationId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/application/method_get.go b/resource-manager/desktopvirtualization/2024-04-08-preview/application/method_get.go new file mode 100644 index 00000000000..288a250a410 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/application/method_get.go @@ -0,0 +1,53 @@ +package application + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Application +} + +// Get ... +func (c ApplicationClient) Get(ctx context.Context, id ApplicationId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Application + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/application/method_list.go b/resource-manager/desktopvirtualization/2024-04-08-preview/application/method_list.go new file mode 100644 index 00000000000..676a0e02709 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/application/method_list.go @@ -0,0 +1,142 @@ +package application + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Application +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Application +} + +type ListOperationOptions struct { + InitialSkip *int64 + IsDescending *bool + PageSize *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.InitialSkip != nil { + out.Append("initialSkip", fmt.Sprintf("%v", *o.InitialSkip)) + } + if o.IsDescending != nil { + out.Append("isDescending", fmt.Sprintf("%v", *o.IsDescending)) + } + if o.PageSize != nil { + out.Append("pageSize", fmt.Sprintf("%v", *o.PageSize)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ApplicationClient) List(ctx context.Context, id ApplicationGroupId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/applications", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Application `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ApplicationClient) ListComplete(ctx context.Context, id ApplicationGroupId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, ApplicationOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApplicationClient) ListCompleteMatchingPredicate(ctx context.Context, id ApplicationGroupId, options ListOperationOptions, predicate ApplicationOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Application, 0) + + resp, err := c.List(ctx, id, options) + 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 = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/application/method_update.go b/resource-manager/desktopvirtualization/2024-04-08-preview/application/method_update.go new file mode 100644 index 00000000000..4c47958c02e --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/application/method_update.go @@ -0,0 +1,57 @@ +package application + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Application +} + +// Update ... +func (c ApplicationClient) Update(ctx context.Context, id ApplicationId, input ApplicationPatch) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Application + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/application/model_application.go b/resource-manager/desktopvirtualization/2024-04-08-preview/application/model_application.go new file mode 100644 index 00000000000..700c972b9de --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/application/model_application.go @@ -0,0 +1,16 @@ +package application + +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 Application struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties ApplicationProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/application/model_applicationpatch.go b/resource-manager/desktopvirtualization/2024-04-08-preview/application/model_applicationpatch.go new file mode 100644 index 00000000000..5b0e7d1a071 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/application/model_applicationpatch.go @@ -0,0 +1,9 @@ +package application + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationPatch struct { + Properties *ApplicationPatchProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/application/model_applicationpatchproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/application/model_applicationpatchproperties.go new file mode 100644 index 00000000000..ada985872c6 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/application/model_applicationpatchproperties.go @@ -0,0 +1,18 @@ +package application + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationPatchProperties struct { + ApplicationType *RemoteApplicationType `json:"applicationType,omitempty"` + CommandLineArguments *string `json:"commandLineArguments,omitempty"` + CommandLineSetting *CommandLineSetting `json:"commandLineSetting,omitempty"` + Description *string `json:"description,omitempty"` + FilePath *string `json:"filePath,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + IconIndex *int64 `json:"iconIndex,omitempty"` + IconPath *string `json:"iconPath,omitempty"` + MsixPackageApplicationId *string `json:"msixPackageApplicationId,omitempty"` + MsixPackageFamilyName *string `json:"msixPackageFamilyName,omitempty"` + ShowInPortal *bool `json:"showInPortal,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/application/model_applicationproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/application/model_applicationproperties.go new file mode 100644 index 00000000000..74362ae1d50 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/application/model_applicationproperties.go @@ -0,0 +1,21 @@ +package application + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationProperties struct { + ApplicationType *RemoteApplicationType `json:"applicationType,omitempty"` + CommandLineArguments *string `json:"commandLineArguments,omitempty"` + CommandLineSetting CommandLineSetting `json:"commandLineSetting"` + Description *string `json:"description,omitempty"` + FilePath *string `json:"filePath,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + IconContent *string `json:"iconContent,omitempty"` + IconHash *string `json:"iconHash,omitempty"` + IconIndex *int64 `json:"iconIndex,omitempty"` + IconPath *string `json:"iconPath,omitempty"` + MsixPackageApplicationId *string `json:"msixPackageApplicationId,omitempty"` + MsixPackageFamilyName *string `json:"msixPackageFamilyName,omitempty"` + ObjectId *string `json:"objectId,omitempty"` + ShowInPortal *bool `json:"showInPortal,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/application/predicates.go b/resource-manager/desktopvirtualization/2024-04-08-preview/application/predicates.go new file mode 100644 index 00000000000..14cd75c9a58 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/application/predicates.go @@ -0,0 +1,27 @@ +package application + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p ApplicationOperationPredicate) Matches(input Application) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/application/version.go b/resource-manager/desktopvirtualization/2024-04-08-preview/application/version.go new file mode 100644 index 00000000000..a117e73703a --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/application/version.go @@ -0,0 +1,10 @@ +package application + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-08-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/application/2024-04-08-preview" +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/README.md b/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/README.md new file mode 100644 index 00000000000..c5b9581ceb1 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/README.md @@ -0,0 +1,129 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup` Documentation + +The `applicationgroup` SDK allows for interaction with Azure Resource Manager `desktopvirtualization` (API Version `2024-04-08-preview`). + +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/desktopvirtualization/2024-04-08-preview/applicationgroup" +``` + + +### Client Initialization + +```go +client := applicationgroup.NewApplicationGroupClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ApplicationGroupClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := applicationgroup.NewApplicationGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGroupName") + +payload := applicationgroup.ApplicationGroup{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ApplicationGroupClient.Delete` + +```go +ctx := context.TODO() +id := applicationgroup.NewApplicationGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGroupName") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ApplicationGroupClient.Get` + +```go +ctx := context.TODO() +id := applicationgroup.NewApplicationGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGroupName") + +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: `ApplicationGroupClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id, applicationgroup.DefaultListByResourceGroupOperationOptions())` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id, applicationgroup.DefaultListByResourceGroupOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ApplicationGroupClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id, applicationgroup.DefaultListBySubscriptionOperationOptions())` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id, applicationgroup.DefaultListBySubscriptionOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ApplicationGroupClient.Update` + +```go +ctx := context.TODO() +id := applicationgroup.NewApplicationGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGroupName") + +payload := applicationgroup.ApplicationGroupPatch{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/client.go b/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/client.go new file mode 100644 index 00000000000..286f253207b --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/client.go @@ -0,0 +1,26 @@ +package applicationgroup + +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 ApplicationGroupClient struct { + Client *resourcemanager.Client +} + +func NewApplicationGroupClientWithBaseURI(sdkApi sdkEnv.Api) (*ApplicationGroupClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "applicationgroup", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApplicationGroupClient: %+v", err) + } + + return &ApplicationGroupClient{ + Client: client, + }, nil +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/constants.go b/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/constants.go new file mode 100644 index 00000000000..174478e2b6e --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/constants.go @@ -0,0 +1,98 @@ +package applicationgroup + +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 ApplicationGroupType string + +const ( + ApplicationGroupTypeDesktop ApplicationGroupType = "Desktop" + ApplicationGroupTypeRemoteApp ApplicationGroupType = "RemoteApp" +) + +func PossibleValuesForApplicationGroupType() []string { + return []string{ + string(ApplicationGroupTypeDesktop), + string(ApplicationGroupTypeRemoteApp), + } +} + +func (s *ApplicationGroupType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationGroupType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationGroupType(input string) (*ApplicationGroupType, error) { + vals := map[string]ApplicationGroupType{ + "desktop": ApplicationGroupTypeDesktop, + "remoteapp": ApplicationGroupTypeRemoteApp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationGroupType(input) + return &out, nil +} + +type SkuTier string + +const ( + SkuTierBasic SkuTier = "Basic" + SkuTierFree SkuTier = "Free" + SkuTierPremium SkuTier = "Premium" + SkuTierStandard SkuTier = "Standard" +) + +func PossibleValuesForSkuTier() []string { + return []string{ + string(SkuTierBasic), + string(SkuTierFree), + string(SkuTierPremium), + string(SkuTierStandard), + } +} + +func (s *SkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSkuTier(input string) (*SkuTier, error) { + vals := map[string]SkuTier{ + "basic": SkuTierBasic, + "free": SkuTierFree, + "premium": SkuTierPremium, + "standard": SkuTierStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SkuTier(input) + return &out, nil +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/id_applicationgroup.go b/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/id_applicationgroup.go new file mode 100644 index 00000000000..ac389f7d9d7 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/id_applicationgroup.go @@ -0,0 +1,130 @@ +package applicationgroup + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ApplicationGroupId{}) +} + +var _ resourceids.ResourceId = &ApplicationGroupId{} + +// ApplicationGroupId is a struct representing the Resource ID for a Application Group +type ApplicationGroupId struct { + SubscriptionId string + ResourceGroupName string + ApplicationGroupName string +} + +// NewApplicationGroupID returns a new ApplicationGroupId struct +func NewApplicationGroupID(subscriptionId string, resourceGroupName string, applicationGroupName string) ApplicationGroupId { + return ApplicationGroupId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ApplicationGroupName: applicationGroupName, + } +} + +// ParseApplicationGroupID parses 'input' into a ApplicationGroupId +func ParseApplicationGroupID(input string) (*ApplicationGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&ApplicationGroupId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ApplicationGroupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseApplicationGroupIDInsensitively parses 'input' case-insensitively into a ApplicationGroupId +// note: this method should only be used for API response data and not user input +func ParseApplicationGroupIDInsensitively(input string) (*ApplicationGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&ApplicationGroupId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ApplicationGroupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ApplicationGroupId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ApplicationGroupName, ok = input.Parsed["applicationGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "applicationGroupName", input) + } + + return nil +} + +// ValidateApplicationGroupID checks that 'input' can be parsed as a Application Group ID +func ValidateApplicationGroupID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseApplicationGroupID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Application Group ID +func (id ApplicationGroupId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DesktopVirtualization/applicationGroups/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ApplicationGroupName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Application Group ID +func (id ApplicationGroupId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDesktopVirtualization", "Microsoft.DesktopVirtualization", "Microsoft.DesktopVirtualization"), + resourceids.StaticSegment("staticApplicationGroups", "applicationGroups", "applicationGroups"), + resourceids.UserSpecifiedSegment("applicationGroupName", "applicationGroupName"), + } +} + +// String returns a human-readable description of this Application Group ID +func (id ApplicationGroupId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Application Group Name: %q", id.ApplicationGroupName), + } + return fmt.Sprintf("Application Group (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/id_applicationgroup_test.go b/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/id_applicationgroup_test.go new file mode 100644 index 00000000000..bafc78722a9 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/id_applicationgroup_test.go @@ -0,0 +1,282 @@ +package applicationgroup + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ApplicationGroupId{} + +func TestNewApplicationGroupID(t *testing.T) { + id := NewApplicationGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGroupName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ApplicationGroupName != "applicationGroupName" { + t.Fatalf("Expected %q but got %q for Segment 'ApplicationGroupName'", id.ApplicationGroupName, "applicationGroupName") + } +} + +func TestFormatApplicationGroupID(t *testing.T) { + actual := NewApplicationGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGroupName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups/applicationGroupName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseApplicationGroupID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ApplicationGroupId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups/applicationGroupName", + Expected: &ApplicationGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ApplicationGroupName: "applicationGroupName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups/applicationGroupName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseApplicationGroupID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ApplicationGroupName != v.Expected.ApplicationGroupName { + t.Fatalf("Expected %q but got %q for ApplicationGroupName", v.Expected.ApplicationGroupName, actual.ApplicationGroupName) + } + + } +} + +func TestParseApplicationGroupIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ApplicationGroupId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/aPpLiCaTiOnGrOuPs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups/applicationGroupName", + Expected: &ApplicationGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ApplicationGroupName: "applicationGroupName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups/applicationGroupName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/aPpLiCaTiOnGrOuPs/aPpLiCaTiOnGrOuPnAmE", + Expected: &ApplicationGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ApplicationGroupName: "aPpLiCaTiOnGrOuPnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/aPpLiCaTiOnGrOuPs/aPpLiCaTiOnGrOuPnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseApplicationGroupIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ApplicationGroupName != v.Expected.ApplicationGroupName { + t.Fatalf("Expected %q but got %q for ApplicationGroupName", v.Expected.ApplicationGroupName, actual.ApplicationGroupName) + } + + } +} + +func TestSegmentsForApplicationGroupId(t *testing.T) { + segments := ApplicationGroupId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ApplicationGroupId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/method_createorupdate.go b/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/method_createorupdate.go new file mode 100644 index 00000000000..d68aa2ad139 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/method_createorupdate.go @@ -0,0 +1,58 @@ +package applicationgroup + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApplicationGroup +} + +// CreateOrUpdate ... +func (c ApplicationGroupClient) CreateOrUpdate(ctx context.Context, id ApplicationGroupId, input ApplicationGroup) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ApplicationGroup + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/method_delete.go b/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/method_delete.go new file mode 100644 index 00000000000..922b578a02d --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/method_delete.go @@ -0,0 +1,47 @@ +package applicationgroup + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ApplicationGroupClient) Delete(ctx context.Context, id ApplicationGroupId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/method_get.go b/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/method_get.go new file mode 100644 index 00000000000..5f689277e19 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/method_get.go @@ -0,0 +1,53 @@ +package applicationgroup + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *ApplicationGroup +} + +// Get ... +func (c ApplicationGroupClient) Get(ctx context.Context, id ApplicationGroupId) (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 ApplicationGroup + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/method_listbyresourcegroup.go b/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/method_listbyresourcegroup.go new file mode 100644 index 00000000000..80f65ad5955 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/method_listbyresourcegroup.go @@ -0,0 +1,147 @@ +package applicationgroup + +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 *[]ApplicationGroup +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []ApplicationGroup +} + +type ListByResourceGroupOperationOptions struct { + Filter *string + InitialSkip *int64 + IsDescending *bool + PageSize *int64 +} + +func DefaultListByResourceGroupOperationOptions() ListByResourceGroupOperationOptions { + return ListByResourceGroupOperationOptions{} +} + +func (o ListByResourceGroupOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByResourceGroupOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListByResourceGroupOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.InitialSkip != nil { + out.Append("initialSkip", fmt.Sprintf("%v", *o.InitialSkip)) + } + if o.IsDescending != nil { + out.Append("isDescending", fmt.Sprintf("%v", *o.IsDescending)) + } + if o.PageSize != nil { + out.Append("pageSize", fmt.Sprintf("%v", *o.PageSize)) + } + return &out +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c ApplicationGroupClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DesktopVirtualization/applicationGroups", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ApplicationGroup `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 ApplicationGroupClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, options, ApplicationGroupOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApplicationGroupClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions, predicate ApplicationGroupOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]ApplicationGroup, 0) + + resp, err := c.ListByResourceGroup(ctx, id, options) + 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/desktopvirtualization/2024-04-08-preview/applicationgroup/method_listbysubscription.go b/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/method_listbysubscription.go new file mode 100644 index 00000000000..50a6f418503 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/method_listbysubscription.go @@ -0,0 +1,135 @@ +package applicationgroup + +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 *[]ApplicationGroup +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []ApplicationGroup +} + +type ListBySubscriptionOperationOptions struct { + Filter *string +} + +func DefaultListBySubscriptionOperationOptions() ListBySubscriptionOperationOptions { + return ListBySubscriptionOperationOptions{} +} + +func (o ListBySubscriptionOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListBySubscriptionOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListBySubscriptionOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +type ListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySubscription ... +func (c ApplicationGroupClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DesktopVirtualization/applicationGroups", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ApplicationGroup `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 ApplicationGroupClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, options, ApplicationGroupOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApplicationGroupClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions, predicate ApplicationGroupOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]ApplicationGroup, 0) + + resp, err := c.ListBySubscription(ctx, id, options) + 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/desktopvirtualization/2024-04-08-preview/applicationgroup/method_update.go b/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/method_update.go new file mode 100644 index 00000000000..503845615c2 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/method_update.go @@ -0,0 +1,57 @@ +package applicationgroup + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApplicationGroup +} + +// Update ... +func (c ApplicationGroupClient) Update(ctx context.Context, id ApplicationGroupId, input ApplicationGroupPatch) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ApplicationGroup + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/model_applicationgroup.go b/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/model_applicationgroup.go new file mode 100644 index 00000000000..c8b71e5f22d --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/model_applicationgroup.go @@ -0,0 +1,25 @@ +package applicationgroup + +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 ApplicationGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + ManagedBy *string `json:"managedBy,omitempty"` + Name *string `json:"name,omitempty"` + Plan *Plan `json:"plan,omitempty"` + Properties ApplicationGroupProperties `json:"properties"` + Sku *Sku `json:"sku,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/model_applicationgrouppatch.go b/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/model_applicationgrouppatch.go new file mode 100644 index 00000000000..57a38dbe3c1 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/model_applicationgrouppatch.go @@ -0,0 +1,17 @@ +package applicationgroup + +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 ApplicationGroupPatch struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGroupPatchProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/model_applicationgrouppatchproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/model_applicationgrouppatchproperties.go new file mode 100644 index 00000000000..34cbc7129f0 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/model_applicationgrouppatchproperties.go @@ -0,0 +1,10 @@ +package applicationgroup + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGroupPatchProperties struct { + Description *string `json:"description,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ShowInFeed *bool `json:"showInFeed,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/model_applicationgroupproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/model_applicationgroupproperties.go new file mode 100644 index 00000000000..df4d14dd281 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/model_applicationgroupproperties.go @@ -0,0 +1,15 @@ +package applicationgroup + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGroupProperties struct { + ApplicationGroupType ApplicationGroupType `json:"applicationGroupType"` + CloudPcResource *bool `json:"cloudPcResource,omitempty"` + Description *string `json:"description,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HostPoolArmPath string `json:"hostPoolArmPath"` + ObjectId *string `json:"objectId,omitempty"` + ShowInFeed *bool `json:"showInFeed,omitempty"` + WorkspaceArmPath *string `json:"workspaceArmPath,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/model_plan.go b/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/model_plan.go new file mode 100644 index 00000000000..865073b6a3e --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/model_plan.go @@ -0,0 +1,12 @@ +package applicationgroup + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Plan struct { + Name string `json:"name"` + Product string `json:"product"` + PromotionCode *string `json:"promotionCode,omitempty"` + Publisher string `json:"publisher"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/model_sku.go b/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/model_sku.go new file mode 100644 index 00000000000..57066762740 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/model_sku.go @@ -0,0 +1,12 @@ +package applicationgroup + +// 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 *int64 `json:"capacity,omitempty"` + Family *string `json:"family,omitempty"` + Name string `json:"name"` + Size *string `json:"size,omitempty"` + Tier *SkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/predicates.go b/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/predicates.go new file mode 100644 index 00000000000..ee3f1f04fc3 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/predicates.go @@ -0,0 +1,47 @@ +package applicationgroup + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGroupOperationPredicate struct { + Etag *string + Id *string + Kind *string + Location *string + ManagedBy *string + Name *string + Type *string +} + +func (p ApplicationGroupOperationPredicate) Matches(input ApplicationGroup) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.ManagedBy != nil && (input.ManagedBy == nil || *p.ManagedBy != *input.ManagedBy) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/version.go b/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/version.go new file mode 100644 index 00000000000..af111e50b95 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup/version.go @@ -0,0 +1,10 @@ +package applicationgroup + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-08-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/applicationgroup/2024-04-08-preview" +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/client.go b/resource-manager/desktopvirtualization/2024-04-08-preview/client.go new file mode 100644 index 00000000000..c1b0507e61c --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/client.go @@ -0,0 +1,199 @@ +package v2024_04_08_preview + +// 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/desktopvirtualization/2024-04-08-preview/activesessionhostconfiguration" + "github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackage" + "github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/appattachpackageinfo" + "github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/application" + "github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/applicationgroup" + "github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/desktop" + "github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool" + "github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/msiximage" + "github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage" + "github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink" + "github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan" + "github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule" + "github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule" + "github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost" + "github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration" + "github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement" + "github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagements" + "github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/startmenuitem" + "github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/usersession" + "github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/workspace" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + ActiveSessionHostConfiguration *activesessionhostconfiguration.ActiveSessionHostConfigurationClient + AppAttachPackage *appattachpackage.AppAttachPackageClient + AppAttachPackageInfo *appattachpackageinfo.AppAttachPackageInfoClient + Application *application.ApplicationClient + ApplicationGroup *applicationgroup.ApplicationGroupClient + Desktop *desktop.DesktopClient + HostPool *hostpool.HostPoolClient + MSIXPackage *msixpackage.MSIXPackageClient + MsixImage *msiximage.MsixImageClient + PrivateLink *privatelink.PrivateLinkClient + ScalingPlan *scalingplan.ScalingPlanClient + ScalingPlanPersonalSchedule *scalingplanpersonalschedule.ScalingPlanPersonalScheduleClient + ScalingPlanPooledSchedule *scalingplanpooledschedule.ScalingPlanPooledScheduleClient + SessionHost *sessionhost.SessionHostClient + SessionHostConfiguration *sessionhostconfiguration.SessionHostConfigurationClient + SessionHostManagement *sessionhostmanagement.SessionHostManagementClient + SessionHostManagements *sessionhostmanagements.SessionHostManagementsClient + StartMenuItem *startmenuitem.StartMenuItemClient + UserSession *usersession.UserSessionClient + Workspace *workspace.WorkspaceClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + activeSessionHostConfigurationClient, err := activesessionhostconfiguration.NewActiveSessionHostConfigurationClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ActiveSessionHostConfiguration client: %+v", err) + } + configureFunc(activeSessionHostConfigurationClient.Client) + + appAttachPackageClient, err := appattachpackage.NewAppAttachPackageClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building AppAttachPackage client: %+v", err) + } + configureFunc(appAttachPackageClient.Client) + + appAttachPackageInfoClient, err := appattachpackageinfo.NewAppAttachPackageInfoClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building AppAttachPackageInfo client: %+v", err) + } + configureFunc(appAttachPackageInfoClient.Client) + + applicationClient, err := application.NewApplicationClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Application client: %+v", err) + } + configureFunc(applicationClient.Client) + + applicationGroupClient, err := applicationgroup.NewApplicationGroupClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ApplicationGroup client: %+v", err) + } + configureFunc(applicationGroupClient.Client) + + desktopClient, err := desktop.NewDesktopClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Desktop client: %+v", err) + } + configureFunc(desktopClient.Client) + + hostPoolClient, err := hostpool.NewHostPoolClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building HostPool client: %+v", err) + } + configureFunc(hostPoolClient.Client) + + mSIXPackageClient, err := msixpackage.NewMSIXPackageClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building MSIXPackage client: %+v", err) + } + configureFunc(mSIXPackageClient.Client) + + msixImageClient, err := msiximage.NewMsixImageClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building MsixImage client: %+v", err) + } + configureFunc(msixImageClient.Client) + + privateLinkClient, err := privatelink.NewPrivateLinkClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building PrivateLink client: %+v", err) + } + configureFunc(privateLinkClient.Client) + + scalingPlanClient, err := scalingplan.NewScalingPlanClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ScalingPlan client: %+v", err) + } + configureFunc(scalingPlanClient.Client) + + scalingPlanPersonalScheduleClient, err := scalingplanpersonalschedule.NewScalingPlanPersonalScheduleClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ScalingPlanPersonalSchedule client: %+v", err) + } + configureFunc(scalingPlanPersonalScheduleClient.Client) + + scalingPlanPooledScheduleClient, err := scalingplanpooledschedule.NewScalingPlanPooledScheduleClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ScalingPlanPooledSchedule client: %+v", err) + } + configureFunc(scalingPlanPooledScheduleClient.Client) + + sessionHostClient, err := sessionhost.NewSessionHostClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building SessionHost client: %+v", err) + } + configureFunc(sessionHostClient.Client) + + sessionHostConfigurationClient, err := sessionhostconfiguration.NewSessionHostConfigurationClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building SessionHostConfiguration client: %+v", err) + } + configureFunc(sessionHostConfigurationClient.Client) + + sessionHostManagementClient, err := sessionhostmanagement.NewSessionHostManagementClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building SessionHostManagement client: %+v", err) + } + configureFunc(sessionHostManagementClient.Client) + + sessionHostManagementsClient, err := sessionhostmanagements.NewSessionHostManagementsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building SessionHostManagements client: %+v", err) + } + configureFunc(sessionHostManagementsClient.Client) + + startMenuItemClient, err := startmenuitem.NewStartMenuItemClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building StartMenuItem client: %+v", err) + } + configureFunc(startMenuItemClient.Client) + + userSessionClient, err := usersession.NewUserSessionClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building UserSession client: %+v", err) + } + configureFunc(userSessionClient.Client) + + workspaceClient, err := workspace.NewWorkspaceClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Workspace client: %+v", err) + } + configureFunc(workspaceClient.Client) + + return &Client{ + ActiveSessionHostConfiguration: activeSessionHostConfigurationClient, + AppAttachPackage: appAttachPackageClient, + AppAttachPackageInfo: appAttachPackageInfoClient, + Application: applicationClient, + ApplicationGroup: applicationGroupClient, + Desktop: desktopClient, + HostPool: hostPoolClient, + MSIXPackage: mSIXPackageClient, + MsixImage: msixImageClient, + PrivateLink: privateLinkClient, + ScalingPlan: scalingPlanClient, + ScalingPlanPersonalSchedule: scalingPlanPersonalScheduleClient, + ScalingPlanPooledSchedule: scalingPlanPooledScheduleClient, + SessionHost: sessionHostClient, + SessionHostConfiguration: sessionHostConfigurationClient, + SessionHostManagement: sessionHostManagementClient, + SessionHostManagements: sessionHostManagementsClient, + StartMenuItem: startMenuItemClient, + UserSession: userSessionClient, + Workspace: workspaceClient, + }, nil +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/desktop/README.md b/resource-manager/desktopvirtualization/2024-04-08-preview/desktop/README.md new file mode 100644 index 00000000000..fa7a0903338 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/desktop/README.md @@ -0,0 +1,74 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/desktop` Documentation + +The `desktop` SDK allows for interaction with Azure Resource Manager `desktopvirtualization` (API Version `2024-04-08-preview`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/desktop" +``` + + +### Client Initialization + +```go +client := desktop.NewDesktopClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DesktopClient.Get` + +```go +ctx := context.TODO() +id := desktop.NewDesktopID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGroupName", "desktopName") + +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: `DesktopClient.List` + +```go +ctx := context.TODO() +id := desktop.NewApplicationGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGroupName") + +// alternatively `client.List(ctx, id, desktop.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, desktop.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DesktopClient.Update` + +```go +ctx := context.TODO() +id := desktop.NewDesktopID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGroupName", "desktopName") + +payload := desktop.DesktopPatch{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/desktop/client.go b/resource-manager/desktopvirtualization/2024-04-08-preview/desktop/client.go new file mode 100644 index 00000000000..fccabe50eda --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/desktop/client.go @@ -0,0 +1,26 @@ +package desktop + +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 DesktopClient struct { + Client *resourcemanager.Client +} + +func NewDesktopClientWithBaseURI(sdkApi sdkEnv.Api) (*DesktopClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "desktop", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DesktopClient: %+v", err) + } + + return &DesktopClient{ + Client: client, + }, nil +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/desktop/id_applicationgroup.go b/resource-manager/desktopvirtualization/2024-04-08-preview/desktop/id_applicationgroup.go new file mode 100644 index 00000000000..b3fd93141c9 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/desktop/id_applicationgroup.go @@ -0,0 +1,130 @@ +package desktop + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ApplicationGroupId{}) +} + +var _ resourceids.ResourceId = &ApplicationGroupId{} + +// ApplicationGroupId is a struct representing the Resource ID for a Application Group +type ApplicationGroupId struct { + SubscriptionId string + ResourceGroupName string + ApplicationGroupName string +} + +// NewApplicationGroupID returns a new ApplicationGroupId struct +func NewApplicationGroupID(subscriptionId string, resourceGroupName string, applicationGroupName string) ApplicationGroupId { + return ApplicationGroupId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ApplicationGroupName: applicationGroupName, + } +} + +// ParseApplicationGroupID parses 'input' into a ApplicationGroupId +func ParseApplicationGroupID(input string) (*ApplicationGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&ApplicationGroupId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ApplicationGroupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseApplicationGroupIDInsensitively parses 'input' case-insensitively into a ApplicationGroupId +// note: this method should only be used for API response data and not user input +func ParseApplicationGroupIDInsensitively(input string) (*ApplicationGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&ApplicationGroupId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ApplicationGroupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ApplicationGroupId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ApplicationGroupName, ok = input.Parsed["applicationGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "applicationGroupName", input) + } + + return nil +} + +// ValidateApplicationGroupID checks that 'input' can be parsed as a Application Group ID +func ValidateApplicationGroupID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseApplicationGroupID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Application Group ID +func (id ApplicationGroupId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DesktopVirtualization/applicationGroups/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ApplicationGroupName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Application Group ID +func (id ApplicationGroupId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDesktopVirtualization", "Microsoft.DesktopVirtualization", "Microsoft.DesktopVirtualization"), + resourceids.StaticSegment("staticApplicationGroups", "applicationGroups", "applicationGroups"), + resourceids.UserSpecifiedSegment("applicationGroupName", "applicationGroupName"), + } +} + +// String returns a human-readable description of this Application Group ID +func (id ApplicationGroupId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Application Group Name: %q", id.ApplicationGroupName), + } + return fmt.Sprintf("Application Group (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/desktop/id_applicationgroup_test.go b/resource-manager/desktopvirtualization/2024-04-08-preview/desktop/id_applicationgroup_test.go new file mode 100644 index 00000000000..8f0f1bb4ea1 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/desktop/id_applicationgroup_test.go @@ -0,0 +1,282 @@ +package desktop + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ApplicationGroupId{} + +func TestNewApplicationGroupID(t *testing.T) { + id := NewApplicationGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGroupName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ApplicationGroupName != "applicationGroupName" { + t.Fatalf("Expected %q but got %q for Segment 'ApplicationGroupName'", id.ApplicationGroupName, "applicationGroupName") + } +} + +func TestFormatApplicationGroupID(t *testing.T) { + actual := NewApplicationGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGroupName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups/applicationGroupName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseApplicationGroupID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ApplicationGroupId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups/applicationGroupName", + Expected: &ApplicationGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ApplicationGroupName: "applicationGroupName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups/applicationGroupName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseApplicationGroupID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ApplicationGroupName != v.Expected.ApplicationGroupName { + t.Fatalf("Expected %q but got %q for ApplicationGroupName", v.Expected.ApplicationGroupName, actual.ApplicationGroupName) + } + + } +} + +func TestParseApplicationGroupIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ApplicationGroupId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/aPpLiCaTiOnGrOuPs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups/applicationGroupName", + Expected: &ApplicationGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ApplicationGroupName: "applicationGroupName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups/applicationGroupName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/aPpLiCaTiOnGrOuPs/aPpLiCaTiOnGrOuPnAmE", + Expected: &ApplicationGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ApplicationGroupName: "aPpLiCaTiOnGrOuPnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/aPpLiCaTiOnGrOuPs/aPpLiCaTiOnGrOuPnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseApplicationGroupIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ApplicationGroupName != v.Expected.ApplicationGroupName { + t.Fatalf("Expected %q but got %q for ApplicationGroupName", v.Expected.ApplicationGroupName, actual.ApplicationGroupName) + } + + } +} + +func TestSegmentsForApplicationGroupId(t *testing.T) { + segments := ApplicationGroupId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ApplicationGroupId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/desktop/id_desktop.go b/resource-manager/desktopvirtualization/2024-04-08-preview/desktop/id_desktop.go new file mode 100644 index 00000000000..f0dfc00f4cc --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/desktop/id_desktop.go @@ -0,0 +1,139 @@ +package desktop + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&DesktopId{}) +} + +var _ resourceids.ResourceId = &DesktopId{} + +// DesktopId is a struct representing the Resource ID for a Desktop +type DesktopId struct { + SubscriptionId string + ResourceGroupName string + ApplicationGroupName string + DesktopName string +} + +// NewDesktopID returns a new DesktopId struct +func NewDesktopID(subscriptionId string, resourceGroupName string, applicationGroupName string, desktopName string) DesktopId { + return DesktopId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ApplicationGroupName: applicationGroupName, + DesktopName: desktopName, + } +} + +// ParseDesktopID parses 'input' into a DesktopId +func ParseDesktopID(input string) (*DesktopId, error) { + parser := resourceids.NewParserFromResourceIdType(&DesktopId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DesktopId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDesktopIDInsensitively parses 'input' case-insensitively into a DesktopId +// note: this method should only be used for API response data and not user input +func ParseDesktopIDInsensitively(input string) (*DesktopId, error) { + parser := resourceids.NewParserFromResourceIdType(&DesktopId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DesktopId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DesktopId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ApplicationGroupName, ok = input.Parsed["applicationGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "applicationGroupName", input) + } + + if id.DesktopName, ok = input.Parsed["desktopName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "desktopName", input) + } + + return nil +} + +// ValidateDesktopID checks that 'input' can be parsed as a Desktop ID +func ValidateDesktopID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseDesktopID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Desktop ID +func (id DesktopId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DesktopVirtualization/applicationGroups/%s/desktops/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ApplicationGroupName, id.DesktopName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Desktop ID +func (id DesktopId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDesktopVirtualization", "Microsoft.DesktopVirtualization", "Microsoft.DesktopVirtualization"), + resourceids.StaticSegment("staticApplicationGroups", "applicationGroups", "applicationGroups"), + resourceids.UserSpecifiedSegment("applicationGroupName", "applicationGroupName"), + resourceids.StaticSegment("staticDesktops", "desktops", "desktops"), + resourceids.UserSpecifiedSegment("desktopName", "desktopName"), + } +} + +// String returns a human-readable description of this Desktop ID +func (id DesktopId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Application Group Name: %q", id.ApplicationGroupName), + fmt.Sprintf("Desktop Name: %q", id.DesktopName), + } + return fmt.Sprintf("Desktop (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/desktop/id_desktop_test.go b/resource-manager/desktopvirtualization/2024-04-08-preview/desktop/id_desktop_test.go new file mode 100644 index 00000000000..502a905a8a1 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/desktop/id_desktop_test.go @@ -0,0 +1,327 @@ +package desktop + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &DesktopId{} + +func TestNewDesktopID(t *testing.T) { + id := NewDesktopID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGroupName", "desktopName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ApplicationGroupName != "applicationGroupName" { + t.Fatalf("Expected %q but got %q for Segment 'ApplicationGroupName'", id.ApplicationGroupName, "applicationGroupName") + } + + if id.DesktopName != "desktopName" { + t.Fatalf("Expected %q but got %q for Segment 'DesktopName'", id.DesktopName, "desktopName") + } +} + +func TestFormatDesktopID(t *testing.T) { + actual := NewDesktopID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGroupName", "desktopName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups/applicationGroupName/desktops/desktopName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDesktopID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DesktopId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups/applicationGroupName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups/applicationGroupName/desktops", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups/applicationGroupName/desktops/desktopName", + Expected: &DesktopId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ApplicationGroupName: "applicationGroupName", + DesktopName: "desktopName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups/applicationGroupName/desktops/desktopName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDesktopID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ApplicationGroupName != v.Expected.ApplicationGroupName { + t.Fatalf("Expected %q but got %q for ApplicationGroupName", v.Expected.ApplicationGroupName, actual.ApplicationGroupName) + } + + if actual.DesktopName != v.Expected.DesktopName { + t.Fatalf("Expected %q but got %q for DesktopName", v.Expected.DesktopName, actual.DesktopName) + } + + } +} + +func TestParseDesktopIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DesktopId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/aPpLiCaTiOnGrOuPs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups/applicationGroupName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/aPpLiCaTiOnGrOuPs/aPpLiCaTiOnGrOuPnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups/applicationGroupName/desktops", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/aPpLiCaTiOnGrOuPs/aPpLiCaTiOnGrOuPnAmE/dEsKtOpS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups/applicationGroupName/desktops/desktopName", + Expected: &DesktopId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ApplicationGroupName: "applicationGroupName", + DesktopName: "desktopName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups/applicationGroupName/desktops/desktopName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/aPpLiCaTiOnGrOuPs/aPpLiCaTiOnGrOuPnAmE/dEsKtOpS/dEsKtOpNaMe", + Expected: &DesktopId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ApplicationGroupName: "aPpLiCaTiOnGrOuPnAmE", + DesktopName: "dEsKtOpNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/aPpLiCaTiOnGrOuPs/aPpLiCaTiOnGrOuPnAmE/dEsKtOpS/dEsKtOpNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDesktopIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ApplicationGroupName != v.Expected.ApplicationGroupName { + t.Fatalf("Expected %q but got %q for ApplicationGroupName", v.Expected.ApplicationGroupName, actual.ApplicationGroupName) + } + + if actual.DesktopName != v.Expected.DesktopName { + t.Fatalf("Expected %q but got %q for DesktopName", v.Expected.DesktopName, actual.DesktopName) + } + + } +} + +func TestSegmentsForDesktopId(t *testing.T) { + segments := DesktopId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DesktopId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/desktop/method_get.go b/resource-manager/desktopvirtualization/2024-04-08-preview/desktop/method_get.go new file mode 100644 index 00000000000..63a8032f34d --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/desktop/method_get.go @@ -0,0 +1,53 @@ +package desktop + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *Desktop +} + +// Get ... +func (c DesktopClient) Get(ctx context.Context, id DesktopId) (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 Desktop + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/desktop/method_list.go b/resource-manager/desktopvirtualization/2024-04-08-preview/desktop/method_list.go new file mode 100644 index 00000000000..03d313a4854 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/desktop/method_list.go @@ -0,0 +1,142 @@ +package desktop + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Desktop +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Desktop +} + +type ListOperationOptions struct { + InitialSkip *int64 + IsDescending *bool + PageSize *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.InitialSkip != nil { + out.Append("initialSkip", fmt.Sprintf("%v", *o.InitialSkip)) + } + if o.IsDescending != nil { + out.Append("isDescending", fmt.Sprintf("%v", *o.IsDescending)) + } + if o.PageSize != nil { + out.Append("pageSize", fmt.Sprintf("%v", *o.PageSize)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c DesktopClient) List(ctx context.Context, id ApplicationGroupId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/desktops", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Desktop `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c DesktopClient) ListComplete(ctx context.Context, id ApplicationGroupId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, DesktopOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DesktopClient) ListCompleteMatchingPredicate(ctx context.Context, id ApplicationGroupId, options ListOperationOptions, predicate DesktopOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Desktop, 0) + + resp, err := c.List(ctx, id, options) + 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 = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/desktop/method_update.go b/resource-manager/desktopvirtualization/2024-04-08-preview/desktop/method_update.go new file mode 100644 index 00000000000..5d797f083b7 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/desktop/method_update.go @@ -0,0 +1,57 @@ +package desktop + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Desktop +} + +// Update ... +func (c DesktopClient) Update(ctx context.Context, id DesktopId, input DesktopPatch) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Desktop + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/desktop/model_desktop.go b/resource-manager/desktopvirtualization/2024-04-08-preview/desktop/model_desktop.go new file mode 100644 index 00000000000..6d41ecc215e --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/desktop/model_desktop.go @@ -0,0 +1,16 @@ +package desktop + +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 Desktop struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DesktopProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/desktop/model_desktoppatch.go b/resource-manager/desktopvirtualization/2024-04-08-preview/desktop/model_desktoppatch.go new file mode 100644 index 00000000000..1d7d1672159 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/desktop/model_desktoppatch.go @@ -0,0 +1,9 @@ +package desktop + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DesktopPatch struct { + Properties *DesktopPatchProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/desktop/model_desktoppatchproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/desktop/model_desktoppatchproperties.go new file mode 100644 index 00000000000..40b1a4577e1 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/desktop/model_desktoppatchproperties.go @@ -0,0 +1,9 @@ +package desktop + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DesktopPatchProperties struct { + Description *string `json:"description,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/desktop/model_desktopproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/desktop/model_desktopproperties.go new file mode 100644 index 00000000000..2d961ead46c --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/desktop/model_desktopproperties.go @@ -0,0 +1,12 @@ +package desktop + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DesktopProperties struct { + Description *string `json:"description,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + IconContent *string `json:"iconContent,omitempty"` + IconHash *string `json:"iconHash,omitempty"` + ObjectId *string `json:"objectId,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/desktop/predicates.go b/resource-manager/desktopvirtualization/2024-04-08-preview/desktop/predicates.go new file mode 100644 index 00000000000..7d69c2ba266 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/desktop/predicates.go @@ -0,0 +1,27 @@ +package desktop + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DesktopOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p DesktopOperationPredicate) Matches(input Desktop) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/desktop/version.go b/resource-manager/desktopvirtualization/2024-04-08-preview/desktop/version.go new file mode 100644 index 00000000000..d0326ae69c9 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/desktop/version.go @@ -0,0 +1,10 @@ +package desktop + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-08-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/desktop/2024-04-08-preview" +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/README.md b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/README.md new file mode 100644 index 00000000000..65a427654b7 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/README.md @@ -0,0 +1,162 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool` Documentation + +The `hostpool` SDK allows for interaction with Azure Resource Manager `desktopvirtualization` (API Version `2024-04-08-preview`). + +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/desktopvirtualization/2024-04-08-preview/hostpool" +``` + + +### Client Initialization + +```go +client := hostpool.NewHostPoolClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `HostPoolClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := hostpool.NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName") + +payload := hostpool.HostPool{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `HostPoolClient.Delete` + +```go +ctx := context.TODO() +id := hostpool.NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName") + +read, err := client.Delete(ctx, id, hostpool.DefaultDeleteOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `HostPoolClient.Get` + +```go +ctx := context.TODO() +id := hostpool.NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName") + +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: `HostPoolClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id, hostpool.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, hostpool.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `HostPoolClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id, hostpool.DefaultListByResourceGroupOperationOptions())` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id, hostpool.DefaultListByResourceGroupOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `HostPoolClient.ListRegistrationTokens` + +```go +ctx := context.TODO() +id := hostpool.NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName") + +// alternatively `client.ListRegistrationTokens(ctx, id)` can be used to do batched pagination +items, err := client.ListRegistrationTokensComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `HostPoolClient.RetrieveRegistrationToken` + +```go +ctx := context.TODO() +id := hostpool.NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName") + +read, err := client.RetrieveRegistrationToken(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `HostPoolClient.Update` + +```go +ctx := context.TODO() +id := hostpool.NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName") + +payload := hostpool.HostPoolPatch{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/client.go b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/client.go new file mode 100644 index 00000000000..e052d6173f9 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/client.go @@ -0,0 +1,26 @@ +package hostpool + +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 HostPoolClient struct { + Client *resourcemanager.Client +} + +func NewHostPoolClientWithBaseURI(sdkApi sdkEnv.Api) (*HostPoolClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "hostpool", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating HostPoolClient: %+v", err) + } + + return &HostPoolClient{ + Client: client, + }, nil +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/constants.go b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/constants.go new file mode 100644 index 00000000000..aa43ad36647 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/constants.go @@ -0,0 +1,776 @@ +package hostpool + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DayOfWeek string + +const ( + DayOfWeekFriday DayOfWeek = "Friday" + DayOfWeekMonday DayOfWeek = "Monday" + DayOfWeekSaturday DayOfWeek = "Saturday" + DayOfWeekSunday DayOfWeek = "Sunday" + DayOfWeekThursday DayOfWeek = "Thursday" + DayOfWeekTuesday DayOfWeek = "Tuesday" + DayOfWeekWednesday DayOfWeek = "Wednesday" +) + +func PossibleValuesForDayOfWeek() []string { + return []string{ + string(DayOfWeekFriday), + string(DayOfWeekMonday), + string(DayOfWeekSaturday), + string(DayOfWeekSunday), + string(DayOfWeekThursday), + string(DayOfWeekTuesday), + string(DayOfWeekWednesday), + } +} + +func (s *DayOfWeek) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDayOfWeek(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDayOfWeek(input string) (*DayOfWeek, error) { + vals := map[string]DayOfWeek{ + "friday": DayOfWeekFriday, + "monday": DayOfWeekMonday, + "saturday": DayOfWeekSaturday, + "sunday": DayOfWeekSunday, + "thursday": DayOfWeekThursday, + "tuesday": DayOfWeekTuesday, + "wednesday": DayOfWeekWednesday, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DayOfWeek(input) + return &out, nil +} + +type DirectUDP string + +const ( + DirectUDPDefault DirectUDP = "Default" + DirectUDPDisabled DirectUDP = "Disabled" + DirectUDPEnabled DirectUDP = "Enabled" +) + +func PossibleValuesForDirectUDP() []string { + return []string{ + string(DirectUDPDefault), + string(DirectUDPDisabled), + string(DirectUDPEnabled), + } +} + +func (s *DirectUDP) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDirectUDP(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDirectUDP(input string) (*DirectUDP, error) { + vals := map[string]DirectUDP{ + "default": DirectUDPDefault, + "disabled": DirectUDPDisabled, + "enabled": DirectUDPEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DirectUDP(input) + return &out, nil +} + +type HostPoolType string + +const ( + HostPoolTypeBYODesktop HostPoolType = "BYODesktop" + HostPoolTypePersonal HostPoolType = "Personal" + HostPoolTypePooled HostPoolType = "Pooled" +) + +func PossibleValuesForHostPoolType() []string { + return []string{ + string(HostPoolTypeBYODesktop), + string(HostPoolTypePersonal), + string(HostPoolTypePooled), + } +} + +func (s *HostPoolType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHostPoolType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHostPoolType(input string) (*HostPoolType, error) { + vals := map[string]HostPoolType{ + "byodesktop": HostPoolTypeBYODesktop, + "personal": HostPoolTypePersonal, + "pooled": HostPoolTypePooled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HostPoolType(input) + return &out, nil +} + +type HostpoolPublicNetworkAccess string + +const ( + HostpoolPublicNetworkAccessDisabled HostpoolPublicNetworkAccess = "Disabled" + HostpoolPublicNetworkAccessEnabled HostpoolPublicNetworkAccess = "Enabled" + HostpoolPublicNetworkAccessEnabledForClientsOnly HostpoolPublicNetworkAccess = "EnabledForClientsOnly" + HostpoolPublicNetworkAccessEnabledForSessionHostsOnly HostpoolPublicNetworkAccess = "EnabledForSessionHostsOnly" +) + +func PossibleValuesForHostpoolPublicNetworkAccess() []string { + return []string{ + string(HostpoolPublicNetworkAccessDisabled), + string(HostpoolPublicNetworkAccessEnabled), + string(HostpoolPublicNetworkAccessEnabledForClientsOnly), + string(HostpoolPublicNetworkAccessEnabledForSessionHostsOnly), + } +} + +func (s *HostpoolPublicNetworkAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHostpoolPublicNetworkAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHostpoolPublicNetworkAccess(input string) (*HostpoolPublicNetworkAccess, error) { + vals := map[string]HostpoolPublicNetworkAccess{ + "disabled": HostpoolPublicNetworkAccessDisabled, + "enabled": HostpoolPublicNetworkAccessEnabled, + "enabledforclientsonly": HostpoolPublicNetworkAccessEnabledForClientsOnly, + "enabledforsessionhostsonly": HostpoolPublicNetworkAccessEnabledForSessionHostsOnly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HostpoolPublicNetworkAccess(input) + return &out, nil +} + +type LoadBalancerType string + +const ( + LoadBalancerTypeBreadthFirst LoadBalancerType = "BreadthFirst" + LoadBalancerTypeDepthFirst LoadBalancerType = "DepthFirst" + LoadBalancerTypeMultiplePersistent LoadBalancerType = "MultiplePersistent" + LoadBalancerTypePersistent LoadBalancerType = "Persistent" +) + +func PossibleValuesForLoadBalancerType() []string { + return []string{ + string(LoadBalancerTypeBreadthFirst), + string(LoadBalancerTypeDepthFirst), + string(LoadBalancerTypeMultiplePersistent), + string(LoadBalancerTypePersistent), + } +} + +func (s *LoadBalancerType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLoadBalancerType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLoadBalancerType(input string) (*LoadBalancerType, error) { + vals := map[string]LoadBalancerType{ + "breadthfirst": LoadBalancerTypeBreadthFirst, + "depthfirst": LoadBalancerTypeDepthFirst, + "multiplepersistent": LoadBalancerTypeMultiplePersistent, + "persistent": LoadBalancerTypePersistent, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LoadBalancerType(input) + return &out, nil +} + +type ManagedPrivateUDP string + +const ( + ManagedPrivateUDPDefault ManagedPrivateUDP = "Default" + ManagedPrivateUDPDisabled ManagedPrivateUDP = "Disabled" + ManagedPrivateUDPEnabled ManagedPrivateUDP = "Enabled" +) + +func PossibleValuesForManagedPrivateUDP() []string { + return []string{ + string(ManagedPrivateUDPDefault), + string(ManagedPrivateUDPDisabled), + string(ManagedPrivateUDPEnabled), + } +} + +func (s *ManagedPrivateUDP) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedPrivateUDP(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseManagedPrivateUDP(input string) (*ManagedPrivateUDP, error) { + vals := map[string]ManagedPrivateUDP{ + "default": ManagedPrivateUDPDefault, + "disabled": ManagedPrivateUDPDisabled, + "enabled": ManagedPrivateUDPEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedPrivateUDP(input) + return &out, nil +} + +type ManagementType string + +const ( + ManagementTypeAutomated ManagementType = "Automated" + ManagementTypeStandard ManagementType = "Standard" +) + +func PossibleValuesForManagementType() []string { + return []string{ + string(ManagementTypeAutomated), + string(ManagementTypeStandard), + } +} + +func (s *ManagementType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagementType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseManagementType(input string) (*ManagementType, error) { + vals := map[string]ManagementType{ + "automated": ManagementTypeAutomated, + "standard": ManagementTypeStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagementType(input) + return &out, nil +} + +type PersonalDesktopAssignmentType string + +const ( + PersonalDesktopAssignmentTypeAutomatic PersonalDesktopAssignmentType = "Automatic" + PersonalDesktopAssignmentTypeDirect PersonalDesktopAssignmentType = "Direct" +) + +func PossibleValuesForPersonalDesktopAssignmentType() []string { + return []string{ + string(PersonalDesktopAssignmentTypeAutomatic), + string(PersonalDesktopAssignmentTypeDirect), + } +} + +func (s *PersonalDesktopAssignmentType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePersonalDesktopAssignmentType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePersonalDesktopAssignmentType(input string) (*PersonalDesktopAssignmentType, error) { + vals := map[string]PersonalDesktopAssignmentType{ + "automatic": PersonalDesktopAssignmentTypeAutomatic, + "direct": PersonalDesktopAssignmentTypeDirect, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PersonalDesktopAssignmentType(input) + return &out, nil +} + +type PreferredAppGroupType string + +const ( + PreferredAppGroupTypeDesktop PreferredAppGroupType = "Desktop" + PreferredAppGroupTypeNone PreferredAppGroupType = "None" + PreferredAppGroupTypeRailApplications PreferredAppGroupType = "RailApplications" +) + +func PossibleValuesForPreferredAppGroupType() []string { + return []string{ + string(PreferredAppGroupTypeDesktop), + string(PreferredAppGroupTypeNone), + string(PreferredAppGroupTypeRailApplications), + } +} + +func (s *PreferredAppGroupType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePreferredAppGroupType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePreferredAppGroupType(input string) (*PreferredAppGroupType, error) { + vals := map[string]PreferredAppGroupType{ + "desktop": PreferredAppGroupTypeDesktop, + "none": PreferredAppGroupTypeNone, + "railapplications": PreferredAppGroupTypeRailApplications, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PreferredAppGroupType(input) + return &out, nil +} + +type PrivateEndpointConnectionProvisioningState string + +const ( + PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" + PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" + PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" + PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" +) + +func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { + return []string{ + string(PrivateEndpointConnectionProvisioningStateCreating), + string(PrivateEndpointConnectionProvisioningStateDeleting), + string(PrivateEndpointConnectionProvisioningStateFailed), + string(PrivateEndpointConnectionProvisioningStateSucceeded), + } +} + +func (s *PrivateEndpointConnectionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointConnectionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { + vals := map[string]PrivateEndpointConnectionProvisioningState{ + "creating": PrivateEndpointConnectionProvisioningStateCreating, + "deleting": PrivateEndpointConnectionProvisioningStateDeleting, + "failed": PrivateEndpointConnectionProvisioningStateFailed, + "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointConnectionProvisioningState(input) + return &out, nil +} + +type PrivateEndpointServiceConnectionStatus string + +const ( + PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" + PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" + PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" +) + +func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { + return []string{ + string(PrivateEndpointServiceConnectionStatusApproved), + string(PrivateEndpointServiceConnectionStatusPending), + string(PrivateEndpointServiceConnectionStatusRejected), + } +} + +func (s *PrivateEndpointServiceConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointServiceConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { + vals := map[string]PrivateEndpointServiceConnectionStatus{ + "approved": PrivateEndpointServiceConnectionStatusApproved, + "pending": PrivateEndpointServiceConnectionStatusPending, + "rejected": PrivateEndpointServiceConnectionStatusRejected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointServiceConnectionStatus(input) + return &out, nil +} + +type PublicUDP string + +const ( + PublicUDPDefault PublicUDP = "Default" + PublicUDPDisabled PublicUDP = "Disabled" + PublicUDPEnabled PublicUDP = "Enabled" +) + +func PossibleValuesForPublicUDP() []string { + return []string{ + string(PublicUDPDefault), + string(PublicUDPDisabled), + string(PublicUDPEnabled), + } +} + +func (s *PublicUDP) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicUDP(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicUDP(input string) (*PublicUDP, error) { + vals := map[string]PublicUDP{ + "default": PublicUDPDefault, + "disabled": PublicUDPDisabled, + "enabled": PublicUDPEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicUDP(input) + return &out, nil +} + +type RegistrationTokenOperation string + +const ( + RegistrationTokenOperationDelete RegistrationTokenOperation = "Delete" + RegistrationTokenOperationNone RegistrationTokenOperation = "None" + RegistrationTokenOperationUpdate RegistrationTokenOperation = "Update" +) + +func PossibleValuesForRegistrationTokenOperation() []string { + return []string{ + string(RegistrationTokenOperationDelete), + string(RegistrationTokenOperationNone), + string(RegistrationTokenOperationUpdate), + } +} + +func (s *RegistrationTokenOperation) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRegistrationTokenOperation(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRegistrationTokenOperation(input string) (*RegistrationTokenOperation, error) { + vals := map[string]RegistrationTokenOperation{ + "delete": RegistrationTokenOperationDelete, + "none": RegistrationTokenOperationNone, + "update": RegistrationTokenOperationUpdate, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RegistrationTokenOperation(input) + return &out, nil +} + +type RelayUDP string + +const ( + RelayUDPDefault RelayUDP = "Default" + RelayUDPDisabled RelayUDP = "Disabled" + RelayUDPEnabled RelayUDP = "Enabled" +) + +func PossibleValuesForRelayUDP() []string { + return []string{ + string(RelayUDPDefault), + string(RelayUDPDisabled), + string(RelayUDPEnabled), + } +} + +func (s *RelayUDP) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRelayUDP(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRelayUDP(input string) (*RelayUDP, error) { + vals := map[string]RelayUDP{ + "default": RelayUDPDefault, + "disabled": RelayUDPDisabled, + "enabled": RelayUDPEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RelayUDP(input) + return &out, nil +} + +type SSOSecretType string + +const ( + SSOSecretTypeCertificate SSOSecretType = "Certificate" + SSOSecretTypeCertificateInKeyVault SSOSecretType = "CertificateInKeyVault" + SSOSecretTypeSharedKey SSOSecretType = "SharedKey" + SSOSecretTypeSharedKeyInKeyVault SSOSecretType = "SharedKeyInKeyVault" +) + +func PossibleValuesForSSOSecretType() []string { + return []string{ + string(SSOSecretTypeCertificate), + string(SSOSecretTypeCertificateInKeyVault), + string(SSOSecretTypeSharedKey), + string(SSOSecretTypeSharedKeyInKeyVault), + } +} + +func (s *SSOSecretType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSSOSecretType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSSOSecretType(input string) (*SSOSecretType, error) { + vals := map[string]SSOSecretType{ + "certificate": SSOSecretTypeCertificate, + "certificateinkeyvault": SSOSecretTypeCertificateInKeyVault, + "sharedkey": SSOSecretTypeSharedKey, + "sharedkeyinkeyvault": SSOSecretTypeSharedKeyInKeyVault, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SSOSecretType(input) + return &out, nil +} + +type SessionHostComponentUpdateType string + +const ( + SessionHostComponentUpdateTypeDefault SessionHostComponentUpdateType = "Default" + SessionHostComponentUpdateTypeScheduled SessionHostComponentUpdateType = "Scheduled" +) + +func PossibleValuesForSessionHostComponentUpdateType() []string { + return []string{ + string(SessionHostComponentUpdateTypeDefault), + string(SessionHostComponentUpdateTypeScheduled), + } +} + +func (s *SessionHostComponentUpdateType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSessionHostComponentUpdateType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSessionHostComponentUpdateType(input string) (*SessionHostComponentUpdateType, error) { + vals := map[string]SessionHostComponentUpdateType{ + "default": SessionHostComponentUpdateTypeDefault, + "scheduled": SessionHostComponentUpdateTypeScheduled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SessionHostComponentUpdateType(input) + return &out, nil +} + +type SkuTier string + +const ( + SkuTierBasic SkuTier = "Basic" + SkuTierFree SkuTier = "Free" + SkuTierPremium SkuTier = "Premium" + SkuTierStandard SkuTier = "Standard" +) + +func PossibleValuesForSkuTier() []string { + return []string{ + string(SkuTierBasic), + string(SkuTierFree), + string(SkuTierPremium), + string(SkuTierStandard), + } +} + +func (s *SkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSkuTier(input string) (*SkuTier, error) { + vals := map[string]SkuTier{ + "basic": SkuTierBasic, + "free": SkuTierFree, + "premium": SkuTierPremium, + "standard": SkuTierStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SkuTier(input) + return &out, nil +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/id_hostpool.go b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/id_hostpool.go new file mode 100644 index 00000000000..e1eb7c7537b --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/id_hostpool.go @@ -0,0 +1,130 @@ +package hostpool + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&HostPoolId{}) +} + +var _ resourceids.ResourceId = &HostPoolId{} + +// HostPoolId is a struct representing the Resource ID for a Host Pool +type HostPoolId struct { + SubscriptionId string + ResourceGroupName string + HostPoolName string +} + +// NewHostPoolID returns a new HostPoolId struct +func NewHostPoolID(subscriptionId string, resourceGroupName string, hostPoolName string) HostPoolId { + return HostPoolId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + HostPoolName: hostPoolName, + } +} + +// ParseHostPoolID parses 'input' into a HostPoolId +func ParseHostPoolID(input string) (*HostPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostPoolId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostPoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseHostPoolIDInsensitively parses 'input' case-insensitively into a HostPoolId +// note: this method should only be used for API response data and not user input +func ParseHostPoolIDInsensitively(input string) (*HostPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostPoolId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostPoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *HostPoolId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.HostPoolName, ok = input.Parsed["hostPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hostPoolName", input) + } + + return nil +} + +// ValidateHostPoolID checks that 'input' can be parsed as a Host Pool ID +func ValidateHostPoolID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseHostPoolID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Host Pool ID +func (id HostPoolId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DesktopVirtualization/hostPools/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.HostPoolName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Host Pool ID +func (id HostPoolId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDesktopVirtualization", "Microsoft.DesktopVirtualization", "Microsoft.DesktopVirtualization"), + resourceids.StaticSegment("staticHostPools", "hostPools", "hostPools"), + resourceids.UserSpecifiedSegment("hostPoolName", "hostPoolName"), + } +} + +// String returns a human-readable description of this Host Pool ID +func (id HostPoolId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Host Pool Name: %q", id.HostPoolName), + } + return fmt.Sprintf("Host Pool (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/id_hostpool_test.go b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/id_hostpool_test.go new file mode 100644 index 00000000000..9505233d81d --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/id_hostpool_test.go @@ -0,0 +1,282 @@ +package hostpool + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &HostPoolId{} + +func TestNewHostPoolID(t *testing.T) { + id := NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.HostPoolName != "hostPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'HostPoolName'", id.HostPoolName, "hostPoolName") + } +} + +func TestFormatHostPoolID(t *testing.T) { + actual := NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseHostPoolID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostPoolId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName", + Expected: &HostPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostPoolName: "hostPoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostPoolID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostPoolName != v.Expected.HostPoolName { + t.Fatalf("Expected %q but got %q for HostPoolName", v.Expected.HostPoolName, actual.HostPoolName) + } + + } +} + +func TestParseHostPoolIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostPoolId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName", + Expected: &HostPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostPoolName: "hostPoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs/hOsTpOoLnAmE", + Expected: &HostPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + HostPoolName: "hOsTpOoLnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs/hOsTpOoLnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostPoolIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostPoolName != v.Expected.HostPoolName { + t.Fatalf("Expected %q but got %q for HostPoolName", v.Expected.HostPoolName, actual.HostPoolName) + } + + } +} + +func TestSegmentsForHostPoolId(t *testing.T) { + segments := HostPoolId{}.Segments() + if len(segments) == 0 { + t.Fatalf("HostPoolId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/method_createorupdate.go b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/method_createorupdate.go new file mode 100644 index 00000000000..4256dfa27bb --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/method_createorupdate.go @@ -0,0 +1,58 @@ +package hostpool + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HostPool +} + +// CreateOrUpdate ... +func (c HostPoolClient) CreateOrUpdate(ctx context.Context, id HostPoolId, input HostPool) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model HostPool + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/method_delete.go b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/method_delete.go new file mode 100644 index 00000000000..d83814eacc1 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/method_delete.go @@ -0,0 +1,77 @@ +package hostpool + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + Force *bool +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Force != nil { + out.Append("force", fmt.Sprintf("%v", *o.Force)) + } + return &out +} + +// Delete ... +func (c HostPoolClient) Delete(ctx context.Context, id HostPoolId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + 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/desktopvirtualization/2024-04-08-preview/hostpool/method_get.go b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/method_get.go new file mode 100644 index 00000000000..1beab20188e --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/method_get.go @@ -0,0 +1,53 @@ +package hostpool + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *HostPool +} + +// Get ... +func (c HostPoolClient) Get(ctx context.Context, id HostPoolId) (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 HostPool + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/method_list.go b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/method_list.go new file mode 100644 index 00000000000..167656ecfd7 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/method_list.go @@ -0,0 +1,143 @@ +package hostpool + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]HostPool +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []HostPool +} + +type ListOperationOptions struct { + InitialSkip *int64 + IsDescending *bool + PageSize *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.InitialSkip != nil { + out.Append("initialSkip", fmt.Sprintf("%v", *o.InitialSkip)) + } + if o.IsDescending != nil { + out.Append("isDescending", fmt.Sprintf("%v", *o.IsDescending)) + } + if o.PageSize != nil { + out.Append("pageSize", fmt.Sprintf("%v", *o.PageSize)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c HostPoolClient) List(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DesktopVirtualization/hostPools", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]HostPool `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c HostPoolClient) ListComplete(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, HostPoolOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c HostPoolClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions, predicate HostPoolOperationPredicate) (result ListCompleteResult, err error) { + items := make([]HostPool, 0) + + resp, err := c.List(ctx, id, options) + 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 = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/method_listbyresourcegroup.go b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/method_listbyresourcegroup.go new file mode 100644 index 00000000000..fc6de240f33 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/method_listbyresourcegroup.go @@ -0,0 +1,143 @@ +package hostpool + +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 *[]HostPool +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []HostPool +} + +type ListByResourceGroupOperationOptions struct { + InitialSkip *int64 + IsDescending *bool + PageSize *int64 +} + +func DefaultListByResourceGroupOperationOptions() ListByResourceGroupOperationOptions { + return ListByResourceGroupOperationOptions{} +} + +func (o ListByResourceGroupOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByResourceGroupOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListByResourceGroupOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.InitialSkip != nil { + out.Append("initialSkip", fmt.Sprintf("%v", *o.InitialSkip)) + } + if o.IsDescending != nil { + out.Append("isDescending", fmt.Sprintf("%v", *o.IsDescending)) + } + if o.PageSize != nil { + out.Append("pageSize", fmt.Sprintf("%v", *o.PageSize)) + } + return &out +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c HostPoolClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DesktopVirtualization/hostPools", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]HostPool `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 HostPoolClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, options, HostPoolOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c HostPoolClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions, predicate HostPoolOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]HostPool, 0) + + resp, err := c.ListByResourceGroup(ctx, id, options) + 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/desktopvirtualization/2024-04-08-preview/hostpool/method_listregistrationtokens.go b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/method_listregistrationtokens.go new file mode 100644 index 00000000000..38b754a9479 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/method_listregistrationtokens.go @@ -0,0 +1,105 @@ +package hostpool + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListRegistrationTokensOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RegistrationTokenMinimal +} + +type ListRegistrationTokensCompleteResult struct { + LatestHttpResponse *http.Response + Items []RegistrationTokenMinimal +} + +type ListRegistrationTokensCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListRegistrationTokensCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListRegistrationTokens ... +func (c HostPoolClient) ListRegistrationTokens(ctx context.Context, id HostPoolId) (result ListRegistrationTokensOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ListRegistrationTokensCustomPager{}, + Path: fmt.Sprintf("%s/listRegistrationTokens", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]RegistrationTokenMinimal `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListRegistrationTokensComplete retrieves all the results into a single object +func (c HostPoolClient) ListRegistrationTokensComplete(ctx context.Context, id HostPoolId) (ListRegistrationTokensCompleteResult, error) { + return c.ListRegistrationTokensCompleteMatchingPredicate(ctx, id, RegistrationTokenMinimalOperationPredicate{}) +} + +// ListRegistrationTokensCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c HostPoolClient) ListRegistrationTokensCompleteMatchingPredicate(ctx context.Context, id HostPoolId, predicate RegistrationTokenMinimalOperationPredicate) (result ListRegistrationTokensCompleteResult, err error) { + items := make([]RegistrationTokenMinimal, 0) + + resp, err := c.ListRegistrationTokens(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 = ListRegistrationTokensCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/method_retrieveregistrationtoken.go b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/method_retrieveregistrationtoken.go new file mode 100644 index 00000000000..d6ba45ec662 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/method_retrieveregistrationtoken.go @@ -0,0 +1,54 @@ +package hostpool + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RetrieveRegistrationTokenOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RegistrationInfo +} + +// RetrieveRegistrationToken ... +func (c HostPoolClient) RetrieveRegistrationToken(ctx context.Context, id HostPoolId) (result RetrieveRegistrationTokenOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/retrieveRegistrationToken", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model RegistrationInfo + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/method_update.go b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/method_update.go new file mode 100644 index 00000000000..ec302eab026 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/method_update.go @@ -0,0 +1,57 @@ +package hostpool + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HostPool +} + +// Update ... +func (c HostPoolClient) Update(ctx context.Context, id HostPoolId, input HostPoolPatch) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model HostPool + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_agentupdatepatchproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_agentupdatepatchproperties.go new file mode 100644 index 00000000000..7656dc349a5 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_agentupdatepatchproperties.go @@ -0,0 +1,11 @@ +package hostpool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentUpdatePatchProperties struct { + MaintenanceWindowTimeZone *string `json:"maintenanceWindowTimeZone,omitempty"` + MaintenanceWindows *[]MaintenanceWindowPatchProperties `json:"maintenanceWindows,omitempty"` + Type *SessionHostComponentUpdateType `json:"type,omitempty"` + UseSessionHostLocalTime *bool `json:"useSessionHostLocalTime,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_agentupdateproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_agentupdateproperties.go new file mode 100644 index 00000000000..76ca245b1c8 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_agentupdateproperties.go @@ -0,0 +1,11 @@ +package hostpool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentUpdateProperties struct { + MaintenanceWindowTimeZone *string `json:"maintenanceWindowTimeZone,omitempty"` + MaintenanceWindows *[]MaintenanceWindowProperties `json:"maintenanceWindows,omitempty"` + Type *SessionHostComponentUpdateType `json:"type,omitempty"` + UseSessionHostLocalTime *bool `json:"useSessionHostLocalTime,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_hostpool.go b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_hostpool.go new file mode 100644 index 00000000000..aa285f513c7 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_hostpool.go @@ -0,0 +1,25 @@ +package hostpool + +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 HostPool struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + ManagedBy *string `json:"managedBy,omitempty"` + Name *string `json:"name,omitempty"` + Plan *Plan `json:"plan,omitempty"` + Properties HostPoolProperties `json:"properties"` + Sku *Sku `json:"sku,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_hostpoolpatch.go b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_hostpoolpatch.go new file mode 100644 index 00000000000..a0808ba7720 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_hostpoolpatch.go @@ -0,0 +1,17 @@ +package hostpool + +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 HostPoolPatch struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *HostPoolPatchProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_hostpoolpatchproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_hostpoolpatchproperties.go new file mode 100644 index 00000000000..faa6508312f --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_hostpoolpatchproperties.go @@ -0,0 +1,29 @@ +package hostpool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HostPoolPatchProperties struct { + AgentUpdate *AgentUpdatePatchProperties `json:"agentUpdate,omitempty"` + CustomRdpProperty *string `json:"customRdpProperty,omitempty"` + Description *string `json:"description,omitempty"` + DirectUDP *DirectUDP `json:"directUDP,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + LoadBalancerType *LoadBalancerType `json:"loadBalancerType,omitempty"` + ManagedPrivateUDP *ManagedPrivateUDP `json:"managedPrivateUDP,omitempty"` + MaxSessionLimit *int64 `json:"maxSessionLimit,omitempty"` + PersonalDesktopAssignmentType *PersonalDesktopAssignmentType `json:"personalDesktopAssignmentType,omitempty"` + PreferredAppGroupType *PreferredAppGroupType `json:"preferredAppGroupType,omitempty"` + PublicNetworkAccess *HostpoolPublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + PublicUDP *PublicUDP `json:"publicUDP,omitempty"` + RegistrationInfo *RegistrationInfoPatch `json:"registrationInfo,omitempty"` + RelayUDP *RelayUDP `json:"relayUDP,omitempty"` + Ring *int64 `json:"ring,omitempty"` + SsoClientId *string `json:"ssoClientId,omitempty"` + SsoClientSecretKeyVaultPath *string `json:"ssoClientSecretKeyVaultPath,omitempty"` + SsoSecretType *SSOSecretType `json:"ssoSecretType,omitempty"` + SsoadfsAuthority *string `json:"ssoadfsAuthority,omitempty"` + StartVMOnConnect *bool `json:"startVMOnConnect,omitempty"` + VMTemplate *string `json:"vmTemplate,omitempty"` + ValidationEnvironment *bool `json:"validationEnvironment,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_hostpoolproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_hostpoolproperties.go new file mode 100644 index 00000000000..480dd978524 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_hostpoolproperties.go @@ -0,0 +1,36 @@ +package hostpool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HostPoolProperties struct { + AgentUpdate *AgentUpdateProperties `json:"agentUpdate,omitempty"` + AppAttachPackageReferences *[]string `json:"appAttachPackageReferences,omitempty"` + ApplicationGroupReferences *[]string `json:"applicationGroupReferences,omitempty"` + CloudPcResource *bool `json:"cloudPcResource,omitempty"` + CustomRdpProperty *string `json:"customRdpProperty,omitempty"` + Description *string `json:"description,omitempty"` + DirectUDP *DirectUDP `json:"directUDP,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HostPoolType HostPoolType `json:"hostPoolType"` + LoadBalancerType LoadBalancerType `json:"loadBalancerType"` + ManagedPrivateUDP *ManagedPrivateUDP `json:"managedPrivateUDP,omitempty"` + ManagementType *ManagementType `json:"managementType,omitempty"` + MaxSessionLimit *int64 `json:"maxSessionLimit,omitempty"` + ObjectId *string `json:"objectId,omitempty"` + PersonalDesktopAssignmentType *PersonalDesktopAssignmentType `json:"personalDesktopAssignmentType,omitempty"` + PreferredAppGroupType PreferredAppGroupType `json:"preferredAppGroupType"` + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + PublicNetworkAccess *HostpoolPublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + PublicUDP *PublicUDP `json:"publicUDP,omitempty"` + RegistrationInfo *RegistrationInfo `json:"registrationInfo,omitempty"` + RelayUDP *RelayUDP `json:"relayUDP,omitempty"` + Ring *int64 `json:"ring,omitempty"` + SsoClientId *string `json:"ssoClientId,omitempty"` + SsoClientSecretKeyVaultPath *string `json:"ssoClientSecretKeyVaultPath,omitempty"` + SsoSecretType *SSOSecretType `json:"ssoSecretType,omitempty"` + SsoadfsAuthority *string `json:"ssoadfsAuthority,omitempty"` + StartVMOnConnect *bool `json:"startVMOnConnect,omitempty"` + VMTemplate *string `json:"vmTemplate,omitempty"` + ValidationEnvironment *bool `json:"validationEnvironment,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_maintenancewindowpatchproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_maintenancewindowpatchproperties.go new file mode 100644 index 00000000000..543fa9f8df4 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_maintenancewindowpatchproperties.go @@ -0,0 +1,9 @@ +package hostpool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MaintenanceWindowPatchProperties struct { + DayOfWeek *DayOfWeek `json:"dayOfWeek,omitempty"` + Hour *int64 `json:"hour,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_maintenancewindowproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_maintenancewindowproperties.go new file mode 100644 index 00000000000..5e64a28986d --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_maintenancewindowproperties.go @@ -0,0 +1,9 @@ +package hostpool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MaintenanceWindowProperties struct { + DayOfWeek *DayOfWeek `json:"dayOfWeek,omitempty"` + Hour *int64 `json:"hour,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_plan.go b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_plan.go new file mode 100644 index 00000000000..f81691c1b9a --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_plan.go @@ -0,0 +1,12 @@ +package hostpool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Plan struct { + Name string `json:"name"` + Product string `json:"product"` + PromotionCode *string `json:"promotionCode,omitempty"` + Publisher string `json:"publisher"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_privateendpoint.go b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_privateendpoint.go new file mode 100644 index 00000000000..43cd81d27a9 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_privateendpoint.go @@ -0,0 +1,8 @@ +package hostpool + +// 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/desktopvirtualization/2024-04-08-preview/hostpool/model_privateendpointconnection.go b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_privateendpointconnection.go new file mode 100644 index 00000000000..20367ebf93a --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_privateendpointconnection.go @@ -0,0 +1,16 @@ +package hostpool + +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/desktopvirtualization/2024-04-08-preview/hostpool/model_privateendpointconnectionproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..2afe514d519 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_privateendpointconnectionproperties.go @@ -0,0 +1,11 @@ +package hostpool + +// 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"` + ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_privatelinkserviceconnectionstate.go b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..b6a202ccf34 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package hostpool + +// 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 *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_registrationinfo.go b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_registrationinfo.go new file mode 100644 index 00000000000..ed356c7e596 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_registrationinfo.go @@ -0,0 +1,28 @@ +package hostpool + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistrationInfo struct { + ExpirationTime *string `json:"expirationTime,omitempty"` + RegistrationTokenOperation *RegistrationTokenOperation `json:"registrationTokenOperation,omitempty"` + Token *string `json:"token,omitempty"` +} + +func (o *RegistrationInfo) GetExpirationTimeAsTime() (*time.Time, error) { + if o.ExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RegistrationInfo) SetExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpirationTime = &formatted +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_registrationinfopatch.go b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_registrationinfopatch.go new file mode 100644 index 00000000000..7340343045e --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_registrationinfopatch.go @@ -0,0 +1,27 @@ +package hostpool + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistrationInfoPatch struct { + ExpirationTime *string `json:"expirationTime,omitempty"` + RegistrationTokenOperation *RegistrationTokenOperation `json:"registrationTokenOperation,omitempty"` +} + +func (o *RegistrationInfoPatch) GetExpirationTimeAsTime() (*time.Time, error) { + if o.ExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RegistrationInfoPatch) SetExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpirationTime = &formatted +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_registrationtokenminimal.go b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_registrationtokenminimal.go new file mode 100644 index 00000000000..4db3784f666 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_registrationtokenminimal.go @@ -0,0 +1,27 @@ +package hostpool + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistrationTokenMinimal struct { + ExpirationTime *string `json:"expirationTime,omitempty"` + Token *string `json:"token,omitempty"` +} + +func (o *RegistrationTokenMinimal) GetExpirationTimeAsTime() (*time.Time, error) { + if o.ExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RegistrationTokenMinimal) SetExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpirationTime = &formatted +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_sku.go b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_sku.go new file mode 100644 index 00000000000..26583f4fcea --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/model_sku.go @@ -0,0 +1,12 @@ +package hostpool + +// 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 *int64 `json:"capacity,omitempty"` + Family *string `json:"family,omitempty"` + Name string `json:"name"` + Size *string `json:"size,omitempty"` + Tier *SkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/predicates.go b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/predicates.go new file mode 100644 index 00000000000..0f7dfb34b32 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/predicates.go @@ -0,0 +1,65 @@ +package hostpool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HostPoolOperationPredicate struct { + Etag *string + Id *string + Kind *string + Location *string + ManagedBy *string + Name *string + Type *string +} + +func (p HostPoolOperationPredicate) Matches(input HostPool) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.ManagedBy != nil && (input.ManagedBy == nil || *p.ManagedBy != *input.ManagedBy) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type RegistrationTokenMinimalOperationPredicate struct { + ExpirationTime *string + Token *string +} + +func (p RegistrationTokenMinimalOperationPredicate) Matches(input RegistrationTokenMinimal) bool { + + if p.ExpirationTime != nil && (input.ExpirationTime == nil || *p.ExpirationTime != *input.ExpirationTime) { + return false + } + + if p.Token != nil && (input.Token == nil || *p.Token != *input.Token) { + return false + } + + return true +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/version.go b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/version.go new file mode 100644 index 00000000000..9df519bcc7b --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/hostpool/version.go @@ -0,0 +1,10 @@ +package hostpool + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-08-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/hostpool/2024-04-08-preview" +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/msiximage/README.md b/resource-manager/desktopvirtualization/2024-04-08-preview/msiximage/README.md new file mode 100644 index 00000000000..02d493cb7b0 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/msiximage/README.md @@ -0,0 +1,42 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/msiximage` Documentation + +The `msiximage` SDK allows for interaction with Azure Resource Manager `desktopvirtualization` (API Version `2024-04-08-preview`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/msiximage" +``` + + +### Client Initialization + +```go +client := msiximage.NewMsixImageClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `MsixImageClient.Expand` + +```go +ctx := context.TODO() +id := msiximage.NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName") + +payload := msiximage.MSIXImageURI{ + // ... +} + + +// alternatively `client.Expand(ctx, id, payload)` can be used to do batched pagination +items, err := client.ExpandComplete(ctx, id, payload) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/msiximage/client.go b/resource-manager/desktopvirtualization/2024-04-08-preview/msiximage/client.go new file mode 100644 index 00000000000..ae8a2fb4410 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/msiximage/client.go @@ -0,0 +1,26 @@ +package msiximage + +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 MsixImageClient struct { + Client *resourcemanager.Client +} + +func NewMsixImageClientWithBaseURI(sdkApi sdkEnv.Api) (*MsixImageClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "msiximage", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating MsixImageClient: %+v", err) + } + + return &MsixImageClient{ + Client: client, + }, nil +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/msiximage/id_hostpool.go b/resource-manager/desktopvirtualization/2024-04-08-preview/msiximage/id_hostpool.go new file mode 100644 index 00000000000..e298697ac38 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/msiximage/id_hostpool.go @@ -0,0 +1,130 @@ +package msiximage + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&HostPoolId{}) +} + +var _ resourceids.ResourceId = &HostPoolId{} + +// HostPoolId is a struct representing the Resource ID for a Host Pool +type HostPoolId struct { + SubscriptionId string + ResourceGroupName string + HostPoolName string +} + +// NewHostPoolID returns a new HostPoolId struct +func NewHostPoolID(subscriptionId string, resourceGroupName string, hostPoolName string) HostPoolId { + return HostPoolId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + HostPoolName: hostPoolName, + } +} + +// ParseHostPoolID parses 'input' into a HostPoolId +func ParseHostPoolID(input string) (*HostPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostPoolId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostPoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseHostPoolIDInsensitively parses 'input' case-insensitively into a HostPoolId +// note: this method should only be used for API response data and not user input +func ParseHostPoolIDInsensitively(input string) (*HostPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostPoolId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostPoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *HostPoolId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.HostPoolName, ok = input.Parsed["hostPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hostPoolName", input) + } + + return nil +} + +// ValidateHostPoolID checks that 'input' can be parsed as a Host Pool ID +func ValidateHostPoolID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseHostPoolID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Host Pool ID +func (id HostPoolId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DesktopVirtualization/hostPools/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.HostPoolName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Host Pool ID +func (id HostPoolId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDesktopVirtualization", "Microsoft.DesktopVirtualization", "Microsoft.DesktopVirtualization"), + resourceids.StaticSegment("staticHostPools", "hostPools", "hostPools"), + resourceids.UserSpecifiedSegment("hostPoolName", "hostPoolName"), + } +} + +// String returns a human-readable description of this Host Pool ID +func (id HostPoolId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Host Pool Name: %q", id.HostPoolName), + } + return fmt.Sprintf("Host Pool (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/msiximage/id_hostpool_test.go b/resource-manager/desktopvirtualization/2024-04-08-preview/msiximage/id_hostpool_test.go new file mode 100644 index 00000000000..37035d57fba --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/msiximage/id_hostpool_test.go @@ -0,0 +1,282 @@ +package msiximage + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &HostPoolId{} + +func TestNewHostPoolID(t *testing.T) { + id := NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.HostPoolName != "hostPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'HostPoolName'", id.HostPoolName, "hostPoolName") + } +} + +func TestFormatHostPoolID(t *testing.T) { + actual := NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseHostPoolID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostPoolId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName", + Expected: &HostPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostPoolName: "hostPoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostPoolID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostPoolName != v.Expected.HostPoolName { + t.Fatalf("Expected %q but got %q for HostPoolName", v.Expected.HostPoolName, actual.HostPoolName) + } + + } +} + +func TestParseHostPoolIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostPoolId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName", + Expected: &HostPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostPoolName: "hostPoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs/hOsTpOoLnAmE", + Expected: &HostPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + HostPoolName: "hOsTpOoLnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs/hOsTpOoLnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostPoolIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostPoolName != v.Expected.HostPoolName { + t.Fatalf("Expected %q but got %q for HostPoolName", v.Expected.HostPoolName, actual.HostPoolName) + } + + } +} + +func TestSegmentsForHostPoolId(t *testing.T) { + segments := HostPoolId{}.Segments() + if len(segments) == 0 { + t.Fatalf("HostPoolId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/msiximage/method_expand.go b/resource-manager/desktopvirtualization/2024-04-08-preview/msiximage/method_expand.go new file mode 100644 index 00000000000..fc0181a310b --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/msiximage/method_expand.go @@ -0,0 +1,105 @@ +package msiximage + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpandOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ExpandMsixImage +} + +type ExpandCompleteResult struct { + LatestHttpResponse *http.Response + Items []ExpandMsixImage +} + +type ExpandCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ExpandCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// Expand ... +func (c MsixImageClient) Expand(ctx context.Context, id HostPoolId, input MSIXImageURI) (result ExpandOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ExpandCustomPager{}, + Path: fmt.Sprintf("%s/expandMsixImage", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ExpandMsixImage `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ExpandComplete retrieves all the results into a single object +func (c MsixImageClient) ExpandComplete(ctx context.Context, id HostPoolId, input MSIXImageURI) (ExpandCompleteResult, error) { + return c.ExpandCompleteMatchingPredicate(ctx, id, input, ExpandMsixImageOperationPredicate{}) +} + +// ExpandCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c MsixImageClient) ExpandCompleteMatchingPredicate(ctx context.Context, id HostPoolId, input MSIXImageURI, predicate ExpandMsixImageOperationPredicate) (result ExpandCompleteResult, err error) { + items := make([]ExpandMsixImage, 0) + + resp, err := c.Expand(ctx, id, input) + 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 = ExpandCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/msiximage/model_expandmsiximage.go b/resource-manager/desktopvirtualization/2024-04-08-preview/msiximage/model_expandmsiximage.go new file mode 100644 index 00000000000..b239f0189a0 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/msiximage/model_expandmsiximage.go @@ -0,0 +1,16 @@ +package msiximage + +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 ExpandMsixImage struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ExpandMsixImageProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/msiximage/model_expandmsiximageproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/msiximage/model_expandmsiximageproperties.go new file mode 100644 index 00000000000..18660d31f92 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/msiximage/model_expandmsiximageproperties.go @@ -0,0 +1,52 @@ +package msiximage + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpandMsixImageProperties struct { + CertificateExpiry *string `json:"certificateExpiry,omitempty"` + CertificateName *string `json:"certificateName,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + ImagePath *string `json:"imagePath,omitempty"` + IsActive *bool `json:"isActive,omitempty"` + IsRegularRegistration *bool `json:"isRegularRegistration,omitempty"` + LastUpdated *string `json:"lastUpdated,omitempty"` + PackageAlias *string `json:"packageAlias,omitempty"` + PackageApplications *[]MsixPackageApplications `json:"packageApplications,omitempty"` + PackageDependencies *[]MsixPackageDependencies `json:"packageDependencies,omitempty"` + PackageFamilyName *string `json:"packageFamilyName,omitempty"` + PackageFullName *string `json:"packageFullName,omitempty"` + PackageName *string `json:"packageName,omitempty"` + PackageRelativePath *string `json:"packageRelativePath,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *ExpandMsixImageProperties) GetCertificateExpiryAsTime() (*time.Time, error) { + if o.CertificateExpiry == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CertificateExpiry, "2006-01-02T15:04:05Z07:00") +} + +func (o *ExpandMsixImageProperties) SetCertificateExpiryAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CertificateExpiry = &formatted +} + +func (o *ExpandMsixImageProperties) GetLastUpdatedAsTime() (*time.Time, error) { + if o.LastUpdated == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastUpdated, "2006-01-02T15:04:05Z07:00") +} + +func (o *ExpandMsixImageProperties) SetLastUpdatedAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastUpdated = &formatted +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/msiximage/model_msiximageuri.go b/resource-manager/desktopvirtualization/2024-04-08-preview/msiximage/model_msiximageuri.go new file mode 100644 index 00000000000..d7ac653b01b --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/msiximage/model_msiximageuri.go @@ -0,0 +1,8 @@ +package msiximage + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MSIXImageURI struct { + Uri *string `json:"uri,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/msiximage/model_msixpackageapplications.go b/resource-manager/desktopvirtualization/2024-04-08-preview/msiximage/model_msixpackageapplications.go new file mode 100644 index 00000000000..372e033f8bb --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/msiximage/model_msixpackageapplications.go @@ -0,0 +1,14 @@ +package msiximage + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MsixPackageApplications struct { + AppId *string `json:"appId,omitempty"` + AppUserModelID *string `json:"appUserModelID,omitempty"` + Description *string `json:"description,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + IconImageName *string `json:"iconImageName,omitempty"` + RawIcon *string `json:"rawIcon,omitempty"` + RawPng *string `json:"rawPng,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/msiximage/model_msixpackagedependencies.go b/resource-manager/desktopvirtualization/2024-04-08-preview/msiximage/model_msixpackagedependencies.go new file mode 100644 index 00000000000..28c81df069c --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/msiximage/model_msixpackagedependencies.go @@ -0,0 +1,10 @@ +package msiximage + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MsixPackageDependencies struct { + DependencyName *string `json:"dependencyName,omitempty"` + MinVersion *string `json:"minVersion,omitempty"` + Publisher *string `json:"publisher,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/msiximage/predicates.go b/resource-manager/desktopvirtualization/2024-04-08-preview/msiximage/predicates.go new file mode 100644 index 00000000000..a91fc8b3c1d --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/msiximage/predicates.go @@ -0,0 +1,27 @@ +package msiximage + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpandMsixImageOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p ExpandMsixImageOperationPredicate) Matches(input ExpandMsixImage) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/msiximage/version.go b/resource-manager/desktopvirtualization/2024-04-08-preview/msiximage/version.go new file mode 100644 index 00000000000..897f39f4f94 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/msiximage/version.go @@ -0,0 +1,10 @@ +package msiximage + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-08-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/msiximage/2024-04-08-preview" +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/README.md b/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/README.md new file mode 100644 index 00000000000..4825fe9e3a3 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/README.md @@ -0,0 +1,111 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage` Documentation + +The `msixpackage` SDK allows for interaction with Azure Resource Manager `desktopvirtualization` (API Version `2024-04-08-preview`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage" +``` + + +### Client Initialization + +```go +client := msixpackage.NewMSIXPackageClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `MSIXPackageClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := msixpackage.NewMsixPackageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName", "msixPackageName") + +payload := msixpackage.MSIXPackage{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `MSIXPackageClient.Delete` + +```go +ctx := context.TODO() +id := msixpackage.NewMsixPackageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName", "msixPackageName") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `MSIXPackageClient.Get` + +```go +ctx := context.TODO() +id := msixpackage.NewMsixPackageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName", "msixPackageName") + +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: `MSIXPackageClient.List` + +```go +ctx := context.TODO() +id := msixpackage.NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName") + +// alternatively `client.List(ctx, id, msixpackage.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, msixpackage.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `MSIXPackageClient.Update` + +```go +ctx := context.TODO() +id := msixpackage.NewMsixPackageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName", "msixPackageName") + +payload := msixpackage.MSIXPackagePatch{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/client.go b/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/client.go new file mode 100644 index 00000000000..7104aaa71b3 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/client.go @@ -0,0 +1,26 @@ +package msixpackage + +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 MSIXPackageClient struct { + Client *resourcemanager.Client +} + +func NewMSIXPackageClientWithBaseURI(sdkApi sdkEnv.Api) (*MSIXPackageClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "msixpackage", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating MSIXPackageClient: %+v", err) + } + + return &MSIXPackageClient{ + Client: client, + }, nil +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/id_hostpool.go b/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/id_hostpool.go new file mode 100644 index 00000000000..2417642aa73 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/id_hostpool.go @@ -0,0 +1,130 @@ +package msixpackage + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&HostPoolId{}) +} + +var _ resourceids.ResourceId = &HostPoolId{} + +// HostPoolId is a struct representing the Resource ID for a Host Pool +type HostPoolId struct { + SubscriptionId string + ResourceGroupName string + HostPoolName string +} + +// NewHostPoolID returns a new HostPoolId struct +func NewHostPoolID(subscriptionId string, resourceGroupName string, hostPoolName string) HostPoolId { + return HostPoolId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + HostPoolName: hostPoolName, + } +} + +// ParseHostPoolID parses 'input' into a HostPoolId +func ParseHostPoolID(input string) (*HostPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostPoolId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostPoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseHostPoolIDInsensitively parses 'input' case-insensitively into a HostPoolId +// note: this method should only be used for API response data and not user input +func ParseHostPoolIDInsensitively(input string) (*HostPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostPoolId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostPoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *HostPoolId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.HostPoolName, ok = input.Parsed["hostPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hostPoolName", input) + } + + return nil +} + +// ValidateHostPoolID checks that 'input' can be parsed as a Host Pool ID +func ValidateHostPoolID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseHostPoolID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Host Pool ID +func (id HostPoolId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DesktopVirtualization/hostPools/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.HostPoolName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Host Pool ID +func (id HostPoolId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDesktopVirtualization", "Microsoft.DesktopVirtualization", "Microsoft.DesktopVirtualization"), + resourceids.StaticSegment("staticHostPools", "hostPools", "hostPools"), + resourceids.UserSpecifiedSegment("hostPoolName", "hostPoolName"), + } +} + +// String returns a human-readable description of this Host Pool ID +func (id HostPoolId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Host Pool Name: %q", id.HostPoolName), + } + return fmt.Sprintf("Host Pool (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/id_hostpool_test.go b/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/id_hostpool_test.go new file mode 100644 index 00000000000..41123960916 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/id_hostpool_test.go @@ -0,0 +1,282 @@ +package msixpackage + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &HostPoolId{} + +func TestNewHostPoolID(t *testing.T) { + id := NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.HostPoolName != "hostPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'HostPoolName'", id.HostPoolName, "hostPoolName") + } +} + +func TestFormatHostPoolID(t *testing.T) { + actual := NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseHostPoolID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostPoolId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName", + Expected: &HostPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostPoolName: "hostPoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostPoolID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostPoolName != v.Expected.HostPoolName { + t.Fatalf("Expected %q but got %q for HostPoolName", v.Expected.HostPoolName, actual.HostPoolName) + } + + } +} + +func TestParseHostPoolIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostPoolId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName", + Expected: &HostPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostPoolName: "hostPoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs/hOsTpOoLnAmE", + Expected: &HostPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + HostPoolName: "hOsTpOoLnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs/hOsTpOoLnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostPoolIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostPoolName != v.Expected.HostPoolName { + t.Fatalf("Expected %q but got %q for HostPoolName", v.Expected.HostPoolName, actual.HostPoolName) + } + + } +} + +func TestSegmentsForHostPoolId(t *testing.T) { + segments := HostPoolId{}.Segments() + if len(segments) == 0 { + t.Fatalf("HostPoolId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/id_msixpackage.go b/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/id_msixpackage.go new file mode 100644 index 00000000000..f72e6d6f0f1 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/id_msixpackage.go @@ -0,0 +1,139 @@ +package msixpackage + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&MsixPackageId{}) +} + +var _ resourceids.ResourceId = &MsixPackageId{} + +// MsixPackageId is a struct representing the Resource ID for a Msix Package +type MsixPackageId struct { + SubscriptionId string + ResourceGroupName string + HostPoolName string + MsixPackageName string +} + +// NewMsixPackageID returns a new MsixPackageId struct +func NewMsixPackageID(subscriptionId string, resourceGroupName string, hostPoolName string, msixPackageName string) MsixPackageId { + return MsixPackageId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + HostPoolName: hostPoolName, + MsixPackageName: msixPackageName, + } +} + +// ParseMsixPackageID parses 'input' into a MsixPackageId +func ParseMsixPackageID(input string) (*MsixPackageId, error) { + parser := resourceids.NewParserFromResourceIdType(&MsixPackageId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MsixPackageId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseMsixPackageIDInsensitively parses 'input' case-insensitively into a MsixPackageId +// note: this method should only be used for API response data and not user input +func ParseMsixPackageIDInsensitively(input string) (*MsixPackageId, error) { + parser := resourceids.NewParserFromResourceIdType(&MsixPackageId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MsixPackageId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *MsixPackageId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.HostPoolName, ok = input.Parsed["hostPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hostPoolName", input) + } + + if id.MsixPackageName, ok = input.Parsed["msixPackageName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "msixPackageName", input) + } + + return nil +} + +// ValidateMsixPackageID checks that 'input' can be parsed as a Msix Package ID +func ValidateMsixPackageID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseMsixPackageID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Msix Package ID +func (id MsixPackageId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DesktopVirtualization/hostPools/%s/msixPackages/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.HostPoolName, id.MsixPackageName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Msix Package ID +func (id MsixPackageId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDesktopVirtualization", "Microsoft.DesktopVirtualization", "Microsoft.DesktopVirtualization"), + resourceids.StaticSegment("staticHostPools", "hostPools", "hostPools"), + resourceids.UserSpecifiedSegment("hostPoolName", "hostPoolName"), + resourceids.StaticSegment("staticMsixPackages", "msixPackages", "msixPackages"), + resourceids.UserSpecifiedSegment("msixPackageName", "msixPackageName"), + } +} + +// String returns a human-readable description of this Msix Package ID +func (id MsixPackageId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Host Pool Name: %q", id.HostPoolName), + fmt.Sprintf("Msix Package Name: %q", id.MsixPackageName), + } + return fmt.Sprintf("Msix Package (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/id_msixpackage_test.go b/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/id_msixpackage_test.go new file mode 100644 index 00000000000..bea1658d0de --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/id_msixpackage_test.go @@ -0,0 +1,327 @@ +package msixpackage + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &MsixPackageId{} + +func TestNewMsixPackageID(t *testing.T) { + id := NewMsixPackageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName", "msixPackageName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.HostPoolName != "hostPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'HostPoolName'", id.HostPoolName, "hostPoolName") + } + + if id.MsixPackageName != "msixPackageName" { + t.Fatalf("Expected %q but got %q for Segment 'MsixPackageName'", id.MsixPackageName, "msixPackageName") + } +} + +func TestFormatMsixPackageID(t *testing.T) { + actual := NewMsixPackageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName", "msixPackageName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/msixPackages/msixPackageName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseMsixPackageID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MsixPackageId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/msixPackages", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/msixPackages/msixPackageName", + Expected: &MsixPackageId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostPoolName: "hostPoolName", + MsixPackageName: "msixPackageName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/msixPackages/msixPackageName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMsixPackageID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostPoolName != v.Expected.HostPoolName { + t.Fatalf("Expected %q but got %q for HostPoolName", v.Expected.HostPoolName, actual.HostPoolName) + } + + if actual.MsixPackageName != v.Expected.MsixPackageName { + t.Fatalf("Expected %q but got %q for MsixPackageName", v.Expected.MsixPackageName, actual.MsixPackageName) + } + + } +} + +func TestParseMsixPackageIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MsixPackageId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs/hOsTpOoLnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/msixPackages", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs/hOsTpOoLnAmE/mSiXpAcKaGeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/msixPackages/msixPackageName", + Expected: &MsixPackageId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostPoolName: "hostPoolName", + MsixPackageName: "msixPackageName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/msixPackages/msixPackageName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs/hOsTpOoLnAmE/mSiXpAcKaGeS/mSiXpAcKaGeNaMe", + Expected: &MsixPackageId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + HostPoolName: "hOsTpOoLnAmE", + MsixPackageName: "mSiXpAcKaGeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs/hOsTpOoLnAmE/mSiXpAcKaGeS/mSiXpAcKaGeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMsixPackageIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostPoolName != v.Expected.HostPoolName { + t.Fatalf("Expected %q but got %q for HostPoolName", v.Expected.HostPoolName, actual.HostPoolName) + } + + if actual.MsixPackageName != v.Expected.MsixPackageName { + t.Fatalf("Expected %q but got %q for MsixPackageName", v.Expected.MsixPackageName, actual.MsixPackageName) + } + + } +} + +func TestSegmentsForMsixPackageId(t *testing.T) { + segments := MsixPackageId{}.Segments() + if len(segments) == 0 { + t.Fatalf("MsixPackageId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/method_createorupdate.go b/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/method_createorupdate.go new file mode 100644 index 00000000000..c5a9487907b --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/method_createorupdate.go @@ -0,0 +1,58 @@ +package msixpackage + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MSIXPackage +} + +// CreateOrUpdate ... +func (c MSIXPackageClient) CreateOrUpdate(ctx context.Context, id MsixPackageId, input MSIXPackage) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model MSIXPackage + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/method_delete.go b/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/method_delete.go new file mode 100644 index 00000000000..c457b9742cd --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/method_delete.go @@ -0,0 +1,47 @@ +package msixpackage + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c MSIXPackageClient) Delete(ctx context.Context, id MsixPackageId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/method_get.go b/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/method_get.go new file mode 100644 index 00000000000..5fe6bb9175f --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/method_get.go @@ -0,0 +1,53 @@ +package msixpackage + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *MSIXPackage +} + +// Get ... +func (c MSIXPackageClient) Get(ctx context.Context, id MsixPackageId) (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 MSIXPackage + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/method_list.go b/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/method_list.go new file mode 100644 index 00000000000..99b04eab71f --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/method_list.go @@ -0,0 +1,142 @@ +package msixpackage + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]MSIXPackage +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []MSIXPackage +} + +type ListOperationOptions struct { + InitialSkip *int64 + IsDescending *bool + PageSize *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.InitialSkip != nil { + out.Append("initialSkip", fmt.Sprintf("%v", *o.InitialSkip)) + } + if o.IsDescending != nil { + out.Append("isDescending", fmt.Sprintf("%v", *o.IsDescending)) + } + if o.PageSize != nil { + out.Append("pageSize", fmt.Sprintf("%v", *o.PageSize)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c MSIXPackageClient) List(ctx context.Context, id HostPoolId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/msixPackages", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]MSIXPackage `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c MSIXPackageClient) ListComplete(ctx context.Context, id HostPoolId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, MSIXPackageOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c MSIXPackageClient) ListCompleteMatchingPredicate(ctx context.Context, id HostPoolId, options ListOperationOptions, predicate MSIXPackageOperationPredicate) (result ListCompleteResult, err error) { + items := make([]MSIXPackage, 0) + + resp, err := c.List(ctx, id, options) + 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 = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/method_update.go b/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/method_update.go new file mode 100644 index 00000000000..21ff1e3a75b --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/method_update.go @@ -0,0 +1,57 @@ +package msixpackage + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MSIXPackage +} + +// Update ... +func (c MSIXPackageClient) Update(ctx context.Context, id MsixPackageId, input MSIXPackagePatch) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model MSIXPackage + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/model_msixpackage.go b/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/model_msixpackage.go new file mode 100644 index 00000000000..a7059e786c9 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/model_msixpackage.go @@ -0,0 +1,16 @@ +package msixpackage + +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 MSIXPackage struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties MSIXPackageProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/model_msixpackageapplications.go b/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/model_msixpackageapplications.go new file mode 100644 index 00000000000..0496360e8a7 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/model_msixpackageapplications.go @@ -0,0 +1,14 @@ +package msixpackage + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MsixPackageApplications struct { + AppId *string `json:"appId,omitempty"` + AppUserModelID *string `json:"appUserModelID,omitempty"` + Description *string `json:"description,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + IconImageName *string `json:"iconImageName,omitempty"` + RawIcon *string `json:"rawIcon,omitempty"` + RawPng *string `json:"rawPng,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/model_msixpackagedependencies.go b/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/model_msixpackagedependencies.go new file mode 100644 index 00000000000..c61fd291e93 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/model_msixpackagedependencies.go @@ -0,0 +1,10 @@ +package msixpackage + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MsixPackageDependencies struct { + DependencyName *string `json:"dependencyName,omitempty"` + MinVersion *string `json:"minVersion,omitempty"` + Publisher *string `json:"publisher,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/model_msixpackagepatch.go b/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/model_msixpackagepatch.go new file mode 100644 index 00000000000..823ed922030 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/model_msixpackagepatch.go @@ -0,0 +1,16 @@ +package msixpackage + +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 MSIXPackagePatch struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *MSIXPackagePatchProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/model_msixpackagepatchproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/model_msixpackagepatchproperties.go new file mode 100644 index 00000000000..3cef321c214 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/model_msixpackagepatchproperties.go @@ -0,0 +1,10 @@ +package msixpackage + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MSIXPackagePatchProperties struct { + DisplayName *string `json:"displayName,omitempty"` + IsActive *bool `json:"isActive,omitempty"` + IsRegularRegistration *bool `json:"isRegularRegistration,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/model_msixpackageproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/model_msixpackageproperties.go new file mode 100644 index 00000000000..92b3d2ccd51 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/model_msixpackageproperties.go @@ -0,0 +1,36 @@ +package msixpackage + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MSIXPackageProperties struct { + DisplayName *string `json:"displayName,omitempty"` + ImagePath *string `json:"imagePath,omitempty"` + IsActive *bool `json:"isActive,omitempty"` + IsRegularRegistration *bool `json:"isRegularRegistration,omitempty"` + LastUpdated *string `json:"lastUpdated,omitempty"` + PackageApplications *[]MsixPackageApplications `json:"packageApplications,omitempty"` + PackageDependencies *[]MsixPackageDependencies `json:"packageDependencies,omitempty"` + PackageFamilyName *string `json:"packageFamilyName,omitempty"` + PackageName *string `json:"packageName,omitempty"` + PackageRelativePath *string `json:"packageRelativePath,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *MSIXPackageProperties) GetLastUpdatedAsTime() (*time.Time, error) { + if o.LastUpdated == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastUpdated, "2006-01-02T15:04:05Z07:00") +} + +func (o *MSIXPackageProperties) SetLastUpdatedAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastUpdated = &formatted +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/predicates.go b/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/predicates.go new file mode 100644 index 00000000000..ac7727901eb --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/predicates.go @@ -0,0 +1,27 @@ +package msixpackage + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MSIXPackageOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p MSIXPackageOperationPredicate) Matches(input MSIXPackage) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/version.go b/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/version.go new file mode 100644 index 00000000000..01e17eabc29 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/msixpackage/version.go @@ -0,0 +1,10 @@ +package msixpackage + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-08-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/msixpackage/2024-04-08-preview" +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/README.md b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/README.md new file mode 100644 index 00000000000..92338831157 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/README.md @@ -0,0 +1,194 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink` Documentation + +The `privatelink` SDK allows for interaction with Azure Resource Manager `desktopvirtualization` (API Version `2024-04-08-preview`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink" +``` + + +### Client Initialization + +```go +client := privatelink.NewPrivateLinkClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PrivateLinkClient.PrivateEndpointConnectionsDeleteByHostPool` + +```go +ctx := context.TODO() +id := privatelink.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName", "privateEndpointConnectionName") + +read, err := client.PrivateEndpointConnectionsDeleteByHostPool(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PrivateLinkClient.PrivateEndpointConnectionsDeleteByWorkspace` + +```go +ctx := context.TODO() +id := privatelink.NewWorkspacePrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "privateEndpointConnectionName") + +read, err := client.PrivateEndpointConnectionsDeleteByWorkspace(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PrivateLinkClient.PrivateEndpointConnectionsGetByHostPool` + +```go +ctx := context.TODO() +id := privatelink.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName", "privateEndpointConnectionName") + +read, err := client.PrivateEndpointConnectionsGetByHostPool(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PrivateLinkClient.PrivateEndpointConnectionsGetByWorkspace` + +```go +ctx := context.TODO() +id := privatelink.NewWorkspacePrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "privateEndpointConnectionName") + +read, err := client.PrivateEndpointConnectionsGetByWorkspace(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PrivateLinkClient.PrivateEndpointConnectionsListByHostPool` + +```go +ctx := context.TODO() +id := privatelink.NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName") + +// alternatively `client.PrivateEndpointConnectionsListByHostPool(ctx, id, privatelink.DefaultPrivateEndpointConnectionsListByHostPoolOperationOptions())` can be used to do batched pagination +items, err := client.PrivateEndpointConnectionsListByHostPoolComplete(ctx, id, privatelink.DefaultPrivateEndpointConnectionsListByHostPoolOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PrivateLinkClient.PrivateEndpointConnectionsListByWorkspace` + +```go +ctx := context.TODO() +id := privatelink.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +// alternatively `client.PrivateEndpointConnectionsListByWorkspace(ctx, id)` can be used to do batched pagination +items, err := client.PrivateEndpointConnectionsListByWorkspaceComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PrivateLinkClient.PrivateEndpointConnectionsUpdateByHostPool` + +```go +ctx := context.TODO() +id := privatelink.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName", "privateEndpointConnectionName") + +payload := privatelink.PrivateEndpointConnection{ + // ... +} + + +read, err := client.PrivateEndpointConnectionsUpdateByHostPool(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PrivateLinkClient.PrivateEndpointConnectionsUpdateByWorkspace` + +```go +ctx := context.TODO() +id := privatelink.NewWorkspacePrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "privateEndpointConnectionName") + +payload := privatelink.PrivateEndpointConnection{ + // ... +} + + +read, err := client.PrivateEndpointConnectionsUpdateByWorkspace(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PrivateLinkClient.ResourcesListByHostPool` + +```go +ctx := context.TODO() +id := privatelink.NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName") + +// alternatively `client.ResourcesListByHostPool(ctx, id, privatelink.DefaultResourcesListByHostPoolOperationOptions())` can be used to do batched pagination +items, err := client.ResourcesListByHostPoolComplete(ctx, id, privatelink.DefaultResourcesListByHostPoolOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PrivateLinkClient.ResourcesListByWorkspace` + +```go +ctx := context.TODO() +id := privatelink.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +// alternatively `client.ResourcesListByWorkspace(ctx, id, privatelink.DefaultResourcesListByWorkspaceOperationOptions())` can be used to do batched pagination +items, err := client.ResourcesListByWorkspaceComplete(ctx, id, privatelink.DefaultResourcesListByWorkspaceOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/client.go b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/client.go new file mode 100644 index 00000000000..84b106c4ad6 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/client.go @@ -0,0 +1,26 @@ +package privatelink + +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 PrivateLinkClient struct { + Client *resourcemanager.Client +} + +func NewPrivateLinkClientWithBaseURI(sdkApi sdkEnv.Api) (*PrivateLinkClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "privatelink", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PrivateLinkClient: %+v", err) + } + + return &PrivateLinkClient{ + Client: client, + }, nil +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/constants.go b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/constants.go new file mode 100644 index 00000000000..54d2f66e122 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/constants.go @@ -0,0 +1,101 @@ +package privatelink + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProvisioningState string + +const ( + PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" + PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" + PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" + PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" +) + +func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { + return []string{ + string(PrivateEndpointConnectionProvisioningStateCreating), + string(PrivateEndpointConnectionProvisioningStateDeleting), + string(PrivateEndpointConnectionProvisioningStateFailed), + string(PrivateEndpointConnectionProvisioningStateSucceeded), + } +} + +func (s *PrivateEndpointConnectionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointConnectionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { + vals := map[string]PrivateEndpointConnectionProvisioningState{ + "creating": PrivateEndpointConnectionProvisioningStateCreating, + "deleting": PrivateEndpointConnectionProvisioningStateDeleting, + "failed": PrivateEndpointConnectionProvisioningStateFailed, + "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointConnectionProvisioningState(input) + return &out, nil +} + +type PrivateEndpointServiceConnectionStatus string + +const ( + PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" + PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" + PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" +) + +func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { + return []string{ + string(PrivateEndpointServiceConnectionStatusApproved), + string(PrivateEndpointServiceConnectionStatusPending), + string(PrivateEndpointServiceConnectionStatusRejected), + } +} + +func (s *PrivateEndpointServiceConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointServiceConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { + vals := map[string]PrivateEndpointServiceConnectionStatus{ + "approved": PrivateEndpointServiceConnectionStatusApproved, + "pending": PrivateEndpointServiceConnectionStatusPending, + "rejected": PrivateEndpointServiceConnectionStatusRejected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointServiceConnectionStatus(input) + return &out, nil +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/id_hostpool.go b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/id_hostpool.go new file mode 100644 index 00000000000..4ded39e138f --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/id_hostpool.go @@ -0,0 +1,130 @@ +package privatelink + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&HostPoolId{}) +} + +var _ resourceids.ResourceId = &HostPoolId{} + +// HostPoolId is a struct representing the Resource ID for a Host Pool +type HostPoolId struct { + SubscriptionId string + ResourceGroupName string + HostPoolName string +} + +// NewHostPoolID returns a new HostPoolId struct +func NewHostPoolID(subscriptionId string, resourceGroupName string, hostPoolName string) HostPoolId { + return HostPoolId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + HostPoolName: hostPoolName, + } +} + +// ParseHostPoolID parses 'input' into a HostPoolId +func ParseHostPoolID(input string) (*HostPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostPoolId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostPoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseHostPoolIDInsensitively parses 'input' case-insensitively into a HostPoolId +// note: this method should only be used for API response data and not user input +func ParseHostPoolIDInsensitively(input string) (*HostPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostPoolId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostPoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *HostPoolId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.HostPoolName, ok = input.Parsed["hostPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hostPoolName", input) + } + + return nil +} + +// ValidateHostPoolID checks that 'input' can be parsed as a Host Pool ID +func ValidateHostPoolID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseHostPoolID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Host Pool ID +func (id HostPoolId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DesktopVirtualization/hostPools/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.HostPoolName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Host Pool ID +func (id HostPoolId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDesktopVirtualization", "Microsoft.DesktopVirtualization", "Microsoft.DesktopVirtualization"), + resourceids.StaticSegment("staticHostPools", "hostPools", "hostPools"), + resourceids.UserSpecifiedSegment("hostPoolName", "hostPoolName"), + } +} + +// String returns a human-readable description of this Host Pool ID +func (id HostPoolId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Host Pool Name: %q", id.HostPoolName), + } + return fmt.Sprintf("Host Pool (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/id_hostpool_test.go b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/id_hostpool_test.go new file mode 100644 index 00000000000..eb922d12623 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/id_hostpool_test.go @@ -0,0 +1,282 @@ +package privatelink + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &HostPoolId{} + +func TestNewHostPoolID(t *testing.T) { + id := NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.HostPoolName != "hostPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'HostPoolName'", id.HostPoolName, "hostPoolName") + } +} + +func TestFormatHostPoolID(t *testing.T) { + actual := NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseHostPoolID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostPoolId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName", + Expected: &HostPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostPoolName: "hostPoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostPoolID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostPoolName != v.Expected.HostPoolName { + t.Fatalf("Expected %q but got %q for HostPoolName", v.Expected.HostPoolName, actual.HostPoolName) + } + + } +} + +func TestParseHostPoolIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostPoolId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName", + Expected: &HostPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostPoolName: "hostPoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs/hOsTpOoLnAmE", + Expected: &HostPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + HostPoolName: "hOsTpOoLnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs/hOsTpOoLnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostPoolIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostPoolName != v.Expected.HostPoolName { + t.Fatalf("Expected %q but got %q for HostPoolName", v.Expected.HostPoolName, actual.HostPoolName) + } + + } +} + +func TestSegmentsForHostPoolId(t *testing.T) { + segments := HostPoolId{}.Segments() + if len(segments) == 0 { + t.Fatalf("HostPoolId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/id_privateendpointconnection.go b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/id_privateendpointconnection.go new file mode 100644 index 00000000000..ccfff7107d2 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/id_privateendpointconnection.go @@ -0,0 +1,139 @@ +package privatelink + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) 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 + HostPoolName string + PrivateEndpointConnectionName string +} + +// NewPrivateEndpointConnectionID returns a new PrivateEndpointConnectionId struct +func NewPrivateEndpointConnectionID(subscriptionId string, resourceGroupName string, hostPoolName string, privateEndpointConnectionName string) PrivateEndpointConnectionId { + return PrivateEndpointConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + HostPoolName: hostPoolName, + 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.HostPoolName, ok = input.Parsed["hostPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hostPoolName", 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.DesktopVirtualization/hostPools/%s/privateEndpointConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.HostPoolName, 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("staticMicrosoftDesktopVirtualization", "Microsoft.DesktopVirtualization", "Microsoft.DesktopVirtualization"), + resourceids.StaticSegment("staticHostPools", "hostPools", "hostPools"), + resourceids.UserSpecifiedSegment("hostPoolName", "hostPoolName"), + resourceids.StaticSegment("staticPrivateEndpointConnections", "privateEndpointConnections", "privateEndpointConnections"), + resourceids.UserSpecifiedSegment("privateEndpointConnectionName", "privateEndpointConnectionName"), + } +} + +// 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("Host Pool Name: %q", id.HostPoolName), + 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/desktopvirtualization/2024-04-08-preview/privatelink/id_privateendpointconnection_test.go b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/id_privateendpointconnection_test.go new file mode 100644 index 00000000000..397321d8c59 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/id_privateendpointconnection_test.go @@ -0,0 +1,327 @@ +package privatelink + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (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", "hostPoolName", "privateEndpointConnectionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.HostPoolName != "hostPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'HostPoolName'", id.HostPoolName, "hostPoolName") + } + + if id.PrivateEndpointConnectionName != "privateEndpointConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'PrivateEndpointConnectionName'", id.PrivateEndpointConnectionName, "privateEndpointConnectionName") + } +} + +func TestFormatPrivateEndpointConnectionID(t *testing.T) { + actual := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName", "privateEndpointConnectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/privateEndpointConnections/privateEndpointConnectionName" + 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.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/privateEndpointConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/privateEndpointConnections/privateEndpointConnectionName", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostPoolName: "hostPoolName", + PrivateEndpointConnectionName: "privateEndpointConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/privateEndpointConnections/privateEndpointConnectionName/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.HostPoolName != v.Expected.HostPoolName { + t.Fatalf("Expected %q but got %q for HostPoolName", v.Expected.HostPoolName, actual.HostPoolName) + } + + 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.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs/hOsTpOoLnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/privateEndpointConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs/hOsTpOoLnAmE/pRiVaTeEnDpOiNtCoNnEcTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/privateEndpointConnections/privateEndpointConnectionName", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostPoolName: "hostPoolName", + PrivateEndpointConnectionName: "privateEndpointConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/privateEndpointConnections/privateEndpointConnectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs/hOsTpOoLnAmE/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnNaMe", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + HostPoolName: "hOsTpOoLnAmE", + PrivateEndpointConnectionName: "pRiVaTeEnDpOiNtCoNnEcTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs/hOsTpOoLnAmE/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnNaMe/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.HostPoolName != v.Expected.HostPoolName { + t.Fatalf("Expected %q but got %q for HostPoolName", v.Expected.HostPoolName, actual.HostPoolName) + } + + 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/desktopvirtualization/2024-04-08-preview/privatelink/id_workspace.go b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/id_workspace.go new file mode 100644 index 00000000000..17ba9726566 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/id_workspace.go @@ -0,0 +1,130 @@ +package privatelink + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&WorkspaceId{}) +} + +var _ resourceids.ResourceId = &WorkspaceId{} + +// WorkspaceId is a struct representing the Resource ID for a Workspace +type WorkspaceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string +} + +// NewWorkspaceID returns a new WorkspaceId struct +func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + } +} + +// ParseWorkspaceID parses 'input' into a WorkspaceId +func ParseWorkspaceID(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + return nil +} + +// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID +func ValidateWorkspaceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace ID +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DesktopVirtualization/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace ID +func (id WorkspaceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDesktopVirtualization", "Microsoft.DesktopVirtualization", "Microsoft.DesktopVirtualization"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + } +} + +// String returns a human-readable description of this Workspace ID +func (id WorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + } + return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/id_workspace_test.go b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/id_workspace_test.go new file mode 100644 index 00000000000..025f9d24ecd --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/id_workspace_test.go @@ -0,0 +1,282 @@ +package privatelink + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &WorkspaceId{} + +func TestNewWorkspaceID(t *testing.T) { + id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } +} + +func TestFormatWorkspaceID(t *testing.T) { + actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/workspaces/workspaceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/workspaces/workspaceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestParseWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/workspaces/workspaceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/wOrKsPaCeS/wOrKsPaCeNaMe", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/wOrKsPaCeS/wOrKsPaCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestSegmentsForWorkspaceId(t *testing.T) { + segments := WorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspaceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/id_workspaceprivateendpointconnection.go b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/id_workspaceprivateendpointconnection.go new file mode 100644 index 00000000000..29c67d1df79 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/id_workspaceprivateendpointconnection.go @@ -0,0 +1,139 @@ +package privatelink + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&WorkspacePrivateEndpointConnectionId{}) +} + +var _ resourceids.ResourceId = &WorkspacePrivateEndpointConnectionId{} + +// WorkspacePrivateEndpointConnectionId is a struct representing the Resource ID for a Workspace Private Endpoint Connection +type WorkspacePrivateEndpointConnectionId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + PrivateEndpointConnectionName string +} + +// NewWorkspacePrivateEndpointConnectionID returns a new WorkspacePrivateEndpointConnectionId struct +func NewWorkspacePrivateEndpointConnectionID(subscriptionId string, resourceGroupName string, workspaceName string, privateEndpointConnectionName string) WorkspacePrivateEndpointConnectionId { + return WorkspacePrivateEndpointConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + PrivateEndpointConnectionName: privateEndpointConnectionName, + } +} + +// ParseWorkspacePrivateEndpointConnectionID parses 'input' into a WorkspacePrivateEndpointConnectionId +func ParseWorkspacePrivateEndpointConnectionID(input string) (*WorkspacePrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspacePrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspacePrivateEndpointConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkspacePrivateEndpointConnectionIDInsensitively parses 'input' case-insensitively into a WorkspacePrivateEndpointConnectionId +// note: this method should only be used for API response data and not user input +func ParseWorkspacePrivateEndpointConnectionIDInsensitively(input string) (*WorkspacePrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspacePrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspacePrivateEndpointConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspacePrivateEndpointConnectionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.PrivateEndpointConnectionName, ok = input.Parsed["privateEndpointConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "privateEndpointConnectionName", input) + } + + return nil +} + +// ValidateWorkspacePrivateEndpointConnectionID checks that 'input' can be parsed as a Workspace Private Endpoint Connection ID +func ValidateWorkspacePrivateEndpointConnectionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseWorkspacePrivateEndpointConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace Private Endpoint Connection ID +func (id WorkspacePrivateEndpointConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DesktopVirtualization/workspaces/%s/privateEndpointConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.PrivateEndpointConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace Private Endpoint Connection ID +func (id WorkspacePrivateEndpointConnectionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDesktopVirtualization", "Microsoft.DesktopVirtualization", "Microsoft.DesktopVirtualization"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticPrivateEndpointConnections", "privateEndpointConnections", "privateEndpointConnections"), + resourceids.UserSpecifiedSegment("privateEndpointConnectionName", "privateEndpointConnectionName"), + } +} + +// String returns a human-readable description of this Workspace Private Endpoint Connection ID +func (id WorkspacePrivateEndpointConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Private Endpoint Connection Name: %q", id.PrivateEndpointConnectionName), + } + return fmt.Sprintf("Workspace Private Endpoint Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/id_workspaceprivateendpointconnection_test.go b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/id_workspaceprivateendpointconnection_test.go new file mode 100644 index 00000000000..43307b5043c --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/id_workspaceprivateendpointconnection_test.go @@ -0,0 +1,327 @@ +package privatelink + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &WorkspacePrivateEndpointConnectionId{} + +func TestNewWorkspacePrivateEndpointConnectionID(t *testing.T) { + id := NewWorkspacePrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "privateEndpointConnectionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.PrivateEndpointConnectionName != "privateEndpointConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'PrivateEndpointConnectionName'", id.PrivateEndpointConnectionName, "privateEndpointConnectionName") + } +} + +func TestFormatWorkspacePrivateEndpointConnectionID(t *testing.T) { + actual := NewWorkspacePrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "privateEndpointConnectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/workspaces/workspaceName/privateEndpointConnections/privateEndpointConnectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspacePrivateEndpointConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspacePrivateEndpointConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/workspaces/workspaceName/privateEndpointConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/workspaces/workspaceName/privateEndpointConnections/privateEndpointConnectionName", + Expected: &WorkspacePrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + PrivateEndpointConnectionName: "privateEndpointConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/workspaces/workspaceName/privateEndpointConnections/privateEndpointConnectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspacePrivateEndpointConnectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestParseWorkspacePrivateEndpointConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspacePrivateEndpointConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/workspaces/workspaceName/privateEndpointConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/wOrKsPaCeS/wOrKsPaCeNaMe/pRiVaTeEnDpOiNtCoNnEcTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/workspaces/workspaceName/privateEndpointConnections/privateEndpointConnectionName", + Expected: &WorkspacePrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + PrivateEndpointConnectionName: "privateEndpointConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/workspaces/workspaceName/privateEndpointConnections/privateEndpointConnectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/wOrKsPaCeS/wOrKsPaCeNaMe/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnNaMe", + Expected: &WorkspacePrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + PrivateEndpointConnectionName: "pRiVaTeEnDpOiNtCoNnEcTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/wOrKsPaCeS/wOrKsPaCeNaMe/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspacePrivateEndpointConnectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestSegmentsForWorkspacePrivateEndpointConnectionId(t *testing.T) { + segments := WorkspacePrivateEndpointConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspacePrivateEndpointConnectionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/method_privateendpointconnectionsdeletebyhostpool.go b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/method_privateendpointconnectionsdeletebyhostpool.go new file mode 100644 index 00000000000..4e176ed7a4a --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/method_privateendpointconnectionsdeletebyhostpool.go @@ -0,0 +1,47 @@ +package privatelink + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionsDeleteByHostPoolOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// PrivateEndpointConnectionsDeleteByHostPool ... +func (c PrivateLinkClient) PrivateEndpointConnectionsDeleteByHostPool(ctx context.Context, id PrivateEndpointConnectionId) (result PrivateEndpointConnectionsDeleteByHostPoolOperationResponse, 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/desktopvirtualization/2024-04-08-preview/privatelink/method_privateendpointconnectionsdeletebyworkspace.go b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/method_privateendpointconnectionsdeletebyworkspace.go new file mode 100644 index 00000000000..dbac08fb6c1 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/method_privateendpointconnectionsdeletebyworkspace.go @@ -0,0 +1,47 @@ +package privatelink + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionsDeleteByWorkspaceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// PrivateEndpointConnectionsDeleteByWorkspace ... +func (c PrivateLinkClient) PrivateEndpointConnectionsDeleteByWorkspace(ctx context.Context, id WorkspacePrivateEndpointConnectionId) (result PrivateEndpointConnectionsDeleteByWorkspaceOperationResponse, 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/desktopvirtualization/2024-04-08-preview/privatelink/method_privateendpointconnectionsgetbyhostpool.go b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/method_privateendpointconnectionsgetbyhostpool.go new file mode 100644 index 00000000000..678782e613f --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/method_privateendpointconnectionsgetbyhostpool.go @@ -0,0 +1,53 @@ +package privatelink + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionsGetByHostPoolOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnection +} + +// PrivateEndpointConnectionsGetByHostPool ... +func (c PrivateLinkClient) PrivateEndpointConnectionsGetByHostPool(ctx context.Context, id PrivateEndpointConnectionId) (result PrivateEndpointConnectionsGetByHostPoolOperationResponse, 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/desktopvirtualization/2024-04-08-preview/privatelink/method_privateendpointconnectionsgetbyworkspace.go b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/method_privateendpointconnectionsgetbyworkspace.go new file mode 100644 index 00000000000..07e82e2c773 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/method_privateendpointconnectionsgetbyworkspace.go @@ -0,0 +1,53 @@ +package privatelink + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionsGetByWorkspaceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnection +} + +// PrivateEndpointConnectionsGetByWorkspace ... +func (c PrivateLinkClient) PrivateEndpointConnectionsGetByWorkspace(ctx context.Context, id WorkspacePrivateEndpointConnectionId) (result PrivateEndpointConnectionsGetByWorkspaceOperationResponse, 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/desktopvirtualization/2024-04-08-preview/privatelink/method_privateendpointconnectionslistbyhostpool.go b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/method_privateendpointconnectionslistbyhostpool.go new file mode 100644 index 00000000000..50a9d10ac8b --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/method_privateendpointconnectionslistbyhostpool.go @@ -0,0 +1,142 @@ +package privatelink + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionsListByHostPoolOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PrivateEndpointConnection +} + +type PrivateEndpointConnectionsListByHostPoolCompleteResult struct { + LatestHttpResponse *http.Response + Items []PrivateEndpointConnection +} + +type PrivateEndpointConnectionsListByHostPoolOperationOptions struct { + InitialSkip *int64 + IsDescending *bool + PageSize *int64 +} + +func DefaultPrivateEndpointConnectionsListByHostPoolOperationOptions() PrivateEndpointConnectionsListByHostPoolOperationOptions { + return PrivateEndpointConnectionsListByHostPoolOperationOptions{} +} + +func (o PrivateEndpointConnectionsListByHostPoolOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o PrivateEndpointConnectionsListByHostPoolOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o PrivateEndpointConnectionsListByHostPoolOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.InitialSkip != nil { + out.Append("initialSkip", fmt.Sprintf("%v", *o.InitialSkip)) + } + if o.IsDescending != nil { + out.Append("isDescending", fmt.Sprintf("%v", *o.IsDescending)) + } + if o.PageSize != nil { + out.Append("pageSize", fmt.Sprintf("%v", *o.PageSize)) + } + return &out +} + +type PrivateEndpointConnectionsListByHostPoolCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *PrivateEndpointConnectionsListByHostPoolCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// PrivateEndpointConnectionsListByHostPool ... +func (c PrivateLinkClient) PrivateEndpointConnectionsListByHostPool(ctx context.Context, id HostPoolId, options PrivateEndpointConnectionsListByHostPoolOperationOptions) (result PrivateEndpointConnectionsListByHostPoolOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &PrivateEndpointConnectionsListByHostPoolCustomPager{}, + 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 +} + +// PrivateEndpointConnectionsListByHostPoolComplete retrieves all the results into a single object +func (c PrivateLinkClient) PrivateEndpointConnectionsListByHostPoolComplete(ctx context.Context, id HostPoolId, options PrivateEndpointConnectionsListByHostPoolOperationOptions) (PrivateEndpointConnectionsListByHostPoolCompleteResult, error) { + return c.PrivateEndpointConnectionsListByHostPoolCompleteMatchingPredicate(ctx, id, options, PrivateEndpointConnectionOperationPredicate{}) +} + +// PrivateEndpointConnectionsListByHostPoolCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PrivateLinkClient) PrivateEndpointConnectionsListByHostPoolCompleteMatchingPredicate(ctx context.Context, id HostPoolId, options PrivateEndpointConnectionsListByHostPoolOperationOptions, predicate PrivateEndpointConnectionOperationPredicate) (result PrivateEndpointConnectionsListByHostPoolCompleteResult, err error) { + items := make([]PrivateEndpointConnection, 0) + + resp, err := c.PrivateEndpointConnectionsListByHostPool(ctx, id, options) + 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 = PrivateEndpointConnectionsListByHostPoolCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/method_privateendpointconnectionslistbyworkspace.go b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/method_privateendpointconnectionslistbyworkspace.go new file mode 100644 index 00000000000..96db3f78bc9 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/method_privateendpointconnectionslistbyworkspace.go @@ -0,0 +1,105 @@ +package privatelink + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionsListByWorkspaceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PrivateEndpointConnection +} + +type PrivateEndpointConnectionsListByWorkspaceCompleteResult struct { + LatestHttpResponse *http.Response + Items []PrivateEndpointConnection +} + +type PrivateEndpointConnectionsListByWorkspaceCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *PrivateEndpointConnectionsListByWorkspaceCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// PrivateEndpointConnectionsListByWorkspace ... +func (c PrivateLinkClient) PrivateEndpointConnectionsListByWorkspace(ctx context.Context, id WorkspaceId) (result PrivateEndpointConnectionsListByWorkspaceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &PrivateEndpointConnectionsListByWorkspaceCustomPager{}, + 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 +} + +// PrivateEndpointConnectionsListByWorkspaceComplete retrieves all the results into a single object +func (c PrivateLinkClient) PrivateEndpointConnectionsListByWorkspaceComplete(ctx context.Context, id WorkspaceId) (PrivateEndpointConnectionsListByWorkspaceCompleteResult, error) { + return c.PrivateEndpointConnectionsListByWorkspaceCompleteMatchingPredicate(ctx, id, PrivateEndpointConnectionOperationPredicate{}) +} + +// PrivateEndpointConnectionsListByWorkspaceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PrivateLinkClient) PrivateEndpointConnectionsListByWorkspaceCompleteMatchingPredicate(ctx context.Context, id WorkspaceId, predicate PrivateEndpointConnectionOperationPredicate) (result PrivateEndpointConnectionsListByWorkspaceCompleteResult, err error) { + items := make([]PrivateEndpointConnection, 0) + + resp, err := c.PrivateEndpointConnectionsListByWorkspace(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 = PrivateEndpointConnectionsListByWorkspaceCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/method_privateendpointconnectionsupdatebyhostpool.go b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/method_privateendpointconnectionsupdatebyhostpool.go new file mode 100644 index 00000000000..c525f8db572 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/method_privateendpointconnectionsupdatebyhostpool.go @@ -0,0 +1,57 @@ +package privatelink + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionsUpdateByHostPoolOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnection +} + +// PrivateEndpointConnectionsUpdateByHostPool ... +func (c PrivateLinkClient) PrivateEndpointConnectionsUpdateByHostPool(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) (result PrivateEndpointConnectionsUpdateByHostPoolOperationResponse, 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/desktopvirtualization/2024-04-08-preview/privatelink/method_privateendpointconnectionsupdatebyworkspace.go b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/method_privateendpointconnectionsupdatebyworkspace.go new file mode 100644 index 00000000000..1c30a554f7d --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/method_privateendpointconnectionsupdatebyworkspace.go @@ -0,0 +1,57 @@ +package privatelink + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionsUpdateByWorkspaceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnection +} + +// PrivateEndpointConnectionsUpdateByWorkspace ... +func (c PrivateLinkClient) PrivateEndpointConnectionsUpdateByWorkspace(ctx context.Context, id WorkspacePrivateEndpointConnectionId, input PrivateEndpointConnection) (result PrivateEndpointConnectionsUpdateByWorkspaceOperationResponse, 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/desktopvirtualization/2024-04-08-preview/privatelink/method_resourceslistbyhostpool.go b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/method_resourceslistbyhostpool.go new file mode 100644 index 00000000000..23d011936d2 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/method_resourceslistbyhostpool.go @@ -0,0 +1,142 @@ +package privatelink + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourcesListByHostPoolOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PrivateLinkResource +} + +type ResourcesListByHostPoolCompleteResult struct { + LatestHttpResponse *http.Response + Items []PrivateLinkResource +} + +type ResourcesListByHostPoolOperationOptions struct { + InitialSkip *int64 + IsDescending *bool + PageSize *int64 +} + +func DefaultResourcesListByHostPoolOperationOptions() ResourcesListByHostPoolOperationOptions { + return ResourcesListByHostPoolOperationOptions{} +} + +func (o ResourcesListByHostPoolOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ResourcesListByHostPoolOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ResourcesListByHostPoolOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.InitialSkip != nil { + out.Append("initialSkip", fmt.Sprintf("%v", *o.InitialSkip)) + } + if o.IsDescending != nil { + out.Append("isDescending", fmt.Sprintf("%v", *o.IsDescending)) + } + if o.PageSize != nil { + out.Append("pageSize", fmt.Sprintf("%v", *o.PageSize)) + } + return &out +} + +type ResourcesListByHostPoolCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ResourcesListByHostPoolCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ResourcesListByHostPool ... +func (c PrivateLinkClient) ResourcesListByHostPool(ctx context.Context, id HostPoolId, options ResourcesListByHostPoolOperationOptions) (result ResourcesListByHostPoolOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ResourcesListByHostPoolCustomPager{}, + 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 +} + +// ResourcesListByHostPoolComplete retrieves all the results into a single object +func (c PrivateLinkClient) ResourcesListByHostPoolComplete(ctx context.Context, id HostPoolId, options ResourcesListByHostPoolOperationOptions) (ResourcesListByHostPoolCompleteResult, error) { + return c.ResourcesListByHostPoolCompleteMatchingPredicate(ctx, id, options, PrivateLinkResourceOperationPredicate{}) +} + +// ResourcesListByHostPoolCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PrivateLinkClient) ResourcesListByHostPoolCompleteMatchingPredicate(ctx context.Context, id HostPoolId, options ResourcesListByHostPoolOperationOptions, predicate PrivateLinkResourceOperationPredicate) (result ResourcesListByHostPoolCompleteResult, err error) { + items := make([]PrivateLinkResource, 0) + + resp, err := c.ResourcesListByHostPool(ctx, id, options) + 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 = ResourcesListByHostPoolCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/method_resourceslistbyworkspace.go b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/method_resourceslistbyworkspace.go new file mode 100644 index 00000000000..bd078b01fc7 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/method_resourceslistbyworkspace.go @@ -0,0 +1,142 @@ +package privatelink + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourcesListByWorkspaceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PrivateLinkResource +} + +type ResourcesListByWorkspaceCompleteResult struct { + LatestHttpResponse *http.Response + Items []PrivateLinkResource +} + +type ResourcesListByWorkspaceOperationOptions struct { + InitialSkip *int64 + IsDescending *bool + PageSize *int64 +} + +func DefaultResourcesListByWorkspaceOperationOptions() ResourcesListByWorkspaceOperationOptions { + return ResourcesListByWorkspaceOperationOptions{} +} + +func (o ResourcesListByWorkspaceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ResourcesListByWorkspaceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ResourcesListByWorkspaceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.InitialSkip != nil { + out.Append("initialSkip", fmt.Sprintf("%v", *o.InitialSkip)) + } + if o.IsDescending != nil { + out.Append("isDescending", fmt.Sprintf("%v", *o.IsDescending)) + } + if o.PageSize != nil { + out.Append("pageSize", fmt.Sprintf("%v", *o.PageSize)) + } + return &out +} + +type ResourcesListByWorkspaceCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ResourcesListByWorkspaceCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ResourcesListByWorkspace ... +func (c PrivateLinkClient) ResourcesListByWorkspace(ctx context.Context, id WorkspaceId, options ResourcesListByWorkspaceOperationOptions) (result ResourcesListByWorkspaceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ResourcesListByWorkspaceCustomPager{}, + 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 +} + +// ResourcesListByWorkspaceComplete retrieves all the results into a single object +func (c PrivateLinkClient) ResourcesListByWorkspaceComplete(ctx context.Context, id WorkspaceId, options ResourcesListByWorkspaceOperationOptions) (ResourcesListByWorkspaceCompleteResult, error) { + return c.ResourcesListByWorkspaceCompleteMatchingPredicate(ctx, id, options, PrivateLinkResourceOperationPredicate{}) +} + +// ResourcesListByWorkspaceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PrivateLinkClient) ResourcesListByWorkspaceCompleteMatchingPredicate(ctx context.Context, id WorkspaceId, options ResourcesListByWorkspaceOperationOptions, predicate PrivateLinkResourceOperationPredicate) (result ResourcesListByWorkspaceCompleteResult, err error) { + items := make([]PrivateLinkResource, 0) + + resp, err := c.ResourcesListByWorkspace(ctx, id, options) + 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 = ResourcesListByWorkspaceCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/model_privateendpoint.go b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/model_privateendpoint.go new file mode 100644 index 00000000000..774ed3c3a08 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/model_privateendpoint.go @@ -0,0 +1,8 @@ +package privatelink + +// 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/desktopvirtualization/2024-04-08-preview/privatelink/model_privateendpointconnection.go b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/model_privateendpointconnection.go new file mode 100644 index 00000000000..b0c3c42e22b --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/model_privateendpointconnection.go @@ -0,0 +1,16 @@ +package privatelink + +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/desktopvirtualization/2024-04-08-preview/privatelink/model_privateendpointconnectionproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..c71775f35a5 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/model_privateendpointconnectionproperties.go @@ -0,0 +1,11 @@ +package privatelink + +// 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"` + ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/model_privatelinkresource.go b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/model_privatelinkresource.go new file mode 100644 index 00000000000..252a91f6b60 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/model_privatelinkresource.go @@ -0,0 +1,16 @@ +package privatelink + +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/desktopvirtualization/2024-04-08-preview/privatelink/model_privatelinkresourceproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/model_privatelinkresourceproperties.go new file mode 100644 index 00000000000..36abe10fd9a --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/model_privatelinkresourceproperties.go @@ -0,0 +1,10 @@ +package privatelink + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourceProperties struct { + GroupId *string `json:"groupId,omitempty"` + RequiredMembers *[]string `json:"requiredMembers,omitempty"` + RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/model_privatelinkserviceconnectionstate.go b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..774b4fe4675 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package privatelink + +// 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 *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/predicates.go b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/predicates.go new file mode 100644 index 00000000000..da93da5a52f --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/predicates.go @@ -0,0 +1,50 @@ +package privatelink + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionOperationPredicate struct { + 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 +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/version.go b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/version.go new file mode 100644 index 00000000000..2c815fe16d6 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/privatelink/version.go @@ -0,0 +1,10 @@ +package privatelink + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-08-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/privatelink/2024-04-08-preview" +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/README.md b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/README.md new file mode 100644 index 00000000000..653d5d7a8a1 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/README.md @@ -0,0 +1,146 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan` Documentation + +The `scalingplan` SDK allows for interaction with Azure Resource Manager `desktopvirtualization` (API Version `2024-04-08-preview`). + +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/desktopvirtualization/2024-04-08-preview/scalingplan" +``` + + +### Client Initialization + +```go +client := scalingplan.NewScalingPlanClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ScalingPlanClient.Create` + +```go +ctx := context.TODO() +id := scalingplan.NewScalingPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "scalingPlanName") + +payload := scalingplan.ScalingPlan{ + // ... +} + + +read, err := client.Create(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ScalingPlanClient.Delete` + +```go +ctx := context.TODO() +id := scalingplan.NewScalingPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "scalingPlanName") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ScalingPlanClient.Get` + +```go +ctx := context.TODO() +id := scalingplan.NewScalingPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "scalingPlanName") + +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: `ScalingPlanClient.ListByHostPool` + +```go +ctx := context.TODO() +id := scalingplan.NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName") + +// alternatively `client.ListByHostPool(ctx, id, scalingplan.DefaultListByHostPoolOperationOptions())` can be used to do batched pagination +items, err := client.ListByHostPoolComplete(ctx, id, scalingplan.DefaultListByHostPoolOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ScalingPlanClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id, scalingplan.DefaultListByResourceGroupOperationOptions())` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id, scalingplan.DefaultListByResourceGroupOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ScalingPlanClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id, scalingplan.DefaultListBySubscriptionOperationOptions())` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id, scalingplan.DefaultListBySubscriptionOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ScalingPlanClient.Update` + +```go +ctx := context.TODO() +id := scalingplan.NewScalingPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "scalingPlanName") + +payload := scalingplan.ScalingPlanPatch{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/client.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/client.go new file mode 100644 index 00000000000..e4ef80bb2b3 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/client.go @@ -0,0 +1,26 @@ +package scalingplan + +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 ScalingPlanClient struct { + Client *resourcemanager.Client +} + +func NewScalingPlanClientWithBaseURI(sdkApi sdkEnv.Api) (*ScalingPlanClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "scalingplan", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ScalingPlanClient: %+v", err) + } + + return &ScalingPlanClient{ + Client: client, + }, nil +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/constants.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/constants.go new file mode 100644 index 00000000000..c7acaf33f9c --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/constants.go @@ -0,0 +1,236 @@ +package scalingplan + +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 DaysOfWeek string + +const ( + DaysOfWeekFriday DaysOfWeek = "Friday" + DaysOfWeekMonday DaysOfWeek = "Monday" + DaysOfWeekSaturday DaysOfWeek = "Saturday" + DaysOfWeekSunday DaysOfWeek = "Sunday" + DaysOfWeekThursday DaysOfWeek = "Thursday" + DaysOfWeekTuesday DaysOfWeek = "Tuesday" + DaysOfWeekWednesday DaysOfWeek = "Wednesday" +) + +func PossibleValuesForDaysOfWeek() []string { + return []string{ + string(DaysOfWeekFriday), + string(DaysOfWeekMonday), + string(DaysOfWeekSaturday), + string(DaysOfWeekSunday), + string(DaysOfWeekThursday), + string(DaysOfWeekTuesday), + string(DaysOfWeekWednesday), + } +} + +func (s *DaysOfWeek) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDaysOfWeek(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDaysOfWeek(input string) (*DaysOfWeek, error) { + vals := map[string]DaysOfWeek{ + "friday": DaysOfWeekFriday, + "monday": DaysOfWeekMonday, + "saturday": DaysOfWeekSaturday, + "sunday": DaysOfWeekSunday, + "thursday": DaysOfWeekThursday, + "tuesday": DaysOfWeekTuesday, + "wednesday": DaysOfWeekWednesday, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DaysOfWeek(input) + return &out, nil +} + +type ScalingHostPoolType string + +const ( + ScalingHostPoolTypePersonal ScalingHostPoolType = "Personal" + ScalingHostPoolTypePooled ScalingHostPoolType = "Pooled" +) + +func PossibleValuesForScalingHostPoolType() []string { + return []string{ + string(ScalingHostPoolTypePersonal), + string(ScalingHostPoolTypePooled), + } +} + +func (s *ScalingHostPoolType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScalingHostPoolType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScalingHostPoolType(input string) (*ScalingHostPoolType, error) { + vals := map[string]ScalingHostPoolType{ + "personal": ScalingHostPoolTypePersonal, + "pooled": ScalingHostPoolTypePooled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScalingHostPoolType(input) + return &out, nil +} + +type SessionHostLoadBalancingAlgorithm string + +const ( + SessionHostLoadBalancingAlgorithmBreadthFirst SessionHostLoadBalancingAlgorithm = "BreadthFirst" + SessionHostLoadBalancingAlgorithmDepthFirst SessionHostLoadBalancingAlgorithm = "DepthFirst" +) + +func PossibleValuesForSessionHostLoadBalancingAlgorithm() []string { + return []string{ + string(SessionHostLoadBalancingAlgorithmBreadthFirst), + string(SessionHostLoadBalancingAlgorithmDepthFirst), + } +} + +func (s *SessionHostLoadBalancingAlgorithm) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSessionHostLoadBalancingAlgorithm(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSessionHostLoadBalancingAlgorithm(input string) (*SessionHostLoadBalancingAlgorithm, error) { + vals := map[string]SessionHostLoadBalancingAlgorithm{ + "breadthfirst": SessionHostLoadBalancingAlgorithmBreadthFirst, + "depthfirst": SessionHostLoadBalancingAlgorithmDepthFirst, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SessionHostLoadBalancingAlgorithm(input) + return &out, nil +} + +type SkuTier string + +const ( + SkuTierBasic SkuTier = "Basic" + SkuTierFree SkuTier = "Free" + SkuTierPremium SkuTier = "Premium" + SkuTierStandard SkuTier = "Standard" +) + +func PossibleValuesForSkuTier() []string { + return []string{ + string(SkuTierBasic), + string(SkuTierFree), + string(SkuTierPremium), + string(SkuTierStandard), + } +} + +func (s *SkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSkuTier(input string) (*SkuTier, error) { + vals := map[string]SkuTier{ + "basic": SkuTierBasic, + "free": SkuTierFree, + "premium": SkuTierPremium, + "standard": SkuTierStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SkuTier(input) + return &out, nil +} + +type StopHostsWhen string + +const ( + StopHostsWhenZeroActiveSessions StopHostsWhen = "ZeroActiveSessions" + StopHostsWhenZeroSessions StopHostsWhen = "ZeroSessions" +) + +func PossibleValuesForStopHostsWhen() []string { + return []string{ + string(StopHostsWhenZeroActiveSessions), + string(StopHostsWhenZeroSessions), + } +} + +func (s *StopHostsWhen) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStopHostsWhen(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStopHostsWhen(input string) (*StopHostsWhen, error) { + vals := map[string]StopHostsWhen{ + "zeroactivesessions": StopHostsWhenZeroActiveSessions, + "zerosessions": StopHostsWhenZeroSessions, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StopHostsWhen(input) + return &out, nil +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/id_hostpool.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/id_hostpool.go new file mode 100644 index 00000000000..086dd9e1414 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/id_hostpool.go @@ -0,0 +1,130 @@ +package scalingplan + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&HostPoolId{}) +} + +var _ resourceids.ResourceId = &HostPoolId{} + +// HostPoolId is a struct representing the Resource ID for a Host Pool +type HostPoolId struct { + SubscriptionId string + ResourceGroupName string + HostPoolName string +} + +// NewHostPoolID returns a new HostPoolId struct +func NewHostPoolID(subscriptionId string, resourceGroupName string, hostPoolName string) HostPoolId { + return HostPoolId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + HostPoolName: hostPoolName, + } +} + +// ParseHostPoolID parses 'input' into a HostPoolId +func ParseHostPoolID(input string) (*HostPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostPoolId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostPoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseHostPoolIDInsensitively parses 'input' case-insensitively into a HostPoolId +// note: this method should only be used for API response data and not user input +func ParseHostPoolIDInsensitively(input string) (*HostPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostPoolId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostPoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *HostPoolId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.HostPoolName, ok = input.Parsed["hostPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hostPoolName", input) + } + + return nil +} + +// ValidateHostPoolID checks that 'input' can be parsed as a Host Pool ID +func ValidateHostPoolID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseHostPoolID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Host Pool ID +func (id HostPoolId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DesktopVirtualization/hostPools/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.HostPoolName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Host Pool ID +func (id HostPoolId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDesktopVirtualization", "Microsoft.DesktopVirtualization", "Microsoft.DesktopVirtualization"), + resourceids.StaticSegment("staticHostPools", "hostPools", "hostPools"), + resourceids.UserSpecifiedSegment("hostPoolName", "hostPoolName"), + } +} + +// String returns a human-readable description of this Host Pool ID +func (id HostPoolId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Host Pool Name: %q", id.HostPoolName), + } + return fmt.Sprintf("Host Pool (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/id_hostpool_test.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/id_hostpool_test.go new file mode 100644 index 00000000000..55329526a56 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/id_hostpool_test.go @@ -0,0 +1,282 @@ +package scalingplan + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &HostPoolId{} + +func TestNewHostPoolID(t *testing.T) { + id := NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.HostPoolName != "hostPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'HostPoolName'", id.HostPoolName, "hostPoolName") + } +} + +func TestFormatHostPoolID(t *testing.T) { + actual := NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseHostPoolID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostPoolId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName", + Expected: &HostPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostPoolName: "hostPoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostPoolID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostPoolName != v.Expected.HostPoolName { + t.Fatalf("Expected %q but got %q for HostPoolName", v.Expected.HostPoolName, actual.HostPoolName) + } + + } +} + +func TestParseHostPoolIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostPoolId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName", + Expected: &HostPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostPoolName: "hostPoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs/hOsTpOoLnAmE", + Expected: &HostPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + HostPoolName: "hOsTpOoLnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs/hOsTpOoLnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostPoolIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostPoolName != v.Expected.HostPoolName { + t.Fatalf("Expected %q but got %q for HostPoolName", v.Expected.HostPoolName, actual.HostPoolName) + } + + } +} + +func TestSegmentsForHostPoolId(t *testing.T) { + segments := HostPoolId{}.Segments() + if len(segments) == 0 { + t.Fatalf("HostPoolId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/id_scalingplan.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/id_scalingplan.go new file mode 100644 index 00000000000..44f0c4e6d0c --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/id_scalingplan.go @@ -0,0 +1,130 @@ +package scalingplan + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ScalingPlanId{}) +} + +var _ resourceids.ResourceId = &ScalingPlanId{} + +// ScalingPlanId is a struct representing the Resource ID for a Scaling Plan +type ScalingPlanId struct { + SubscriptionId string + ResourceGroupName string + ScalingPlanName string +} + +// NewScalingPlanID returns a new ScalingPlanId struct +func NewScalingPlanID(subscriptionId string, resourceGroupName string, scalingPlanName string) ScalingPlanId { + return ScalingPlanId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ScalingPlanName: scalingPlanName, + } +} + +// ParseScalingPlanID parses 'input' into a ScalingPlanId +func ParseScalingPlanID(input string) (*ScalingPlanId, error) { + parser := resourceids.NewParserFromResourceIdType(&ScalingPlanId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ScalingPlanId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseScalingPlanIDInsensitively parses 'input' case-insensitively into a ScalingPlanId +// note: this method should only be used for API response data and not user input +func ParseScalingPlanIDInsensitively(input string) (*ScalingPlanId, error) { + parser := resourceids.NewParserFromResourceIdType(&ScalingPlanId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ScalingPlanId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ScalingPlanId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ScalingPlanName, ok = input.Parsed["scalingPlanName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "scalingPlanName", input) + } + + return nil +} + +// ValidateScalingPlanID checks that 'input' can be parsed as a Scaling Plan ID +func ValidateScalingPlanID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseScalingPlanID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Scaling Plan ID +func (id ScalingPlanId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DesktopVirtualization/scalingPlans/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ScalingPlanName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Scaling Plan ID +func (id ScalingPlanId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDesktopVirtualization", "Microsoft.DesktopVirtualization", "Microsoft.DesktopVirtualization"), + resourceids.StaticSegment("staticScalingPlans", "scalingPlans", "scalingPlans"), + resourceids.UserSpecifiedSegment("scalingPlanName", "scalingPlanName"), + } +} + +// String returns a human-readable description of this Scaling Plan ID +func (id ScalingPlanId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Scaling Plan Name: %q", id.ScalingPlanName), + } + return fmt.Sprintf("Scaling Plan (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/id_scalingplan_test.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/id_scalingplan_test.go new file mode 100644 index 00000000000..7e2d71f4e6c --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/id_scalingplan_test.go @@ -0,0 +1,282 @@ +package scalingplan + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ScalingPlanId{} + +func TestNewScalingPlanID(t *testing.T) { + id := NewScalingPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "scalingPlanName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ScalingPlanName != "scalingPlanName" { + t.Fatalf("Expected %q but got %q for Segment 'ScalingPlanName'", id.ScalingPlanName, "scalingPlanName") + } +} + +func TestFormatScalingPlanID(t *testing.T) { + actual := NewScalingPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "scalingPlanName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/scalingPlans/scalingPlanName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseScalingPlanID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ScalingPlanId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/scalingPlans", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/scalingPlans/scalingPlanName", + Expected: &ScalingPlanId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ScalingPlanName: "scalingPlanName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/scalingPlans/scalingPlanName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseScalingPlanID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ScalingPlanName != v.Expected.ScalingPlanName { + t.Fatalf("Expected %q but got %q for ScalingPlanName", v.Expected.ScalingPlanName, actual.ScalingPlanName) + } + + } +} + +func TestParseScalingPlanIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ScalingPlanId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/scalingPlans", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/sCaLiNgPlAnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/scalingPlans/scalingPlanName", + Expected: &ScalingPlanId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ScalingPlanName: "scalingPlanName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/scalingPlans/scalingPlanName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/sCaLiNgPlAnS/sCaLiNgPlAnNaMe", + Expected: &ScalingPlanId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ScalingPlanName: "sCaLiNgPlAnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/sCaLiNgPlAnS/sCaLiNgPlAnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseScalingPlanIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ScalingPlanName != v.Expected.ScalingPlanName { + t.Fatalf("Expected %q but got %q for ScalingPlanName", v.Expected.ScalingPlanName, actual.ScalingPlanName) + } + + } +} + +func TestSegmentsForScalingPlanId(t *testing.T) { + segments := ScalingPlanId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ScalingPlanId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/method_create.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/method_create.go new file mode 100644 index 00000000000..52557422ed3 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/method_create.go @@ -0,0 +1,58 @@ +package scalingplan + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ScalingPlan +} + +// Create ... +func (c ScalingPlanClient) Create(ctx context.Context, id ScalingPlanId, input ScalingPlan) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ScalingPlan + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/method_delete.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/method_delete.go new file mode 100644 index 00000000000..a84f6d1516a --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/method_delete.go @@ -0,0 +1,47 @@ +package scalingplan + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ScalingPlanClient) Delete(ctx context.Context, id ScalingPlanId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/method_get.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/method_get.go new file mode 100644 index 00000000000..0bd28e3a491 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/method_get.go @@ -0,0 +1,53 @@ +package scalingplan + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *ScalingPlan +} + +// Get ... +func (c ScalingPlanClient) Get(ctx context.Context, id ScalingPlanId) (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 ScalingPlan + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/method_listbyhostpool.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/method_listbyhostpool.go new file mode 100644 index 00000000000..e526a537535 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/method_listbyhostpool.go @@ -0,0 +1,142 @@ +package scalingplan + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByHostPoolOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ScalingPlan +} + +type ListByHostPoolCompleteResult struct { + LatestHttpResponse *http.Response + Items []ScalingPlan +} + +type ListByHostPoolOperationOptions struct { + InitialSkip *int64 + IsDescending *bool + PageSize *int64 +} + +func DefaultListByHostPoolOperationOptions() ListByHostPoolOperationOptions { + return ListByHostPoolOperationOptions{} +} + +func (o ListByHostPoolOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByHostPoolOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListByHostPoolOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.InitialSkip != nil { + out.Append("initialSkip", fmt.Sprintf("%v", *o.InitialSkip)) + } + if o.IsDescending != nil { + out.Append("isDescending", fmt.Sprintf("%v", *o.IsDescending)) + } + if o.PageSize != nil { + out.Append("pageSize", fmt.Sprintf("%v", *o.PageSize)) + } + return &out +} + +type ListByHostPoolCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByHostPoolCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByHostPool ... +func (c ScalingPlanClient) ListByHostPool(ctx context.Context, id HostPoolId, options ListByHostPoolOperationOptions) (result ListByHostPoolOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListByHostPoolCustomPager{}, + Path: fmt.Sprintf("%s/scalingPlans", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ScalingPlan `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByHostPoolComplete retrieves all the results into a single object +func (c ScalingPlanClient) ListByHostPoolComplete(ctx context.Context, id HostPoolId, options ListByHostPoolOperationOptions) (ListByHostPoolCompleteResult, error) { + return c.ListByHostPoolCompleteMatchingPredicate(ctx, id, options, ScalingPlanOperationPredicate{}) +} + +// ListByHostPoolCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ScalingPlanClient) ListByHostPoolCompleteMatchingPredicate(ctx context.Context, id HostPoolId, options ListByHostPoolOperationOptions, predicate ScalingPlanOperationPredicate) (result ListByHostPoolCompleteResult, err error) { + items := make([]ScalingPlan, 0) + + resp, err := c.ListByHostPool(ctx, id, options) + 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 = ListByHostPoolCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/method_listbyresourcegroup.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/method_listbyresourcegroup.go new file mode 100644 index 00000000000..918692b7a54 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/method_listbyresourcegroup.go @@ -0,0 +1,143 @@ +package scalingplan + +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 *[]ScalingPlan +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []ScalingPlan +} + +type ListByResourceGroupOperationOptions struct { + InitialSkip *int64 + IsDescending *bool + PageSize *int64 +} + +func DefaultListByResourceGroupOperationOptions() ListByResourceGroupOperationOptions { + return ListByResourceGroupOperationOptions{} +} + +func (o ListByResourceGroupOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByResourceGroupOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListByResourceGroupOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.InitialSkip != nil { + out.Append("initialSkip", fmt.Sprintf("%v", *o.InitialSkip)) + } + if o.IsDescending != nil { + out.Append("isDescending", fmt.Sprintf("%v", *o.IsDescending)) + } + if o.PageSize != nil { + out.Append("pageSize", fmt.Sprintf("%v", *o.PageSize)) + } + return &out +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c ScalingPlanClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DesktopVirtualization/scalingPlans", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ScalingPlan `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 ScalingPlanClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, options, ScalingPlanOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ScalingPlanClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions, predicate ScalingPlanOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]ScalingPlan, 0) + + resp, err := c.ListByResourceGroup(ctx, id, options) + 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/desktopvirtualization/2024-04-08-preview/scalingplan/method_listbysubscription.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/method_listbysubscription.go new file mode 100644 index 00000000000..d58d149c5f0 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/method_listbysubscription.go @@ -0,0 +1,143 @@ +package scalingplan + +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 *[]ScalingPlan +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []ScalingPlan +} + +type ListBySubscriptionOperationOptions struct { + InitialSkip *int64 + IsDescending *bool + PageSize *int64 +} + +func DefaultListBySubscriptionOperationOptions() ListBySubscriptionOperationOptions { + return ListBySubscriptionOperationOptions{} +} + +func (o ListBySubscriptionOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListBySubscriptionOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListBySubscriptionOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.InitialSkip != nil { + out.Append("initialSkip", fmt.Sprintf("%v", *o.InitialSkip)) + } + if o.IsDescending != nil { + out.Append("isDescending", fmt.Sprintf("%v", *o.IsDescending)) + } + if o.PageSize != nil { + out.Append("pageSize", fmt.Sprintf("%v", *o.PageSize)) + } + return &out +} + +type ListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySubscription ... +func (c ScalingPlanClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DesktopVirtualization/scalingPlans", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ScalingPlan `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 ScalingPlanClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, options, ScalingPlanOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ScalingPlanClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions, predicate ScalingPlanOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]ScalingPlan, 0) + + resp, err := c.ListBySubscription(ctx, id, options) + 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/desktopvirtualization/2024-04-08-preview/scalingplan/method_update.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/method_update.go new file mode 100644 index 00000000000..5757e0ebec6 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/method_update.go @@ -0,0 +1,57 @@ +package scalingplan + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ScalingPlan +} + +// Update ... +func (c ScalingPlanClient) Update(ctx context.Context, id ScalingPlanId, input ScalingPlanPatch) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ScalingPlan + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/model_plan.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/model_plan.go new file mode 100644 index 00000000000..07296ec4765 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/model_plan.go @@ -0,0 +1,12 @@ +package scalingplan + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Plan struct { + Name string `json:"name"` + Product string `json:"product"` + PromotionCode *string `json:"promotionCode,omitempty"` + Publisher string `json:"publisher"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/model_scalinghostpoolreference.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/model_scalinghostpoolreference.go new file mode 100644 index 00000000000..0bd8fd048bb --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/model_scalinghostpoolreference.go @@ -0,0 +1,9 @@ +package scalingplan + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScalingHostPoolReference struct { + HostPoolArmPath *string `json:"hostPoolArmPath,omitempty"` + ScalingPlanEnabled *bool `json:"scalingPlanEnabled,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/model_scalingplan.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/model_scalingplan.go new file mode 100644 index 00000000000..0bea4d2f691 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/model_scalingplan.go @@ -0,0 +1,25 @@ +package scalingplan + +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 ScalingPlan struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + ManagedBy *string `json:"managedBy,omitempty"` + Name *string `json:"name,omitempty"` + Plan *Plan `json:"plan,omitempty"` + Properties ScalingPlanProperties `json:"properties"` + Sku *Sku `json:"sku,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/model_scalingplanpatch.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/model_scalingplanpatch.go new file mode 100644 index 00000000000..642647709fe --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/model_scalingplanpatch.go @@ -0,0 +1,9 @@ +package scalingplan + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScalingPlanPatch struct { + Properties *ScalingPlanPatchProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/model_scalingplanpatchproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/model_scalingplanpatchproperties.go new file mode 100644 index 00000000000..393a26bb413 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/model_scalingplanpatchproperties.go @@ -0,0 +1,13 @@ +package scalingplan + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScalingPlanPatchProperties struct { + Description *string `json:"description,omitempty"` + ExclusionTag *string `json:"exclusionTag,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HostPoolReferences *[]ScalingHostPoolReference `json:"hostPoolReferences,omitempty"` + Schedules *[]ScalingSchedule `json:"schedules,omitempty"` + TimeZone *string `json:"timeZone,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/model_scalingplanproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/model_scalingplanproperties.go new file mode 100644 index 00000000000..a1e22e2c774 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/model_scalingplanproperties.go @@ -0,0 +1,15 @@ +package scalingplan + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScalingPlanProperties struct { + Description *string `json:"description,omitempty"` + ExclusionTag *string `json:"exclusionTag,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HostPoolReferences *[]ScalingHostPoolReference `json:"hostPoolReferences,omitempty"` + HostPoolType *ScalingHostPoolType `json:"hostPoolType,omitempty"` + ObjectId *string `json:"objectId,omitempty"` + Schedules *[]ScalingSchedule `json:"schedules,omitempty"` + TimeZone string `json:"timeZone"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/model_scalingschedule.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/model_scalingschedule.go new file mode 100644 index 00000000000..313ed8bdf13 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/model_scalingschedule.go @@ -0,0 +1,25 @@ +package scalingplan + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScalingSchedule struct { + DaysOfWeek *[]DaysOfWeek `json:"daysOfWeek,omitempty"` + Name *string `json:"name,omitempty"` + OffPeakLoadBalancingAlgorithm *SessionHostLoadBalancingAlgorithm `json:"offPeakLoadBalancingAlgorithm,omitempty"` + OffPeakStartTime *Time `json:"offPeakStartTime,omitempty"` + PeakLoadBalancingAlgorithm *SessionHostLoadBalancingAlgorithm `json:"peakLoadBalancingAlgorithm,omitempty"` + PeakStartTime *Time `json:"peakStartTime,omitempty"` + RampDownCapacityThresholdPct *int64 `json:"rampDownCapacityThresholdPct,omitempty"` + RampDownForceLogoffUsers *bool `json:"rampDownForceLogoffUsers,omitempty"` + RampDownLoadBalancingAlgorithm *SessionHostLoadBalancingAlgorithm `json:"rampDownLoadBalancingAlgorithm,omitempty"` + RampDownMinimumHostsPct *int64 `json:"rampDownMinimumHostsPct,omitempty"` + RampDownNotificationMessage *string `json:"rampDownNotificationMessage,omitempty"` + RampDownStartTime *Time `json:"rampDownStartTime,omitempty"` + RampDownStopHostsWhen *StopHostsWhen `json:"rampDownStopHostsWhen,omitempty"` + RampDownWaitTimeMinutes *int64 `json:"rampDownWaitTimeMinutes,omitempty"` + RampUpCapacityThresholdPct *int64 `json:"rampUpCapacityThresholdPct,omitempty"` + RampUpLoadBalancingAlgorithm *SessionHostLoadBalancingAlgorithm `json:"rampUpLoadBalancingAlgorithm,omitempty"` + RampUpMinimumHostsPct *int64 `json:"rampUpMinimumHostsPct,omitempty"` + RampUpStartTime *Time `json:"rampUpStartTime,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/model_sku.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/model_sku.go new file mode 100644 index 00000000000..364fdaef1a0 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/model_sku.go @@ -0,0 +1,12 @@ +package scalingplan + +// 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 *int64 `json:"capacity,omitempty"` + Family *string `json:"family,omitempty"` + Name string `json:"name"` + Size *string `json:"size,omitempty"` + Tier *SkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/model_time.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/model_time.go new file mode 100644 index 00000000000..f9e8b6f4484 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/model_time.go @@ -0,0 +1,9 @@ +package scalingplan + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Time struct { + Hour int64 `json:"hour"` + Minute int64 `json:"minute"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/predicates.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/predicates.go new file mode 100644 index 00000000000..e1bec31fe3a --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/predicates.go @@ -0,0 +1,47 @@ +package scalingplan + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScalingPlanOperationPredicate struct { + Etag *string + Id *string + Kind *string + Location *string + ManagedBy *string + Name *string + Type *string +} + +func (p ScalingPlanOperationPredicate) Matches(input ScalingPlan) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.ManagedBy != nil && (input.ManagedBy == nil || *p.ManagedBy != *input.ManagedBy) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/version.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/version.go new file mode 100644 index 00000000000..455628aade4 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplan/version.go @@ -0,0 +1,10 @@ +package scalingplan + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-08-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/scalingplan/2024-04-08-preview" +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/README.md b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/README.md new file mode 100644 index 00000000000..db7e658bd3d --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/README.md @@ -0,0 +1,111 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule` Documentation + +The `scalingplanpersonalschedule` SDK allows for interaction with Azure Resource Manager `desktopvirtualization` (API Version `2024-04-08-preview`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule" +``` + + +### Client Initialization + +```go +client := scalingplanpersonalschedule.NewScalingPlanPersonalScheduleClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ScalingPlanPersonalScheduleClient.Create` + +```go +ctx := context.TODO() +id := scalingplanpersonalschedule.NewPersonalScheduleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "scalingPlanName", "personalScheduleName") + +payload := scalingplanpersonalschedule.ScalingPlanPersonalSchedule{ + // ... +} + + +read, err := client.Create(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ScalingPlanPersonalScheduleClient.Delete` + +```go +ctx := context.TODO() +id := scalingplanpersonalschedule.NewPersonalScheduleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "scalingPlanName", "personalScheduleName") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ScalingPlanPersonalScheduleClient.Get` + +```go +ctx := context.TODO() +id := scalingplanpersonalschedule.NewPersonalScheduleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "scalingPlanName", "personalScheduleName") + +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: `ScalingPlanPersonalScheduleClient.List` + +```go +ctx := context.TODO() +id := scalingplanpersonalschedule.NewScalingPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "scalingPlanName") + +// alternatively `client.List(ctx, id, scalingplanpersonalschedule.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, scalingplanpersonalschedule.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ScalingPlanPersonalScheduleClient.Update` + +```go +ctx := context.TODO() +id := scalingplanpersonalschedule.NewPersonalScheduleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "scalingPlanName", "personalScheduleName") + +payload := scalingplanpersonalschedule.ScalingPlanPersonalSchedulePatch{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/client.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/client.go new file mode 100644 index 00000000000..7ef1b523ea8 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/client.go @@ -0,0 +1,26 @@ +package scalingplanpersonalschedule + +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 ScalingPlanPersonalScheduleClient struct { + Client *resourcemanager.Client +} + +func NewScalingPlanPersonalScheduleClientWithBaseURI(sdkApi sdkEnv.Api) (*ScalingPlanPersonalScheduleClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "scalingplanpersonalschedule", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ScalingPlanPersonalScheduleClient: %+v", err) + } + + return &ScalingPlanPersonalScheduleClient{ + Client: client, + }, nil +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/constants.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/constants.go new file mode 100644 index 00000000000..6b4a6fed926 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/constants.go @@ -0,0 +1,195 @@ +package scalingplanpersonalschedule + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DayOfWeek string + +const ( + DayOfWeekFriday DayOfWeek = "Friday" + DayOfWeekMonday DayOfWeek = "Monday" + DayOfWeekSaturday DayOfWeek = "Saturday" + DayOfWeekSunday DayOfWeek = "Sunday" + DayOfWeekThursday DayOfWeek = "Thursday" + DayOfWeekTuesday DayOfWeek = "Tuesday" + DayOfWeekWednesday DayOfWeek = "Wednesday" +) + +func PossibleValuesForDayOfWeek() []string { + return []string{ + string(DayOfWeekFriday), + string(DayOfWeekMonday), + string(DayOfWeekSaturday), + string(DayOfWeekSunday), + string(DayOfWeekThursday), + string(DayOfWeekTuesday), + string(DayOfWeekWednesday), + } +} + +func (s *DayOfWeek) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDayOfWeek(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDayOfWeek(input string) (*DayOfWeek, error) { + vals := map[string]DayOfWeek{ + "friday": DayOfWeekFriday, + "monday": DayOfWeekMonday, + "saturday": DayOfWeekSaturday, + "sunday": DayOfWeekSunday, + "thursday": DayOfWeekThursday, + "tuesday": DayOfWeekTuesday, + "wednesday": DayOfWeekWednesday, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DayOfWeek(input) + return &out, nil +} + +type SessionHandlingOperation string + +const ( + SessionHandlingOperationDeallocate SessionHandlingOperation = "Deallocate" + SessionHandlingOperationHibernate SessionHandlingOperation = "Hibernate" + SessionHandlingOperationNone SessionHandlingOperation = "None" +) + +func PossibleValuesForSessionHandlingOperation() []string { + return []string{ + string(SessionHandlingOperationDeallocate), + string(SessionHandlingOperationHibernate), + string(SessionHandlingOperationNone), + } +} + +func (s *SessionHandlingOperation) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSessionHandlingOperation(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSessionHandlingOperation(input string) (*SessionHandlingOperation, error) { + vals := map[string]SessionHandlingOperation{ + "deallocate": SessionHandlingOperationDeallocate, + "hibernate": SessionHandlingOperationHibernate, + "none": SessionHandlingOperationNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SessionHandlingOperation(input) + return &out, nil +} + +type SetStartVMOnConnect string + +const ( + SetStartVMOnConnectDisable SetStartVMOnConnect = "Disable" + SetStartVMOnConnectEnable SetStartVMOnConnect = "Enable" +) + +func PossibleValuesForSetStartVMOnConnect() []string { + return []string{ + string(SetStartVMOnConnectDisable), + string(SetStartVMOnConnectEnable), + } +} + +func (s *SetStartVMOnConnect) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSetStartVMOnConnect(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSetStartVMOnConnect(input string) (*SetStartVMOnConnect, error) { + vals := map[string]SetStartVMOnConnect{ + "disable": SetStartVMOnConnectDisable, + "enable": SetStartVMOnConnectEnable, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SetStartVMOnConnect(input) + return &out, nil +} + +type StartupBehavior string + +const ( + StartupBehaviorAll StartupBehavior = "All" + StartupBehaviorNone StartupBehavior = "None" + StartupBehaviorWithAssignedUser StartupBehavior = "WithAssignedUser" +) + +func PossibleValuesForStartupBehavior() []string { + return []string{ + string(StartupBehaviorAll), + string(StartupBehaviorNone), + string(StartupBehaviorWithAssignedUser), + } +} + +func (s *StartupBehavior) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStartupBehavior(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStartupBehavior(input string) (*StartupBehavior, error) { + vals := map[string]StartupBehavior{ + "all": StartupBehaviorAll, + "none": StartupBehaviorNone, + "withassigneduser": StartupBehaviorWithAssignedUser, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StartupBehavior(input) + return &out, nil +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/id_personalschedule.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/id_personalschedule.go new file mode 100644 index 00000000000..eccdf98fe58 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/id_personalschedule.go @@ -0,0 +1,139 @@ +package scalingplanpersonalschedule + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PersonalScheduleId{}) +} + +var _ resourceids.ResourceId = &PersonalScheduleId{} + +// PersonalScheduleId is a struct representing the Resource ID for a Personal Schedule +type PersonalScheduleId struct { + SubscriptionId string + ResourceGroupName string + ScalingPlanName string + PersonalScheduleName string +} + +// NewPersonalScheduleID returns a new PersonalScheduleId struct +func NewPersonalScheduleID(subscriptionId string, resourceGroupName string, scalingPlanName string, personalScheduleName string) PersonalScheduleId { + return PersonalScheduleId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ScalingPlanName: scalingPlanName, + PersonalScheduleName: personalScheduleName, + } +} + +// ParsePersonalScheduleID parses 'input' into a PersonalScheduleId +func ParsePersonalScheduleID(input string) (*PersonalScheduleId, error) { + parser := resourceids.NewParserFromResourceIdType(&PersonalScheduleId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PersonalScheduleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePersonalScheduleIDInsensitively parses 'input' case-insensitively into a PersonalScheduleId +// note: this method should only be used for API response data and not user input +func ParsePersonalScheduleIDInsensitively(input string) (*PersonalScheduleId, error) { + parser := resourceids.NewParserFromResourceIdType(&PersonalScheduleId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PersonalScheduleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PersonalScheduleId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ScalingPlanName, ok = input.Parsed["scalingPlanName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "scalingPlanName", input) + } + + if id.PersonalScheduleName, ok = input.Parsed["personalScheduleName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "personalScheduleName", input) + } + + return nil +} + +// ValidatePersonalScheduleID checks that 'input' can be parsed as a Personal Schedule ID +func ValidatePersonalScheduleID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParsePersonalScheduleID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Personal Schedule ID +func (id PersonalScheduleId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DesktopVirtualization/scalingPlans/%s/personalSchedules/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ScalingPlanName, id.PersonalScheduleName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Personal Schedule ID +func (id PersonalScheduleId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDesktopVirtualization", "Microsoft.DesktopVirtualization", "Microsoft.DesktopVirtualization"), + resourceids.StaticSegment("staticScalingPlans", "scalingPlans", "scalingPlans"), + resourceids.UserSpecifiedSegment("scalingPlanName", "scalingPlanName"), + resourceids.StaticSegment("staticPersonalSchedules", "personalSchedules", "personalSchedules"), + resourceids.UserSpecifiedSegment("personalScheduleName", "personalScheduleName"), + } +} + +// String returns a human-readable description of this Personal Schedule ID +func (id PersonalScheduleId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Scaling Plan Name: %q", id.ScalingPlanName), + fmt.Sprintf("Personal Schedule Name: %q", id.PersonalScheduleName), + } + return fmt.Sprintf("Personal Schedule (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/id_personalschedule_test.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/id_personalschedule_test.go new file mode 100644 index 00000000000..f6860563d6c --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/id_personalschedule_test.go @@ -0,0 +1,327 @@ +package scalingplanpersonalschedule + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PersonalScheduleId{} + +func TestNewPersonalScheduleID(t *testing.T) { + id := NewPersonalScheduleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "scalingPlanName", "personalScheduleName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ScalingPlanName != "scalingPlanName" { + t.Fatalf("Expected %q but got %q for Segment 'ScalingPlanName'", id.ScalingPlanName, "scalingPlanName") + } + + if id.PersonalScheduleName != "personalScheduleName" { + t.Fatalf("Expected %q but got %q for Segment 'PersonalScheduleName'", id.PersonalScheduleName, "personalScheduleName") + } +} + +func TestFormatPersonalScheduleID(t *testing.T) { + actual := NewPersonalScheduleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "scalingPlanName", "personalScheduleName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/scalingPlans/scalingPlanName/personalSchedules/personalScheduleName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePersonalScheduleID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PersonalScheduleId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/scalingPlans", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/scalingPlans/scalingPlanName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/scalingPlans/scalingPlanName/personalSchedules", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/scalingPlans/scalingPlanName/personalSchedules/personalScheduleName", + Expected: &PersonalScheduleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ScalingPlanName: "scalingPlanName", + PersonalScheduleName: "personalScheduleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/scalingPlans/scalingPlanName/personalSchedules/personalScheduleName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePersonalScheduleID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ScalingPlanName != v.Expected.ScalingPlanName { + t.Fatalf("Expected %q but got %q for ScalingPlanName", v.Expected.ScalingPlanName, actual.ScalingPlanName) + } + + if actual.PersonalScheduleName != v.Expected.PersonalScheduleName { + t.Fatalf("Expected %q but got %q for PersonalScheduleName", v.Expected.PersonalScheduleName, actual.PersonalScheduleName) + } + + } +} + +func TestParsePersonalScheduleIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PersonalScheduleId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/scalingPlans", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/sCaLiNgPlAnS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/scalingPlans/scalingPlanName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/sCaLiNgPlAnS/sCaLiNgPlAnNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/scalingPlans/scalingPlanName/personalSchedules", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/sCaLiNgPlAnS/sCaLiNgPlAnNaMe/pErSoNaLsChEdUlEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/scalingPlans/scalingPlanName/personalSchedules/personalScheduleName", + Expected: &PersonalScheduleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ScalingPlanName: "scalingPlanName", + PersonalScheduleName: "personalScheduleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/scalingPlans/scalingPlanName/personalSchedules/personalScheduleName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/sCaLiNgPlAnS/sCaLiNgPlAnNaMe/pErSoNaLsChEdUlEs/pErSoNaLsChEdUlEnAmE", + Expected: &PersonalScheduleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ScalingPlanName: "sCaLiNgPlAnNaMe", + PersonalScheduleName: "pErSoNaLsChEdUlEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/sCaLiNgPlAnS/sCaLiNgPlAnNaMe/pErSoNaLsChEdUlEs/pErSoNaLsChEdUlEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePersonalScheduleIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ScalingPlanName != v.Expected.ScalingPlanName { + t.Fatalf("Expected %q but got %q for ScalingPlanName", v.Expected.ScalingPlanName, actual.ScalingPlanName) + } + + if actual.PersonalScheduleName != v.Expected.PersonalScheduleName { + t.Fatalf("Expected %q but got %q for PersonalScheduleName", v.Expected.PersonalScheduleName, actual.PersonalScheduleName) + } + + } +} + +func TestSegmentsForPersonalScheduleId(t *testing.T) { + segments := PersonalScheduleId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PersonalScheduleId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/id_scalingplan.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/id_scalingplan.go new file mode 100644 index 00000000000..c6eb002b7f1 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/id_scalingplan.go @@ -0,0 +1,130 @@ +package scalingplanpersonalschedule + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ScalingPlanId{}) +} + +var _ resourceids.ResourceId = &ScalingPlanId{} + +// ScalingPlanId is a struct representing the Resource ID for a Scaling Plan +type ScalingPlanId struct { + SubscriptionId string + ResourceGroupName string + ScalingPlanName string +} + +// NewScalingPlanID returns a new ScalingPlanId struct +func NewScalingPlanID(subscriptionId string, resourceGroupName string, scalingPlanName string) ScalingPlanId { + return ScalingPlanId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ScalingPlanName: scalingPlanName, + } +} + +// ParseScalingPlanID parses 'input' into a ScalingPlanId +func ParseScalingPlanID(input string) (*ScalingPlanId, error) { + parser := resourceids.NewParserFromResourceIdType(&ScalingPlanId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ScalingPlanId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseScalingPlanIDInsensitively parses 'input' case-insensitively into a ScalingPlanId +// note: this method should only be used for API response data and not user input +func ParseScalingPlanIDInsensitively(input string) (*ScalingPlanId, error) { + parser := resourceids.NewParserFromResourceIdType(&ScalingPlanId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ScalingPlanId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ScalingPlanId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ScalingPlanName, ok = input.Parsed["scalingPlanName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "scalingPlanName", input) + } + + return nil +} + +// ValidateScalingPlanID checks that 'input' can be parsed as a Scaling Plan ID +func ValidateScalingPlanID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseScalingPlanID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Scaling Plan ID +func (id ScalingPlanId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DesktopVirtualization/scalingPlans/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ScalingPlanName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Scaling Plan ID +func (id ScalingPlanId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDesktopVirtualization", "Microsoft.DesktopVirtualization", "Microsoft.DesktopVirtualization"), + resourceids.StaticSegment("staticScalingPlans", "scalingPlans", "scalingPlans"), + resourceids.UserSpecifiedSegment("scalingPlanName", "scalingPlanName"), + } +} + +// String returns a human-readable description of this Scaling Plan ID +func (id ScalingPlanId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Scaling Plan Name: %q", id.ScalingPlanName), + } + return fmt.Sprintf("Scaling Plan (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/id_scalingplan_test.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/id_scalingplan_test.go new file mode 100644 index 00000000000..946f2d5cdac --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/id_scalingplan_test.go @@ -0,0 +1,282 @@ +package scalingplanpersonalschedule + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ScalingPlanId{} + +func TestNewScalingPlanID(t *testing.T) { + id := NewScalingPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "scalingPlanName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ScalingPlanName != "scalingPlanName" { + t.Fatalf("Expected %q but got %q for Segment 'ScalingPlanName'", id.ScalingPlanName, "scalingPlanName") + } +} + +func TestFormatScalingPlanID(t *testing.T) { + actual := NewScalingPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "scalingPlanName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/scalingPlans/scalingPlanName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseScalingPlanID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ScalingPlanId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/scalingPlans", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/scalingPlans/scalingPlanName", + Expected: &ScalingPlanId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ScalingPlanName: "scalingPlanName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/scalingPlans/scalingPlanName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseScalingPlanID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ScalingPlanName != v.Expected.ScalingPlanName { + t.Fatalf("Expected %q but got %q for ScalingPlanName", v.Expected.ScalingPlanName, actual.ScalingPlanName) + } + + } +} + +func TestParseScalingPlanIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ScalingPlanId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/scalingPlans", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/sCaLiNgPlAnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/scalingPlans/scalingPlanName", + Expected: &ScalingPlanId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ScalingPlanName: "scalingPlanName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/scalingPlans/scalingPlanName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/sCaLiNgPlAnS/sCaLiNgPlAnNaMe", + Expected: &ScalingPlanId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ScalingPlanName: "sCaLiNgPlAnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/sCaLiNgPlAnS/sCaLiNgPlAnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseScalingPlanIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ScalingPlanName != v.Expected.ScalingPlanName { + t.Fatalf("Expected %q but got %q for ScalingPlanName", v.Expected.ScalingPlanName, actual.ScalingPlanName) + } + + } +} + +func TestSegmentsForScalingPlanId(t *testing.T) { + segments := ScalingPlanId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ScalingPlanId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/method_create.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/method_create.go new file mode 100644 index 00000000000..626830e14b4 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/method_create.go @@ -0,0 +1,58 @@ +package scalingplanpersonalschedule + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ScalingPlanPersonalSchedule +} + +// Create ... +func (c ScalingPlanPersonalScheduleClient) Create(ctx context.Context, id PersonalScheduleId, input ScalingPlanPersonalSchedule) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ScalingPlanPersonalSchedule + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/method_delete.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/method_delete.go new file mode 100644 index 00000000000..ee19d98e12a --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/method_delete.go @@ -0,0 +1,47 @@ +package scalingplanpersonalschedule + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ScalingPlanPersonalScheduleClient) Delete(ctx context.Context, id PersonalScheduleId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/method_get.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/method_get.go new file mode 100644 index 00000000000..07faad43786 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/method_get.go @@ -0,0 +1,53 @@ +package scalingplanpersonalschedule + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *ScalingPlanPersonalSchedule +} + +// Get ... +func (c ScalingPlanPersonalScheduleClient) Get(ctx context.Context, id PersonalScheduleId) (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 ScalingPlanPersonalSchedule + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/method_list.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/method_list.go new file mode 100644 index 00000000000..88060845698 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/method_list.go @@ -0,0 +1,142 @@ +package scalingplanpersonalschedule + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ScalingPlanPersonalSchedule +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ScalingPlanPersonalSchedule +} + +type ListOperationOptions struct { + InitialSkip *int64 + IsDescending *bool + PageSize *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.InitialSkip != nil { + out.Append("initialSkip", fmt.Sprintf("%v", *o.InitialSkip)) + } + if o.IsDescending != nil { + out.Append("isDescending", fmt.Sprintf("%v", *o.IsDescending)) + } + if o.PageSize != nil { + out.Append("pageSize", fmt.Sprintf("%v", *o.PageSize)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ScalingPlanPersonalScheduleClient) List(ctx context.Context, id ScalingPlanId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/personalSchedules", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ScalingPlanPersonalSchedule `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ScalingPlanPersonalScheduleClient) ListComplete(ctx context.Context, id ScalingPlanId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, ScalingPlanPersonalScheduleOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ScalingPlanPersonalScheduleClient) ListCompleteMatchingPredicate(ctx context.Context, id ScalingPlanId, options ListOperationOptions, predicate ScalingPlanPersonalScheduleOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ScalingPlanPersonalSchedule, 0) + + resp, err := c.List(ctx, id, options) + 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 = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/method_update.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/method_update.go new file mode 100644 index 00000000000..b9e1ea6b5a1 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/method_update.go @@ -0,0 +1,57 @@ +package scalingplanpersonalschedule + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ScalingPlanPersonalSchedule +} + +// Update ... +func (c ScalingPlanPersonalScheduleClient) Update(ctx context.Context, id PersonalScheduleId, input ScalingPlanPersonalSchedulePatch) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ScalingPlanPersonalSchedule + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/model_scalingplanpersonalschedule.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/model_scalingplanpersonalschedule.go new file mode 100644 index 00000000000..5483a538ad0 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/model_scalingplanpersonalschedule.go @@ -0,0 +1,16 @@ +package scalingplanpersonalschedule + +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 ScalingPlanPersonalSchedule struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties ScalingPlanPersonalScheduleProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/model_scalingplanpersonalschedulepatch.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/model_scalingplanpersonalschedulepatch.go new file mode 100644 index 00000000000..67bc710f24c --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/model_scalingplanpersonalschedulepatch.go @@ -0,0 +1,8 @@ +package scalingplanpersonalschedule + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScalingPlanPersonalSchedulePatch struct { + Properties *ScalingPlanPersonalScheduleProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/model_scalingplanpersonalscheduleproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/model_scalingplanpersonalscheduleproperties.go new file mode 100644 index 00000000000..bd4c5cb7a28 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/model_scalingplanpersonalscheduleproperties.go @@ -0,0 +1,33 @@ +package scalingplanpersonalschedule + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScalingPlanPersonalScheduleProperties struct { + DaysOfWeek *[]DayOfWeek `json:"daysOfWeek,omitempty"` + OffPeakActionOnDisconnect *SessionHandlingOperation `json:"offPeakActionOnDisconnect,omitempty"` + OffPeakActionOnLogoff *SessionHandlingOperation `json:"offPeakActionOnLogoff,omitempty"` + OffPeakMinutesToWaitOnDisconnect *int64 `json:"offPeakMinutesToWaitOnDisconnect,omitempty"` + OffPeakMinutesToWaitOnLogoff *int64 `json:"offPeakMinutesToWaitOnLogoff,omitempty"` + OffPeakStartTime *Time `json:"offPeakStartTime,omitempty"` + OffPeakStartVMOnConnect *SetStartVMOnConnect `json:"offPeakStartVMOnConnect,omitempty"` + PeakActionOnDisconnect *SessionHandlingOperation `json:"peakActionOnDisconnect,omitempty"` + PeakActionOnLogoff *SessionHandlingOperation `json:"peakActionOnLogoff,omitempty"` + PeakMinutesToWaitOnDisconnect *int64 `json:"peakMinutesToWaitOnDisconnect,omitempty"` + PeakMinutesToWaitOnLogoff *int64 `json:"peakMinutesToWaitOnLogoff,omitempty"` + PeakStartTime *Time `json:"peakStartTime,omitempty"` + PeakStartVMOnConnect *SetStartVMOnConnect `json:"peakStartVMOnConnect,omitempty"` + RampDownActionOnDisconnect *SessionHandlingOperation `json:"rampDownActionOnDisconnect,omitempty"` + RampDownActionOnLogoff *SessionHandlingOperation `json:"rampDownActionOnLogoff,omitempty"` + RampDownMinutesToWaitOnDisconnect *int64 `json:"rampDownMinutesToWaitOnDisconnect,omitempty"` + RampDownMinutesToWaitOnLogoff *int64 `json:"rampDownMinutesToWaitOnLogoff,omitempty"` + RampDownStartTime *Time `json:"rampDownStartTime,omitempty"` + RampDownStartVMOnConnect *SetStartVMOnConnect `json:"rampDownStartVMOnConnect,omitempty"` + RampUpActionOnDisconnect *SessionHandlingOperation `json:"rampUpActionOnDisconnect,omitempty"` + RampUpActionOnLogoff *SessionHandlingOperation `json:"rampUpActionOnLogoff,omitempty"` + RampUpAutoStartHosts *StartupBehavior `json:"rampUpAutoStartHosts,omitempty"` + RampUpMinutesToWaitOnDisconnect *int64 `json:"rampUpMinutesToWaitOnDisconnect,omitempty"` + RampUpMinutesToWaitOnLogoff *int64 `json:"rampUpMinutesToWaitOnLogoff,omitempty"` + RampUpStartTime *Time `json:"rampUpStartTime,omitempty"` + RampUpStartVMOnConnect *SetStartVMOnConnect `json:"rampUpStartVMOnConnect,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/model_time.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/model_time.go new file mode 100644 index 00000000000..05bd9545d76 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/model_time.go @@ -0,0 +1,9 @@ +package scalingplanpersonalschedule + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Time struct { + Hour int64 `json:"hour"` + Minute int64 `json:"minute"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/predicates.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/predicates.go new file mode 100644 index 00000000000..3c3acee7852 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/predicates.go @@ -0,0 +1,27 @@ +package scalingplanpersonalschedule + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScalingPlanPersonalScheduleOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p ScalingPlanPersonalScheduleOperationPredicate) Matches(input ScalingPlanPersonalSchedule) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/version.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/version.go new file mode 100644 index 00000000000..37e6661e68b --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpersonalschedule/version.go @@ -0,0 +1,10 @@ +package scalingplanpersonalschedule + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-08-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/scalingplanpersonalschedule/2024-04-08-preview" +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/README.md b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/README.md new file mode 100644 index 00000000000..8a6d5c3066b --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/README.md @@ -0,0 +1,111 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule` Documentation + +The `scalingplanpooledschedule` SDK allows for interaction with Azure Resource Manager `desktopvirtualization` (API Version `2024-04-08-preview`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule" +``` + + +### Client Initialization + +```go +client := scalingplanpooledschedule.NewScalingPlanPooledScheduleClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ScalingPlanPooledScheduleClient.Create` + +```go +ctx := context.TODO() +id := scalingplanpooledschedule.NewPooledScheduleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "scalingPlanName", "pooledScheduleName") + +payload := scalingplanpooledschedule.ScalingPlanPooledSchedule{ + // ... +} + + +read, err := client.Create(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ScalingPlanPooledScheduleClient.Delete` + +```go +ctx := context.TODO() +id := scalingplanpooledschedule.NewPooledScheduleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "scalingPlanName", "pooledScheduleName") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ScalingPlanPooledScheduleClient.Get` + +```go +ctx := context.TODO() +id := scalingplanpooledschedule.NewPooledScheduleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "scalingPlanName", "pooledScheduleName") + +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: `ScalingPlanPooledScheduleClient.List` + +```go +ctx := context.TODO() +id := scalingplanpooledschedule.NewScalingPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "scalingPlanName") + +// alternatively `client.List(ctx, id, scalingplanpooledschedule.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, scalingplanpooledschedule.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ScalingPlanPooledScheduleClient.Update` + +```go +ctx := context.TODO() +id := scalingplanpooledschedule.NewPooledScheduleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "scalingPlanName", "pooledScheduleName") + +payload := scalingplanpooledschedule.ScalingPlanPooledSchedulePatch{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/client.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/client.go new file mode 100644 index 00000000000..3822aff5059 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/client.go @@ -0,0 +1,26 @@ +package scalingplanpooledschedule + +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 ScalingPlanPooledScheduleClient struct { + Client *resourcemanager.Client +} + +func NewScalingPlanPooledScheduleClientWithBaseURI(sdkApi sdkEnv.Api) (*ScalingPlanPooledScheduleClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "scalingplanpooledschedule", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ScalingPlanPooledScheduleClient: %+v", err) + } + + return &ScalingPlanPooledScheduleClient{ + Client: client, + }, nil +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/constants.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/constants.go new file mode 100644 index 00000000000..f0b980f4579 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/constants.go @@ -0,0 +1,148 @@ +package scalingplanpooledschedule + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DayOfWeek string + +const ( + DayOfWeekFriday DayOfWeek = "Friday" + DayOfWeekMonday DayOfWeek = "Monday" + DayOfWeekSaturday DayOfWeek = "Saturday" + DayOfWeekSunday DayOfWeek = "Sunday" + DayOfWeekThursday DayOfWeek = "Thursday" + DayOfWeekTuesday DayOfWeek = "Tuesday" + DayOfWeekWednesday DayOfWeek = "Wednesday" +) + +func PossibleValuesForDayOfWeek() []string { + return []string{ + string(DayOfWeekFriday), + string(DayOfWeekMonday), + string(DayOfWeekSaturday), + string(DayOfWeekSunday), + string(DayOfWeekThursday), + string(DayOfWeekTuesday), + string(DayOfWeekWednesday), + } +} + +func (s *DayOfWeek) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDayOfWeek(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDayOfWeek(input string) (*DayOfWeek, error) { + vals := map[string]DayOfWeek{ + "friday": DayOfWeekFriday, + "monday": DayOfWeekMonday, + "saturday": DayOfWeekSaturday, + "sunday": DayOfWeekSunday, + "thursday": DayOfWeekThursday, + "tuesday": DayOfWeekTuesday, + "wednesday": DayOfWeekWednesday, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DayOfWeek(input) + return &out, nil +} + +type SessionHostLoadBalancingAlgorithm string + +const ( + SessionHostLoadBalancingAlgorithmBreadthFirst SessionHostLoadBalancingAlgorithm = "BreadthFirst" + SessionHostLoadBalancingAlgorithmDepthFirst SessionHostLoadBalancingAlgorithm = "DepthFirst" +) + +func PossibleValuesForSessionHostLoadBalancingAlgorithm() []string { + return []string{ + string(SessionHostLoadBalancingAlgorithmBreadthFirst), + string(SessionHostLoadBalancingAlgorithmDepthFirst), + } +} + +func (s *SessionHostLoadBalancingAlgorithm) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSessionHostLoadBalancingAlgorithm(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSessionHostLoadBalancingAlgorithm(input string) (*SessionHostLoadBalancingAlgorithm, error) { + vals := map[string]SessionHostLoadBalancingAlgorithm{ + "breadthfirst": SessionHostLoadBalancingAlgorithmBreadthFirst, + "depthfirst": SessionHostLoadBalancingAlgorithmDepthFirst, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SessionHostLoadBalancingAlgorithm(input) + return &out, nil +} + +type StopHostsWhen string + +const ( + StopHostsWhenZeroActiveSessions StopHostsWhen = "ZeroActiveSessions" + StopHostsWhenZeroSessions StopHostsWhen = "ZeroSessions" +) + +func PossibleValuesForStopHostsWhen() []string { + return []string{ + string(StopHostsWhenZeroActiveSessions), + string(StopHostsWhenZeroSessions), + } +} + +func (s *StopHostsWhen) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStopHostsWhen(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStopHostsWhen(input string) (*StopHostsWhen, error) { + vals := map[string]StopHostsWhen{ + "zeroactivesessions": StopHostsWhenZeroActiveSessions, + "zerosessions": StopHostsWhenZeroSessions, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StopHostsWhen(input) + return &out, nil +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/id_pooledschedule.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/id_pooledschedule.go new file mode 100644 index 00000000000..4e8f4e64453 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/id_pooledschedule.go @@ -0,0 +1,139 @@ +package scalingplanpooledschedule + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PooledScheduleId{}) +} + +var _ resourceids.ResourceId = &PooledScheduleId{} + +// PooledScheduleId is a struct representing the Resource ID for a Pooled Schedule +type PooledScheduleId struct { + SubscriptionId string + ResourceGroupName string + ScalingPlanName string + PooledScheduleName string +} + +// NewPooledScheduleID returns a new PooledScheduleId struct +func NewPooledScheduleID(subscriptionId string, resourceGroupName string, scalingPlanName string, pooledScheduleName string) PooledScheduleId { + return PooledScheduleId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ScalingPlanName: scalingPlanName, + PooledScheduleName: pooledScheduleName, + } +} + +// ParsePooledScheduleID parses 'input' into a PooledScheduleId +func ParsePooledScheduleID(input string) (*PooledScheduleId, error) { + parser := resourceids.NewParserFromResourceIdType(&PooledScheduleId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PooledScheduleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePooledScheduleIDInsensitively parses 'input' case-insensitively into a PooledScheduleId +// note: this method should only be used for API response data and not user input +func ParsePooledScheduleIDInsensitively(input string) (*PooledScheduleId, error) { + parser := resourceids.NewParserFromResourceIdType(&PooledScheduleId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PooledScheduleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PooledScheduleId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ScalingPlanName, ok = input.Parsed["scalingPlanName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "scalingPlanName", input) + } + + if id.PooledScheduleName, ok = input.Parsed["pooledScheduleName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "pooledScheduleName", input) + } + + return nil +} + +// ValidatePooledScheduleID checks that 'input' can be parsed as a Pooled Schedule ID +func ValidatePooledScheduleID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParsePooledScheduleID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Pooled Schedule ID +func (id PooledScheduleId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DesktopVirtualization/scalingPlans/%s/pooledSchedules/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ScalingPlanName, id.PooledScheduleName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Pooled Schedule ID +func (id PooledScheduleId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDesktopVirtualization", "Microsoft.DesktopVirtualization", "Microsoft.DesktopVirtualization"), + resourceids.StaticSegment("staticScalingPlans", "scalingPlans", "scalingPlans"), + resourceids.UserSpecifiedSegment("scalingPlanName", "scalingPlanName"), + resourceids.StaticSegment("staticPooledSchedules", "pooledSchedules", "pooledSchedules"), + resourceids.UserSpecifiedSegment("pooledScheduleName", "pooledScheduleName"), + } +} + +// String returns a human-readable description of this Pooled Schedule ID +func (id PooledScheduleId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Scaling Plan Name: %q", id.ScalingPlanName), + fmt.Sprintf("Pooled Schedule Name: %q", id.PooledScheduleName), + } + return fmt.Sprintf("Pooled Schedule (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/id_pooledschedule_test.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/id_pooledschedule_test.go new file mode 100644 index 00000000000..9ab45df15b4 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/id_pooledschedule_test.go @@ -0,0 +1,327 @@ +package scalingplanpooledschedule + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PooledScheduleId{} + +func TestNewPooledScheduleID(t *testing.T) { + id := NewPooledScheduleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "scalingPlanName", "pooledScheduleName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ScalingPlanName != "scalingPlanName" { + t.Fatalf("Expected %q but got %q for Segment 'ScalingPlanName'", id.ScalingPlanName, "scalingPlanName") + } + + if id.PooledScheduleName != "pooledScheduleName" { + t.Fatalf("Expected %q but got %q for Segment 'PooledScheduleName'", id.PooledScheduleName, "pooledScheduleName") + } +} + +func TestFormatPooledScheduleID(t *testing.T) { + actual := NewPooledScheduleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "scalingPlanName", "pooledScheduleName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/scalingPlans/scalingPlanName/pooledSchedules/pooledScheduleName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePooledScheduleID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PooledScheduleId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/scalingPlans", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/scalingPlans/scalingPlanName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/scalingPlans/scalingPlanName/pooledSchedules", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/scalingPlans/scalingPlanName/pooledSchedules/pooledScheduleName", + Expected: &PooledScheduleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ScalingPlanName: "scalingPlanName", + PooledScheduleName: "pooledScheduleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/scalingPlans/scalingPlanName/pooledSchedules/pooledScheduleName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePooledScheduleID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ScalingPlanName != v.Expected.ScalingPlanName { + t.Fatalf("Expected %q but got %q for ScalingPlanName", v.Expected.ScalingPlanName, actual.ScalingPlanName) + } + + if actual.PooledScheduleName != v.Expected.PooledScheduleName { + t.Fatalf("Expected %q but got %q for PooledScheduleName", v.Expected.PooledScheduleName, actual.PooledScheduleName) + } + + } +} + +func TestParsePooledScheduleIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PooledScheduleId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/scalingPlans", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/sCaLiNgPlAnS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/scalingPlans/scalingPlanName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/sCaLiNgPlAnS/sCaLiNgPlAnNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/scalingPlans/scalingPlanName/pooledSchedules", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/sCaLiNgPlAnS/sCaLiNgPlAnNaMe/pOoLeDsChEdUlEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/scalingPlans/scalingPlanName/pooledSchedules/pooledScheduleName", + Expected: &PooledScheduleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ScalingPlanName: "scalingPlanName", + PooledScheduleName: "pooledScheduleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/scalingPlans/scalingPlanName/pooledSchedules/pooledScheduleName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/sCaLiNgPlAnS/sCaLiNgPlAnNaMe/pOoLeDsChEdUlEs/pOoLeDsChEdUlEnAmE", + Expected: &PooledScheduleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ScalingPlanName: "sCaLiNgPlAnNaMe", + PooledScheduleName: "pOoLeDsChEdUlEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/sCaLiNgPlAnS/sCaLiNgPlAnNaMe/pOoLeDsChEdUlEs/pOoLeDsChEdUlEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePooledScheduleIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ScalingPlanName != v.Expected.ScalingPlanName { + t.Fatalf("Expected %q but got %q for ScalingPlanName", v.Expected.ScalingPlanName, actual.ScalingPlanName) + } + + if actual.PooledScheduleName != v.Expected.PooledScheduleName { + t.Fatalf("Expected %q but got %q for PooledScheduleName", v.Expected.PooledScheduleName, actual.PooledScheduleName) + } + + } +} + +func TestSegmentsForPooledScheduleId(t *testing.T) { + segments := PooledScheduleId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PooledScheduleId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/id_scalingplan.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/id_scalingplan.go new file mode 100644 index 00000000000..ab6b67a872a --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/id_scalingplan.go @@ -0,0 +1,130 @@ +package scalingplanpooledschedule + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ScalingPlanId{}) +} + +var _ resourceids.ResourceId = &ScalingPlanId{} + +// ScalingPlanId is a struct representing the Resource ID for a Scaling Plan +type ScalingPlanId struct { + SubscriptionId string + ResourceGroupName string + ScalingPlanName string +} + +// NewScalingPlanID returns a new ScalingPlanId struct +func NewScalingPlanID(subscriptionId string, resourceGroupName string, scalingPlanName string) ScalingPlanId { + return ScalingPlanId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ScalingPlanName: scalingPlanName, + } +} + +// ParseScalingPlanID parses 'input' into a ScalingPlanId +func ParseScalingPlanID(input string) (*ScalingPlanId, error) { + parser := resourceids.NewParserFromResourceIdType(&ScalingPlanId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ScalingPlanId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseScalingPlanIDInsensitively parses 'input' case-insensitively into a ScalingPlanId +// note: this method should only be used for API response data and not user input +func ParseScalingPlanIDInsensitively(input string) (*ScalingPlanId, error) { + parser := resourceids.NewParserFromResourceIdType(&ScalingPlanId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ScalingPlanId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ScalingPlanId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ScalingPlanName, ok = input.Parsed["scalingPlanName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "scalingPlanName", input) + } + + return nil +} + +// ValidateScalingPlanID checks that 'input' can be parsed as a Scaling Plan ID +func ValidateScalingPlanID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseScalingPlanID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Scaling Plan ID +func (id ScalingPlanId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DesktopVirtualization/scalingPlans/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ScalingPlanName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Scaling Plan ID +func (id ScalingPlanId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDesktopVirtualization", "Microsoft.DesktopVirtualization", "Microsoft.DesktopVirtualization"), + resourceids.StaticSegment("staticScalingPlans", "scalingPlans", "scalingPlans"), + resourceids.UserSpecifiedSegment("scalingPlanName", "scalingPlanName"), + } +} + +// String returns a human-readable description of this Scaling Plan ID +func (id ScalingPlanId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Scaling Plan Name: %q", id.ScalingPlanName), + } + return fmt.Sprintf("Scaling Plan (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/id_scalingplan_test.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/id_scalingplan_test.go new file mode 100644 index 00000000000..04cbbd034c1 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/id_scalingplan_test.go @@ -0,0 +1,282 @@ +package scalingplanpooledschedule + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ScalingPlanId{} + +func TestNewScalingPlanID(t *testing.T) { + id := NewScalingPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "scalingPlanName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ScalingPlanName != "scalingPlanName" { + t.Fatalf("Expected %q but got %q for Segment 'ScalingPlanName'", id.ScalingPlanName, "scalingPlanName") + } +} + +func TestFormatScalingPlanID(t *testing.T) { + actual := NewScalingPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "scalingPlanName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/scalingPlans/scalingPlanName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseScalingPlanID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ScalingPlanId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/scalingPlans", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/scalingPlans/scalingPlanName", + Expected: &ScalingPlanId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ScalingPlanName: "scalingPlanName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/scalingPlans/scalingPlanName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseScalingPlanID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ScalingPlanName != v.Expected.ScalingPlanName { + t.Fatalf("Expected %q but got %q for ScalingPlanName", v.Expected.ScalingPlanName, actual.ScalingPlanName) + } + + } +} + +func TestParseScalingPlanIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ScalingPlanId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/scalingPlans", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/sCaLiNgPlAnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/scalingPlans/scalingPlanName", + Expected: &ScalingPlanId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ScalingPlanName: "scalingPlanName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/scalingPlans/scalingPlanName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/sCaLiNgPlAnS/sCaLiNgPlAnNaMe", + Expected: &ScalingPlanId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ScalingPlanName: "sCaLiNgPlAnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/sCaLiNgPlAnS/sCaLiNgPlAnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseScalingPlanIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ScalingPlanName != v.Expected.ScalingPlanName { + t.Fatalf("Expected %q but got %q for ScalingPlanName", v.Expected.ScalingPlanName, actual.ScalingPlanName) + } + + } +} + +func TestSegmentsForScalingPlanId(t *testing.T) { + segments := ScalingPlanId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ScalingPlanId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/method_create.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/method_create.go new file mode 100644 index 00000000000..c00f1038f65 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/method_create.go @@ -0,0 +1,58 @@ +package scalingplanpooledschedule + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ScalingPlanPooledSchedule +} + +// Create ... +func (c ScalingPlanPooledScheduleClient) Create(ctx context.Context, id PooledScheduleId, input ScalingPlanPooledSchedule) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ScalingPlanPooledSchedule + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/method_delete.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/method_delete.go new file mode 100644 index 00000000000..3efa3eab88c --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/method_delete.go @@ -0,0 +1,47 @@ +package scalingplanpooledschedule + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ScalingPlanPooledScheduleClient) Delete(ctx context.Context, id PooledScheduleId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/method_get.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/method_get.go new file mode 100644 index 00000000000..be6d9a31b6c --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/method_get.go @@ -0,0 +1,53 @@ +package scalingplanpooledschedule + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *ScalingPlanPooledSchedule +} + +// Get ... +func (c ScalingPlanPooledScheduleClient) Get(ctx context.Context, id PooledScheduleId) (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 ScalingPlanPooledSchedule + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/method_list.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/method_list.go new file mode 100644 index 00000000000..b7b9f9e21a4 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/method_list.go @@ -0,0 +1,142 @@ +package scalingplanpooledschedule + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ScalingPlanPooledSchedule +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ScalingPlanPooledSchedule +} + +type ListOperationOptions struct { + InitialSkip *int64 + IsDescending *bool + PageSize *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.InitialSkip != nil { + out.Append("initialSkip", fmt.Sprintf("%v", *o.InitialSkip)) + } + if o.IsDescending != nil { + out.Append("isDescending", fmt.Sprintf("%v", *o.IsDescending)) + } + if o.PageSize != nil { + out.Append("pageSize", fmt.Sprintf("%v", *o.PageSize)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ScalingPlanPooledScheduleClient) List(ctx context.Context, id ScalingPlanId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/pooledSchedules", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ScalingPlanPooledSchedule `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ScalingPlanPooledScheduleClient) ListComplete(ctx context.Context, id ScalingPlanId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, ScalingPlanPooledScheduleOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ScalingPlanPooledScheduleClient) ListCompleteMatchingPredicate(ctx context.Context, id ScalingPlanId, options ListOperationOptions, predicate ScalingPlanPooledScheduleOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ScalingPlanPooledSchedule, 0) + + resp, err := c.List(ctx, id, options) + 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 = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/method_update.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/method_update.go new file mode 100644 index 00000000000..d3ead6728bf --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/method_update.go @@ -0,0 +1,57 @@ +package scalingplanpooledschedule + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ScalingPlanPooledSchedule +} + +// Update ... +func (c ScalingPlanPooledScheduleClient) Update(ctx context.Context, id PooledScheduleId, input ScalingPlanPooledSchedulePatch) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ScalingPlanPooledSchedule + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/model_scalingplanpooledschedule.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/model_scalingplanpooledschedule.go new file mode 100644 index 00000000000..f2ec79768a6 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/model_scalingplanpooledschedule.go @@ -0,0 +1,16 @@ +package scalingplanpooledschedule + +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 ScalingPlanPooledSchedule struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties ScalingPlanPooledScheduleProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/model_scalingplanpooledschedulepatch.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/model_scalingplanpooledschedulepatch.go new file mode 100644 index 00000000000..c6e33046010 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/model_scalingplanpooledschedulepatch.go @@ -0,0 +1,16 @@ +package scalingplanpooledschedule + +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 ScalingPlanPooledSchedulePatch struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ScalingPlanPooledScheduleProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/model_scalingplanpooledscheduleproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/model_scalingplanpooledscheduleproperties.go new file mode 100644 index 00000000000..d646b9e2f16 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/model_scalingplanpooledscheduleproperties.go @@ -0,0 +1,24 @@ +package scalingplanpooledschedule + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScalingPlanPooledScheduleProperties struct { + DaysOfWeek *[]DayOfWeek `json:"daysOfWeek,omitempty"` + OffPeakLoadBalancingAlgorithm *SessionHostLoadBalancingAlgorithm `json:"offPeakLoadBalancingAlgorithm,omitempty"` + OffPeakStartTime *Time `json:"offPeakStartTime,omitempty"` + PeakLoadBalancingAlgorithm *SessionHostLoadBalancingAlgorithm `json:"peakLoadBalancingAlgorithm,omitempty"` + PeakStartTime *Time `json:"peakStartTime,omitempty"` + RampDownCapacityThresholdPct *int64 `json:"rampDownCapacityThresholdPct,omitempty"` + RampDownForceLogoffUsers *bool `json:"rampDownForceLogoffUsers,omitempty"` + RampDownLoadBalancingAlgorithm *SessionHostLoadBalancingAlgorithm `json:"rampDownLoadBalancingAlgorithm,omitempty"` + RampDownMinimumHostsPct *int64 `json:"rampDownMinimumHostsPct,omitempty"` + RampDownNotificationMessage *string `json:"rampDownNotificationMessage,omitempty"` + RampDownStartTime *Time `json:"rampDownStartTime,omitempty"` + RampDownStopHostsWhen *StopHostsWhen `json:"rampDownStopHostsWhen,omitempty"` + RampDownWaitTimeMinutes *int64 `json:"rampDownWaitTimeMinutes,omitempty"` + RampUpCapacityThresholdPct *int64 `json:"rampUpCapacityThresholdPct,omitempty"` + RampUpLoadBalancingAlgorithm *SessionHostLoadBalancingAlgorithm `json:"rampUpLoadBalancingAlgorithm,omitempty"` + RampUpMinimumHostsPct *int64 `json:"rampUpMinimumHostsPct,omitempty"` + RampUpStartTime *Time `json:"rampUpStartTime,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/model_time.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/model_time.go new file mode 100644 index 00000000000..4bcac98fb45 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/model_time.go @@ -0,0 +1,9 @@ +package scalingplanpooledschedule + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Time struct { + Hour int64 `json:"hour"` + Minute int64 `json:"minute"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/predicates.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/predicates.go new file mode 100644 index 00000000000..9ff82179406 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/predicates.go @@ -0,0 +1,27 @@ +package scalingplanpooledschedule + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScalingPlanPooledScheduleOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p ScalingPlanPooledScheduleOperationPredicate) Matches(input ScalingPlanPooledSchedule) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/version.go b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/version.go new file mode 100644 index 00000000000..980b8afeed1 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/scalingplanpooledschedule/version.go @@ -0,0 +1,10 @@ +package scalingplanpooledschedule + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-08-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/scalingplanpooledschedule/2024-04-08-preview" +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/README.md b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/README.md new file mode 100644 index 00000000000..a92ac1a3b5b --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/README.md @@ -0,0 +1,106 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost` Documentation + +The `sessionhost` SDK allows for interaction with Azure Resource Manager `desktopvirtualization` (API Version `2024-04-08-preview`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost" +``` + + +### Client Initialization + +```go +client := sessionhost.NewSessionHostClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SessionHostClient.Delete` + +```go +ctx := context.TODO() +id := sessionhost.NewSessionHostID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName", "sessionHostName") + +read, err := client.Delete(ctx, id, sessionhost.DefaultDeleteOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SessionHostClient.Get` + +```go +ctx := context.TODO() +id := sessionhost.NewSessionHostID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName", "sessionHostName") + +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: `SessionHostClient.List` + +```go +ctx := context.TODO() +id := sessionhost.NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName") + +// alternatively `client.List(ctx, id, sessionhost.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, sessionhost.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `SessionHostClient.RetryProvisioning` + +```go +ctx := context.TODO() +id := sessionhost.NewSessionHostID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName", "sessionHostName") + +read, err := client.RetryProvisioning(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SessionHostClient.Update` + +```go +ctx := context.TODO() +id := sessionhost.NewSessionHostID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName", "sessionHostName") + +payload := sessionhost.SessionHostPatch{ + // ... +} + + +read, err := client.Update(ctx, id, payload, sessionhost.DefaultUpdateOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/client.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/client.go new file mode 100644 index 00000000000..ced1537db50 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/client.go @@ -0,0 +1,26 @@ +package sessionhost + +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 SessionHostClient struct { + Client *resourcemanager.Client +} + +func NewSessionHostClientWithBaseURI(sdkApi sdkEnv.Api) (*SessionHostClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "sessionhost", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SessionHostClient: %+v", err) + } + + return &SessionHostClient{ + Client: client, + }, nil +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/constants.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/constants.go new file mode 100644 index 00000000000..d48400f37c2 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/constants.go @@ -0,0 +1,246 @@ +package sessionhost + +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 HealthCheckName string + +const ( + HealthCheckNameAppAttachHealthCheck HealthCheckName = "AppAttachHealthCheck" + HealthCheckNameDomainJoinedCheck HealthCheckName = "DomainJoinedCheck" + HealthCheckNameDomainReachable HealthCheckName = "DomainReachable" + HealthCheckNameDomainTrustCheck HealthCheckName = "DomainTrustCheck" + HealthCheckNameFSLogixHealthCheck HealthCheckName = "FSLogixHealthCheck" + HealthCheckNameMetaDataServiceCheck HealthCheckName = "MetaDataServiceCheck" + HealthCheckNameMonitoringAgentCheck HealthCheckName = "MonitoringAgentCheck" + HealthCheckNameSupportedEncryptionCheck HealthCheckName = "SupportedEncryptionCheck" + HealthCheckNameSxSStackListenerCheck HealthCheckName = "SxSStackListenerCheck" + HealthCheckNameURLsAccessibleCheck HealthCheckName = "UrlsAccessibleCheck" + HealthCheckNameWebRTCRedirectorCheck HealthCheckName = "WebRTCRedirectorCheck" +) + +func PossibleValuesForHealthCheckName() []string { + return []string{ + string(HealthCheckNameAppAttachHealthCheck), + string(HealthCheckNameDomainJoinedCheck), + string(HealthCheckNameDomainReachable), + string(HealthCheckNameDomainTrustCheck), + string(HealthCheckNameFSLogixHealthCheck), + string(HealthCheckNameMetaDataServiceCheck), + string(HealthCheckNameMonitoringAgentCheck), + string(HealthCheckNameSupportedEncryptionCheck), + string(HealthCheckNameSxSStackListenerCheck), + string(HealthCheckNameURLsAccessibleCheck), + string(HealthCheckNameWebRTCRedirectorCheck), + } +} + +func (s *HealthCheckName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHealthCheckName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHealthCheckName(input string) (*HealthCheckName, error) { + vals := map[string]HealthCheckName{ + "appattachhealthcheck": HealthCheckNameAppAttachHealthCheck, + "domainjoinedcheck": HealthCheckNameDomainJoinedCheck, + "domainreachable": HealthCheckNameDomainReachable, + "domaintrustcheck": HealthCheckNameDomainTrustCheck, + "fslogixhealthcheck": HealthCheckNameFSLogixHealthCheck, + "metadataservicecheck": HealthCheckNameMetaDataServiceCheck, + "monitoringagentcheck": HealthCheckNameMonitoringAgentCheck, + "supportedencryptioncheck": HealthCheckNameSupportedEncryptionCheck, + "sxsstacklistenercheck": HealthCheckNameSxSStackListenerCheck, + "urlsaccessiblecheck": HealthCheckNameURLsAccessibleCheck, + "webrtcredirectorcheck": HealthCheckNameWebRTCRedirectorCheck, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HealthCheckName(input) + return &out, nil +} + +type HealthCheckResult string + +const ( + HealthCheckResultHealthCheckFailed HealthCheckResult = "HealthCheckFailed" + HealthCheckResultHealthCheckSucceeded HealthCheckResult = "HealthCheckSucceeded" + HealthCheckResultSessionHostShutdown HealthCheckResult = "SessionHostShutdown" + HealthCheckResultUnknown HealthCheckResult = "Unknown" +) + +func PossibleValuesForHealthCheckResult() []string { + return []string{ + string(HealthCheckResultHealthCheckFailed), + string(HealthCheckResultHealthCheckSucceeded), + string(HealthCheckResultSessionHostShutdown), + string(HealthCheckResultUnknown), + } +} + +func (s *HealthCheckResult) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHealthCheckResult(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHealthCheckResult(input string) (*HealthCheckResult, error) { + vals := map[string]HealthCheckResult{ + "healthcheckfailed": HealthCheckResultHealthCheckFailed, + "healthchecksucceeded": HealthCheckResultHealthCheckSucceeded, + "sessionhostshutdown": HealthCheckResultSessionHostShutdown, + "unknown": HealthCheckResultUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HealthCheckResult(input) + return &out, nil +} + +type Status string + +const ( + StatusAvailable Status = "Available" + StatusDisconnected Status = "Disconnected" + StatusDomainTrustRelationshipLost Status = "DomainTrustRelationshipLost" + StatusFSLogixNotHealthy Status = "FSLogixNotHealthy" + StatusNeedsAssistance Status = "NeedsAssistance" + StatusNoHeartbeat Status = "NoHeartbeat" + StatusNotJoinedToDomain Status = "NotJoinedToDomain" + StatusShutdown Status = "Shutdown" + StatusSxSStackListenerNotReady Status = "SxSStackListenerNotReady" + StatusUnavailable Status = "Unavailable" + StatusUpgradeFailed Status = "UpgradeFailed" + StatusUpgrading Status = "Upgrading" +) + +func PossibleValuesForStatus() []string { + return []string{ + string(StatusAvailable), + string(StatusDisconnected), + string(StatusDomainTrustRelationshipLost), + string(StatusFSLogixNotHealthy), + string(StatusNeedsAssistance), + string(StatusNoHeartbeat), + string(StatusNotJoinedToDomain), + string(StatusShutdown), + string(StatusSxSStackListenerNotReady), + string(StatusUnavailable), + string(StatusUpgradeFailed), + string(StatusUpgrading), + } +} + +func (s *Status) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStatus(input string) (*Status, error) { + vals := map[string]Status{ + "available": StatusAvailable, + "disconnected": StatusDisconnected, + "domaintrustrelationshiplost": StatusDomainTrustRelationshipLost, + "fslogixnothealthy": StatusFSLogixNotHealthy, + "needsassistance": StatusNeedsAssistance, + "noheartbeat": StatusNoHeartbeat, + "notjoinedtodomain": StatusNotJoinedToDomain, + "shutdown": StatusShutdown, + "sxsstacklistenernotready": StatusSxSStackListenerNotReady, + "unavailable": StatusUnavailable, + "upgradefailed": StatusUpgradeFailed, + "upgrading": StatusUpgrading, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Status(input) + return &out, nil +} + +type UpdateState string + +const ( + UpdateStateFailed UpdateState = "Failed" + UpdateStateInitial UpdateState = "Initial" + UpdateStatePending UpdateState = "Pending" + UpdateStateStarted UpdateState = "Started" + UpdateStateSucceeded UpdateState = "Succeeded" +) + +func PossibleValuesForUpdateState() []string { + return []string{ + string(UpdateStateFailed), + string(UpdateStateInitial), + string(UpdateStatePending), + string(UpdateStateStarted), + string(UpdateStateSucceeded), + } +} + +func (s *UpdateState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUpdateState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUpdateState(input string) (*UpdateState, error) { + vals := map[string]UpdateState{ + "failed": UpdateStateFailed, + "initial": UpdateStateInitial, + "pending": UpdateStatePending, + "started": UpdateStateStarted, + "succeeded": UpdateStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UpdateState(input) + return &out, nil +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/id_hostpool.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/id_hostpool.go new file mode 100644 index 00000000000..5ff508f7643 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/id_hostpool.go @@ -0,0 +1,130 @@ +package sessionhost + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&HostPoolId{}) +} + +var _ resourceids.ResourceId = &HostPoolId{} + +// HostPoolId is a struct representing the Resource ID for a Host Pool +type HostPoolId struct { + SubscriptionId string + ResourceGroupName string + HostPoolName string +} + +// NewHostPoolID returns a new HostPoolId struct +func NewHostPoolID(subscriptionId string, resourceGroupName string, hostPoolName string) HostPoolId { + return HostPoolId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + HostPoolName: hostPoolName, + } +} + +// ParseHostPoolID parses 'input' into a HostPoolId +func ParseHostPoolID(input string) (*HostPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostPoolId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostPoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseHostPoolIDInsensitively parses 'input' case-insensitively into a HostPoolId +// note: this method should only be used for API response data and not user input +func ParseHostPoolIDInsensitively(input string) (*HostPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostPoolId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostPoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *HostPoolId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.HostPoolName, ok = input.Parsed["hostPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hostPoolName", input) + } + + return nil +} + +// ValidateHostPoolID checks that 'input' can be parsed as a Host Pool ID +func ValidateHostPoolID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseHostPoolID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Host Pool ID +func (id HostPoolId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DesktopVirtualization/hostPools/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.HostPoolName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Host Pool ID +func (id HostPoolId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDesktopVirtualization", "Microsoft.DesktopVirtualization", "Microsoft.DesktopVirtualization"), + resourceids.StaticSegment("staticHostPools", "hostPools", "hostPools"), + resourceids.UserSpecifiedSegment("hostPoolName", "hostPoolName"), + } +} + +// String returns a human-readable description of this Host Pool ID +func (id HostPoolId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Host Pool Name: %q", id.HostPoolName), + } + return fmt.Sprintf("Host Pool (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/id_hostpool_test.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/id_hostpool_test.go new file mode 100644 index 00000000000..bc868d8c47b --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/id_hostpool_test.go @@ -0,0 +1,282 @@ +package sessionhost + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &HostPoolId{} + +func TestNewHostPoolID(t *testing.T) { + id := NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.HostPoolName != "hostPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'HostPoolName'", id.HostPoolName, "hostPoolName") + } +} + +func TestFormatHostPoolID(t *testing.T) { + actual := NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseHostPoolID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostPoolId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName", + Expected: &HostPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostPoolName: "hostPoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostPoolID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostPoolName != v.Expected.HostPoolName { + t.Fatalf("Expected %q but got %q for HostPoolName", v.Expected.HostPoolName, actual.HostPoolName) + } + + } +} + +func TestParseHostPoolIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostPoolId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName", + Expected: &HostPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostPoolName: "hostPoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs/hOsTpOoLnAmE", + Expected: &HostPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + HostPoolName: "hOsTpOoLnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs/hOsTpOoLnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostPoolIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostPoolName != v.Expected.HostPoolName { + t.Fatalf("Expected %q but got %q for HostPoolName", v.Expected.HostPoolName, actual.HostPoolName) + } + + } +} + +func TestSegmentsForHostPoolId(t *testing.T) { + segments := HostPoolId{}.Segments() + if len(segments) == 0 { + t.Fatalf("HostPoolId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/id_sessionhost.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/id_sessionhost.go new file mode 100644 index 00000000000..487a32218fd --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/id_sessionhost.go @@ -0,0 +1,139 @@ +package sessionhost + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SessionHostId{}) +} + +var _ resourceids.ResourceId = &SessionHostId{} + +// SessionHostId is a struct representing the Resource ID for a Session Host +type SessionHostId struct { + SubscriptionId string + ResourceGroupName string + HostPoolName string + SessionHostName string +} + +// NewSessionHostID returns a new SessionHostId struct +func NewSessionHostID(subscriptionId string, resourceGroupName string, hostPoolName string, sessionHostName string) SessionHostId { + return SessionHostId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + HostPoolName: hostPoolName, + SessionHostName: sessionHostName, + } +} + +// ParseSessionHostID parses 'input' into a SessionHostId +func ParseSessionHostID(input string) (*SessionHostId, error) { + parser := resourceids.NewParserFromResourceIdType(&SessionHostId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SessionHostId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSessionHostIDInsensitively parses 'input' case-insensitively into a SessionHostId +// note: this method should only be used for API response data and not user input +func ParseSessionHostIDInsensitively(input string) (*SessionHostId, error) { + parser := resourceids.NewParserFromResourceIdType(&SessionHostId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SessionHostId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SessionHostId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.HostPoolName, ok = input.Parsed["hostPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hostPoolName", input) + } + + if id.SessionHostName, ok = input.Parsed["sessionHostName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "sessionHostName", input) + } + + return nil +} + +// ValidateSessionHostID checks that 'input' can be parsed as a Session Host ID +func ValidateSessionHostID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSessionHostID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Session Host ID +func (id SessionHostId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DesktopVirtualization/hostPools/%s/sessionHosts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.HostPoolName, id.SessionHostName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Session Host ID +func (id SessionHostId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDesktopVirtualization", "Microsoft.DesktopVirtualization", "Microsoft.DesktopVirtualization"), + resourceids.StaticSegment("staticHostPools", "hostPools", "hostPools"), + resourceids.UserSpecifiedSegment("hostPoolName", "hostPoolName"), + resourceids.StaticSegment("staticSessionHosts", "sessionHosts", "sessionHosts"), + resourceids.UserSpecifiedSegment("sessionHostName", "sessionHostName"), + } +} + +// String returns a human-readable description of this Session Host ID +func (id SessionHostId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Host Pool Name: %q", id.HostPoolName), + fmt.Sprintf("Session Host Name: %q", id.SessionHostName), + } + return fmt.Sprintf("Session Host (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/id_sessionhost_test.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/id_sessionhost_test.go new file mode 100644 index 00000000000..cc6c41883fa --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/id_sessionhost_test.go @@ -0,0 +1,327 @@ +package sessionhost + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SessionHostId{} + +func TestNewSessionHostID(t *testing.T) { + id := NewSessionHostID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName", "sessionHostName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.HostPoolName != "hostPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'HostPoolName'", id.HostPoolName, "hostPoolName") + } + + if id.SessionHostName != "sessionHostName" { + t.Fatalf("Expected %q but got %q for Segment 'SessionHostName'", id.SessionHostName, "sessionHostName") + } +} + +func TestFormatSessionHostID(t *testing.T) { + actual := NewSessionHostID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName", "sessionHostName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/sessionHosts/sessionHostName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSessionHostID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SessionHostId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/sessionHosts", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/sessionHosts/sessionHostName", + Expected: &SessionHostId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostPoolName: "hostPoolName", + SessionHostName: "sessionHostName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/sessionHosts/sessionHostName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSessionHostID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostPoolName != v.Expected.HostPoolName { + t.Fatalf("Expected %q but got %q for HostPoolName", v.Expected.HostPoolName, actual.HostPoolName) + } + + if actual.SessionHostName != v.Expected.SessionHostName { + t.Fatalf("Expected %q but got %q for SessionHostName", v.Expected.SessionHostName, actual.SessionHostName) + } + + } +} + +func TestParseSessionHostIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SessionHostId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs/hOsTpOoLnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/sessionHosts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs/hOsTpOoLnAmE/sEsSiOnHoStS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/sessionHosts/sessionHostName", + Expected: &SessionHostId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostPoolName: "hostPoolName", + SessionHostName: "sessionHostName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/sessionHosts/sessionHostName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs/hOsTpOoLnAmE/sEsSiOnHoStS/sEsSiOnHoStNaMe", + Expected: &SessionHostId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + HostPoolName: "hOsTpOoLnAmE", + SessionHostName: "sEsSiOnHoStNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs/hOsTpOoLnAmE/sEsSiOnHoStS/sEsSiOnHoStNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSessionHostIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostPoolName != v.Expected.HostPoolName { + t.Fatalf("Expected %q but got %q for HostPoolName", v.Expected.HostPoolName, actual.HostPoolName) + } + + if actual.SessionHostName != v.Expected.SessionHostName { + t.Fatalf("Expected %q but got %q for SessionHostName", v.Expected.SessionHostName, actual.SessionHostName) + } + + } +} + +func TestSegmentsForSessionHostId(t *testing.T) { + segments := SessionHostId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SessionHostId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/method_delete.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/method_delete.go new file mode 100644 index 00000000000..9eebfcf3a86 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/method_delete.go @@ -0,0 +1,77 @@ +package sessionhost + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + Force *bool +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Force != nil { + out.Append("force", fmt.Sprintf("%v", *o.Force)) + } + return &out +} + +// Delete ... +func (c SessionHostClient) Delete(ctx context.Context, id SessionHostId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + 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/desktopvirtualization/2024-04-08-preview/sessionhost/method_get.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/method_get.go new file mode 100644 index 00000000000..32d3a452e0b --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/method_get.go @@ -0,0 +1,53 @@ +package sessionhost + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *SessionHost +} + +// Get ... +func (c SessionHostClient) Get(ctx context.Context, id SessionHostId) (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 SessionHost + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/method_list.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/method_list.go new file mode 100644 index 00000000000..ee42732f14f --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/method_list.go @@ -0,0 +1,146 @@ +package sessionhost + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SessionHost +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []SessionHost +} + +type ListOperationOptions struct { + InitialSkip *int64 + IsDescending *bool + PageSize *int64 + VMPath *string +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.InitialSkip != nil { + out.Append("initialSkip", fmt.Sprintf("%v", *o.InitialSkip)) + } + if o.IsDescending != nil { + out.Append("isDescending", fmt.Sprintf("%v", *o.IsDescending)) + } + if o.PageSize != nil { + out.Append("pageSize", fmt.Sprintf("%v", *o.PageSize)) + } + if o.VMPath != nil { + out.Append("vmPath", fmt.Sprintf("%v", *o.VMPath)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c SessionHostClient) List(ctx context.Context, id HostPoolId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/sessionHosts", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SessionHost `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c SessionHostClient) ListComplete(ctx context.Context, id HostPoolId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, SessionHostOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SessionHostClient) ListCompleteMatchingPredicate(ctx context.Context, id HostPoolId, options ListOperationOptions, predicate SessionHostOperationPredicate) (result ListCompleteResult, err error) { + items := make([]SessionHost, 0) + + resp, err := c.List(ctx, id, options) + 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 = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/method_retryprovisioning.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/method_retryprovisioning.go new file mode 100644 index 00000000000..d685a13a40a --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/method_retryprovisioning.go @@ -0,0 +1,47 @@ +package sessionhost + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RetryProvisioningOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// RetryProvisioning ... +func (c SessionHostClient) RetryProvisioning(ctx context.Context, id SessionHostId) (result RetryProvisioningOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/retryProvisioning", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + 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/desktopvirtualization/2024-04-08-preview/sessionhost/method_update.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/method_update.go new file mode 100644 index 00000000000..01d50994dfd --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/method_update.go @@ -0,0 +1,87 @@ +package sessionhost + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SessionHost +} + +type UpdateOperationOptions struct { + Force *bool +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Force != nil { + out.Append("force", fmt.Sprintf("%v", *o.Force)) + } + return &out +} + +// Update ... +func (c SessionHostClient) Update(ctx context.Context, id SessionHostId, input SessionHostPatch, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + OptionsObject: options, + 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 SessionHost + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/model_sessionhost.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/model_sessionhost.go new file mode 100644 index 00000000000..6a59b593c4c --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/model_sessionhost.go @@ -0,0 +1,16 @@ +package sessionhost + +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 SessionHost struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SessionHostProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/model_sessionhosthealthcheckfailuredetails.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/model_sessionhosthealthcheckfailuredetails.go new file mode 100644 index 00000000000..e2430e721a2 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/model_sessionhosthealthcheckfailuredetails.go @@ -0,0 +1,28 @@ +package sessionhost + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SessionHostHealthCheckFailureDetails struct { + ErrorCode *int64 `json:"errorCode,omitempty"` + LastHealthCheckDateTime *string `json:"lastHealthCheckDateTime,omitempty"` + Message *string `json:"message,omitempty"` +} + +func (o *SessionHostHealthCheckFailureDetails) GetLastHealthCheckDateTimeAsTime() (*time.Time, error) { + if o.LastHealthCheckDateTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHealthCheckDateTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *SessionHostHealthCheckFailureDetails) SetLastHealthCheckDateTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHealthCheckDateTime = &formatted +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/model_sessionhosthealthcheckreport.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/model_sessionhosthealthcheckreport.go new file mode 100644 index 00000000000..6545cf0a038 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/model_sessionhosthealthcheckreport.go @@ -0,0 +1,10 @@ +package sessionhost + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SessionHostHealthCheckReport struct { + AdditionalFailureDetails *SessionHostHealthCheckFailureDetails `json:"additionalFailureDetails,omitempty"` + HealthCheckName *HealthCheckName `json:"healthCheckName,omitempty"` + HealthCheckResult *HealthCheckResult `json:"healthCheckResult,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/model_sessionhostpatch.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/model_sessionhostpatch.go new file mode 100644 index 00000000000..d9f893c0727 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/model_sessionhostpatch.go @@ -0,0 +1,16 @@ +package sessionhost + +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 SessionHostPatch struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SessionHostPatchProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/model_sessionhostpatchproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/model_sessionhostpatchproperties.go new file mode 100644 index 00000000000..d4286285575 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/model_sessionhostpatchproperties.go @@ -0,0 +1,10 @@ +package sessionhost + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SessionHostPatchProperties struct { + AllowNewSession *bool `json:"allowNewSession,omitempty"` + AssignedUser *string `json:"assignedUser,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/model_sessionhostproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/model_sessionhostproperties.go new file mode 100644 index 00000000000..5d959e46bed --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/model_sessionhostproperties.go @@ -0,0 +1,80 @@ +package sessionhost + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SessionHostProperties struct { + AgentVersion *string `json:"agentVersion,omitempty"` + AllowNewSession *bool `json:"allowNewSession,omitempty"` + AssignedUser *string `json:"assignedUser,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + LastHeartBeat *string `json:"lastHeartBeat,omitempty"` + LastSessionHostUpdateTime *string `json:"lastSessionHostUpdateTime,omitempty"` + LastUpdateTime *string `json:"lastUpdateTime,omitempty"` + ObjectId *string `json:"objectId,omitempty"` + OsVersion *string `json:"osVersion,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` + SessionHostConfiguration *string `json:"sessionHostConfiguration,omitempty"` + SessionHostHealthCheckResults *[]SessionHostHealthCheckReport `json:"sessionHostHealthCheckResults,omitempty"` + Sessions *int64 `json:"sessions,omitempty"` + Status *Status `json:"status,omitempty"` + StatusTimestamp *string `json:"statusTimestamp,omitempty"` + SxSStackVersion *string `json:"sxSStackVersion,omitempty"` + UpdateErrorMessage *string `json:"updateErrorMessage,omitempty"` + UpdateState *UpdateState `json:"updateState,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` +} + +func (o *SessionHostProperties) GetLastHeartBeatAsTime() (*time.Time, error) { + if o.LastHeartBeat == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartBeat, "2006-01-02T15:04:05Z07:00") +} + +func (o *SessionHostProperties) SetLastHeartBeatAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartBeat = &formatted +} + +func (o *SessionHostProperties) GetLastSessionHostUpdateTimeAsTime() (*time.Time, error) { + if o.LastSessionHostUpdateTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastSessionHostUpdateTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *SessionHostProperties) SetLastSessionHostUpdateTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastSessionHostUpdateTime = &formatted +} + +func (o *SessionHostProperties) GetLastUpdateTimeAsTime() (*time.Time, error) { + if o.LastUpdateTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastUpdateTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *SessionHostProperties) SetLastUpdateTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastUpdateTime = &formatted +} + +func (o *SessionHostProperties) GetStatusTimestampAsTime() (*time.Time, error) { + if o.StatusTimestamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StatusTimestamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *SessionHostProperties) SetStatusTimestampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StatusTimestamp = &formatted +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/predicates.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/predicates.go new file mode 100644 index 00000000000..e5e5d8df947 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/predicates.go @@ -0,0 +1,27 @@ +package sessionhost + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SessionHostOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p SessionHostOperationPredicate) Matches(input SessionHost) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/version.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/version.go new file mode 100644 index 00000000000..b859e4aad26 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhost/version.go @@ -0,0 +1,10 @@ +package sessionhost + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-08-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/sessionhost/2024-04-08-preview" +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/README.md b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/README.md new file mode 100644 index 00000000000..e515675805a --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/README.md @@ -0,0 +1,87 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration` Documentation + +The `sessionhostconfiguration` SDK allows for interaction with Azure Resource Manager `desktopvirtualization` (API Version `2024-04-08-preview`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration" +``` + + +### Client Initialization + +```go +client := sessionhostconfiguration.NewSessionHostConfigurationClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SessionHostConfigurationClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := sessionhostconfiguration.NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName") + +payload := sessionhostconfiguration.SessionHostConfiguration{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SessionHostConfigurationClient.Get` + +```go +ctx := context.TODO() +id := sessionhostconfiguration.NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName") + +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: `SessionHostConfigurationClient.ListByHostPool` + +```go +ctx := context.TODO() +id := sessionhostconfiguration.NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName") + +// alternatively `client.ListByHostPool(ctx, id)` can be used to do batched pagination +items, err := client.ListByHostPoolComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `SessionHostConfigurationClient.Update` + +```go +ctx := context.TODO() +id := sessionhostconfiguration.NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName") + +payload := sessionhostconfiguration.SessionHostConfigurationPatch{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/client.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/client.go new file mode 100644 index 00000000000..858aa93caa7 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/client.go @@ -0,0 +1,26 @@ +package sessionhostconfiguration + +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 SessionHostConfigurationClient struct { + Client *resourcemanager.Client +} + +func NewSessionHostConfigurationClientWithBaseURI(sdkApi sdkEnv.Api) (*SessionHostConfigurationClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "sessionhostconfiguration", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SessionHostConfigurationClient: %+v", err) + } + + return &SessionHostConfigurationClient{ + Client: client, + }, nil +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/constants.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/constants.go new file mode 100644 index 00000000000..03914dda4d1 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/constants.go @@ -0,0 +1,227 @@ +package sessionhostconfiguration + +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 DomainJoinType string + +const ( + DomainJoinTypeActiveDirectory DomainJoinType = "ActiveDirectory" + DomainJoinTypeAzureActiveDirectory DomainJoinType = "AzureActiveDirectory" +) + +func PossibleValuesForDomainJoinType() []string { + return []string{ + string(DomainJoinTypeActiveDirectory), + string(DomainJoinTypeAzureActiveDirectory), + } +} + +func (s *DomainJoinType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDomainJoinType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDomainJoinType(input string) (*DomainJoinType, error) { + vals := map[string]DomainJoinType{ + "activedirectory": DomainJoinTypeActiveDirectory, + "azureactivedirectory": DomainJoinTypeAzureActiveDirectory, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DomainJoinType(input) + return &out, nil +} + +type ProvisioningStateSHC string + +const ( + ProvisioningStateSHCCanceled ProvisioningStateSHC = "Canceled" + ProvisioningStateSHCFailed ProvisioningStateSHC = "Failed" + ProvisioningStateSHCProvisioning ProvisioningStateSHC = "Provisioning" + ProvisioningStateSHCSucceeded ProvisioningStateSHC = "Succeeded" +) + +func PossibleValuesForProvisioningStateSHC() []string { + return []string{ + string(ProvisioningStateSHCCanceled), + string(ProvisioningStateSHCFailed), + string(ProvisioningStateSHCProvisioning), + string(ProvisioningStateSHCSucceeded), + } +} + +func (s *ProvisioningStateSHC) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningStateSHC(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningStateSHC(input string) (*ProvisioningStateSHC, error) { + vals := map[string]ProvisioningStateSHC{ + "canceled": ProvisioningStateSHCCanceled, + "failed": ProvisioningStateSHCFailed, + "provisioning": ProvisioningStateSHCProvisioning, + "succeeded": ProvisioningStateSHCSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningStateSHC(input) + return &out, nil +} + +type Type string + +const ( + TypeCustom Type = "Custom" + TypeMarketplace Type = "Marketplace" +) + +func PossibleValuesForType() []string { + return []string{ + string(TypeCustom), + string(TypeMarketplace), + } +} + +func (s *Type) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseType(input string) (*Type, error) { + vals := map[string]Type{ + "custom": TypeCustom, + "marketplace": TypeMarketplace, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Type(input) + return &out, nil +} + +type VirtualMachineDiskType string + +const ( + VirtualMachineDiskTypePremiumLRS VirtualMachineDiskType = "Premium_LRS" + VirtualMachineDiskTypeStandardLRS VirtualMachineDiskType = "Standard_LRS" + VirtualMachineDiskTypeStandardSSDLRS VirtualMachineDiskType = "StandardSSD_LRS" +) + +func PossibleValuesForVirtualMachineDiskType() []string { + return []string{ + string(VirtualMachineDiskTypePremiumLRS), + string(VirtualMachineDiskTypeStandardLRS), + string(VirtualMachineDiskTypeStandardSSDLRS), + } +} + +func (s *VirtualMachineDiskType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualMachineDiskType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualMachineDiskType(input string) (*VirtualMachineDiskType, error) { + vals := map[string]VirtualMachineDiskType{ + "premium_lrs": VirtualMachineDiskTypePremiumLRS, + "standard_lrs": VirtualMachineDiskTypeStandardLRS, + "standardssd_lrs": VirtualMachineDiskTypeStandardSSDLRS, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualMachineDiskType(input) + return &out, nil +} + +type VirtualMachineSecurityType string + +const ( + VirtualMachineSecurityTypeConfidentialVM VirtualMachineSecurityType = "ConfidentialVM" + VirtualMachineSecurityTypeStandard VirtualMachineSecurityType = "Standard" + VirtualMachineSecurityTypeTrustedLaunch VirtualMachineSecurityType = "TrustedLaunch" +) + +func PossibleValuesForVirtualMachineSecurityType() []string { + return []string{ + string(VirtualMachineSecurityTypeConfidentialVM), + string(VirtualMachineSecurityTypeStandard), + string(VirtualMachineSecurityTypeTrustedLaunch), + } +} + +func (s *VirtualMachineSecurityType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualMachineSecurityType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualMachineSecurityType(input string) (*VirtualMachineSecurityType, error) { + vals := map[string]VirtualMachineSecurityType{ + "confidentialvm": VirtualMachineSecurityTypeConfidentialVM, + "standard": VirtualMachineSecurityTypeStandard, + "trustedlaunch": VirtualMachineSecurityTypeTrustedLaunch, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualMachineSecurityType(input) + return &out, nil +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/id_hostpool.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/id_hostpool.go new file mode 100644 index 00000000000..fe338fa5869 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/id_hostpool.go @@ -0,0 +1,130 @@ +package sessionhostconfiguration + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&HostPoolId{}) +} + +var _ resourceids.ResourceId = &HostPoolId{} + +// HostPoolId is a struct representing the Resource ID for a Host Pool +type HostPoolId struct { + SubscriptionId string + ResourceGroupName string + HostPoolName string +} + +// NewHostPoolID returns a new HostPoolId struct +func NewHostPoolID(subscriptionId string, resourceGroupName string, hostPoolName string) HostPoolId { + return HostPoolId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + HostPoolName: hostPoolName, + } +} + +// ParseHostPoolID parses 'input' into a HostPoolId +func ParseHostPoolID(input string) (*HostPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostPoolId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostPoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseHostPoolIDInsensitively parses 'input' case-insensitively into a HostPoolId +// note: this method should only be used for API response data and not user input +func ParseHostPoolIDInsensitively(input string) (*HostPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostPoolId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostPoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *HostPoolId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.HostPoolName, ok = input.Parsed["hostPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hostPoolName", input) + } + + return nil +} + +// ValidateHostPoolID checks that 'input' can be parsed as a Host Pool ID +func ValidateHostPoolID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseHostPoolID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Host Pool ID +func (id HostPoolId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DesktopVirtualization/hostPools/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.HostPoolName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Host Pool ID +func (id HostPoolId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDesktopVirtualization", "Microsoft.DesktopVirtualization", "Microsoft.DesktopVirtualization"), + resourceids.StaticSegment("staticHostPools", "hostPools", "hostPools"), + resourceids.UserSpecifiedSegment("hostPoolName", "hostPoolName"), + } +} + +// String returns a human-readable description of this Host Pool ID +func (id HostPoolId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Host Pool Name: %q", id.HostPoolName), + } + return fmt.Sprintf("Host Pool (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/id_hostpool_test.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/id_hostpool_test.go new file mode 100644 index 00000000000..40b59c9adc3 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/id_hostpool_test.go @@ -0,0 +1,282 @@ +package sessionhostconfiguration + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &HostPoolId{} + +func TestNewHostPoolID(t *testing.T) { + id := NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.HostPoolName != "hostPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'HostPoolName'", id.HostPoolName, "hostPoolName") + } +} + +func TestFormatHostPoolID(t *testing.T) { + actual := NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseHostPoolID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostPoolId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName", + Expected: &HostPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostPoolName: "hostPoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostPoolID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostPoolName != v.Expected.HostPoolName { + t.Fatalf("Expected %q but got %q for HostPoolName", v.Expected.HostPoolName, actual.HostPoolName) + } + + } +} + +func TestParseHostPoolIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostPoolId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName", + Expected: &HostPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostPoolName: "hostPoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs/hOsTpOoLnAmE", + Expected: &HostPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + HostPoolName: "hOsTpOoLnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs/hOsTpOoLnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostPoolIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostPoolName != v.Expected.HostPoolName { + t.Fatalf("Expected %q but got %q for HostPoolName", v.Expected.HostPoolName, actual.HostPoolName) + } + + } +} + +func TestSegmentsForHostPoolId(t *testing.T) { + segments := HostPoolId{}.Segments() + if len(segments) == 0 { + t.Fatalf("HostPoolId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/method_createorupdate.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/method_createorupdate.go new file mode 100644 index 00000000000..34d0df2bef0 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/method_createorupdate.go @@ -0,0 +1,75 @@ +package sessionhostconfiguration + +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 *SessionHostConfiguration +} + +// CreateOrUpdate ... +func (c SessionHostConfigurationClient) CreateOrUpdate(ctx context.Context, id HostPoolId, input SessionHostConfiguration) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/sessionHostConfigurations/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c SessionHostConfigurationClient) CreateOrUpdateThenPoll(ctx context.Context, id HostPoolId, input SessionHostConfiguration) 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/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/method_get.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/method_get.go new file mode 100644 index 00000000000..e5d7952b783 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/method_get.go @@ -0,0 +1,54 @@ +package sessionhostconfiguration + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *SessionHostConfiguration +} + +// Get ... +func (c SessionHostConfigurationClient) Get(ctx context.Context, id HostPoolId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/sessionHostConfigurations/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SessionHostConfiguration + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/method_listbyhostpool.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/method_listbyhostpool.go new file mode 100644 index 00000000000..59e4c0d6dcc --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/method_listbyhostpool.go @@ -0,0 +1,105 @@ +package sessionhostconfiguration + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByHostPoolOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SessionHostConfiguration +} + +type ListByHostPoolCompleteResult struct { + LatestHttpResponse *http.Response + Items []SessionHostConfiguration +} + +type ListByHostPoolCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByHostPoolCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByHostPool ... +func (c SessionHostConfigurationClient) ListByHostPool(ctx context.Context, id HostPoolId) (result ListByHostPoolOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByHostPoolCustomPager{}, + Path: fmt.Sprintf("%s/sessionHostConfigurations", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SessionHostConfiguration `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByHostPoolComplete retrieves all the results into a single object +func (c SessionHostConfigurationClient) ListByHostPoolComplete(ctx context.Context, id HostPoolId) (ListByHostPoolCompleteResult, error) { + return c.ListByHostPoolCompleteMatchingPredicate(ctx, id, SessionHostConfigurationOperationPredicate{}) +} + +// ListByHostPoolCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SessionHostConfigurationClient) ListByHostPoolCompleteMatchingPredicate(ctx context.Context, id HostPoolId, predicate SessionHostConfigurationOperationPredicate) (result ListByHostPoolCompleteResult, err error) { + items := make([]SessionHostConfiguration, 0) + + resp, err := c.ListByHostPool(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 = ListByHostPoolCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/method_update.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/method_update.go new file mode 100644 index 00000000000..2578bd40d2d --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/method_update.go @@ -0,0 +1,75 @@ +package sessionhostconfiguration + +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 *SessionHostConfiguration +} + +// Update ... +func (c SessionHostConfigurationClient) Update(ctx context.Context, id HostPoolId, input SessionHostConfigurationPatch) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: fmt.Sprintf("%s/sessionHostConfigurations/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c SessionHostConfigurationClient) UpdateThenPoll(ctx context.Context, id HostPoolId, input SessionHostConfigurationPatch) 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/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_activedirectoryinfopatchproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_activedirectoryinfopatchproperties.go new file mode 100644 index 00000000000..3d69c0e29a8 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_activedirectoryinfopatchproperties.go @@ -0,0 +1,8 @@ +package sessionhostconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ActiveDirectoryInfoPatchProperties struct { + DomainCredentials *KeyVaultCredentialsPatchProperties `json:"domainCredentials,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_activedirectoryinfoproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_activedirectoryinfoproperties.go new file mode 100644 index 00000000000..7ec2ee5df8e --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_activedirectoryinfoproperties.go @@ -0,0 +1,10 @@ +package sessionhostconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ActiveDirectoryInfoProperties struct { + DomainCredentials KeyVaultCredentialsProperties `json:"domainCredentials"` + DomainName *string `json:"domainName,omitempty"` + OuPath string `json:"ouPath"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_azureactivedirectoryinfoproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_azureactivedirectoryinfoproperties.go new file mode 100644 index 00000000000..03934073a0a --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_azureactivedirectoryinfoproperties.go @@ -0,0 +1,8 @@ +package sessionhostconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureActiveDirectoryInfoProperties struct { + MdmProviderGuid string `json:"mdmProviderGuid"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_bootdiagnosticsinfopatchproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_bootdiagnosticsinfopatchproperties.go new file mode 100644 index 00000000000..f0036203ebb --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_bootdiagnosticsinfopatchproperties.go @@ -0,0 +1,9 @@ +package sessionhostconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BootDiagnosticsInfoPatchProperties struct { + Enabled *bool `json:"enabled,omitempty"` + StorageUri *string `json:"storageUri,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_bootdiagnosticsinfoproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_bootdiagnosticsinfoproperties.go new file mode 100644 index 00000000000..f249d414d19 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_bootdiagnosticsinfoproperties.go @@ -0,0 +1,9 @@ +package sessionhostconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BootDiagnosticsInfoProperties struct { + Enabled *bool `json:"enabled,omitempty"` + StorageUri *string `json:"storageUri,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_custominfopatchproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_custominfopatchproperties.go new file mode 100644 index 00000000000..8c5cf0148ad --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_custominfopatchproperties.go @@ -0,0 +1,8 @@ +package sessionhostconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomInfoPatchProperties struct { + ResourceId *string `json:"resourceId,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_custominfoproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_custominfoproperties.go new file mode 100644 index 00000000000..0db2bc85745 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_custominfoproperties.go @@ -0,0 +1,8 @@ +package sessionhostconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomInfoProperties struct { + ResourceId string `json:"resourceId"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_diskinfopatchproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_diskinfopatchproperties.go new file mode 100644 index 00000000000..2eff60be728 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_diskinfopatchproperties.go @@ -0,0 +1,8 @@ +package sessionhostconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiskInfoPatchProperties struct { + Type *VirtualMachineDiskType `json:"type,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_diskinfoproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_diskinfoproperties.go new file mode 100644 index 00000000000..3908e061bd6 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_diskinfoproperties.go @@ -0,0 +1,8 @@ +package sessionhostconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiskInfoProperties struct { + Type VirtualMachineDiskType `json:"type"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_domaininfopatchproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_domaininfopatchproperties.go new file mode 100644 index 00000000000..5cae01d2c9e --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_domaininfopatchproperties.go @@ -0,0 +1,8 @@ +package sessionhostconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DomainInfoPatchProperties struct { + ActiveDirectoryInfo *ActiveDirectoryInfoPatchProperties `json:"activeDirectoryInfo,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_domaininfoproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_domaininfoproperties.go new file mode 100644 index 00000000000..e3377b07ca1 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_domaininfoproperties.go @@ -0,0 +1,10 @@ +package sessionhostconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DomainInfoProperties struct { + ActiveDirectoryInfo *ActiveDirectoryInfoProperties `json:"activeDirectoryInfo,omitempty"` + AzureActiveDirectoryInfo *AzureActiveDirectoryInfoProperties `json:"azureActiveDirectoryInfo,omitempty"` + JoinType DomainJoinType `json:"joinType"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_imageinfopatchproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_imageinfopatchproperties.go new file mode 100644 index 00000000000..eb7678681da --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_imageinfopatchproperties.go @@ -0,0 +1,10 @@ +package sessionhostconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ImageInfoPatchProperties struct { + CustomInfo *CustomInfoPatchProperties `json:"customInfo,omitempty"` + MarketplaceInfo *MarketplaceInfoPatchProperties `json:"marketplaceInfo,omitempty"` + Type *Type `json:"type,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_imageinfoproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_imageinfoproperties.go new file mode 100644 index 00000000000..e49aa2d5ebc --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_imageinfoproperties.go @@ -0,0 +1,10 @@ +package sessionhostconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ImageInfoProperties struct { + CustomInfo *CustomInfoProperties `json:"customInfo,omitempty"` + MarketplaceInfo *MarketplaceInfoProperties `json:"marketplaceInfo,omitempty"` + Type Type `json:"type"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_keyvaultcredentialspatchproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_keyvaultcredentialspatchproperties.go new file mode 100644 index 00000000000..7ecd74fe753 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_keyvaultcredentialspatchproperties.go @@ -0,0 +1,9 @@ +package sessionhostconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyVaultCredentialsPatchProperties struct { + PasswordKeyVaultSecretUri *string `json:"passwordKeyVaultSecretUri,omitempty"` + UsernameKeyVaultSecretUri *string `json:"usernameKeyVaultSecretUri,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_keyvaultcredentialsproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_keyvaultcredentialsproperties.go new file mode 100644 index 00000000000..7cbb0d9ad6f --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_keyvaultcredentialsproperties.go @@ -0,0 +1,9 @@ +package sessionhostconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyVaultCredentialsProperties struct { + PasswordKeyVaultSecretUri string `json:"passwordKeyVaultSecretUri"` + UsernameKeyVaultSecretUri string `json:"usernameKeyVaultSecretUri"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_marketplaceinfopatchproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_marketplaceinfopatchproperties.go new file mode 100644 index 00000000000..9d4cac36455 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_marketplaceinfopatchproperties.go @@ -0,0 +1,11 @@ +package sessionhostconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MarketplaceInfoPatchProperties struct { + ExactVersion *string `json:"exactVersion,omitempty"` + Offer *string `json:"offer,omitempty"` + Publisher *string `json:"publisher,omitempty"` + Sku *string `json:"sku,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_marketplaceinfoproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_marketplaceinfoproperties.go new file mode 100644 index 00000000000..e7eeb4581b3 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_marketplaceinfoproperties.go @@ -0,0 +1,11 @@ +package sessionhostconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MarketplaceInfoProperties struct { + ExactVersion string `json:"exactVersion"` + Offer string `json:"offer"` + Publisher string `json:"publisher"` + Sku string `json:"sku"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_networkinfopatchproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_networkinfopatchproperties.go new file mode 100644 index 00000000000..0ce4da5160e --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_networkinfopatchproperties.go @@ -0,0 +1,9 @@ +package sessionhostconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInfoPatchProperties struct { + SecurityGroupId *string `json:"securityGroupId,omitempty"` + SubnetId *string `json:"subnetId,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_networkinfoproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_networkinfoproperties.go new file mode 100644 index 00000000000..5cab05b4558 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_networkinfoproperties.go @@ -0,0 +1,9 @@ +package sessionhostconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInfoProperties struct { + SecurityGroupId *string `json:"securityGroupId,omitempty"` + SubnetId string `json:"subnetId"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_securityinfopatchproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_securityinfopatchproperties.go new file mode 100644 index 00000000000..0cd58f49c5c --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_securityinfopatchproperties.go @@ -0,0 +1,10 @@ +package sessionhostconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityInfoPatchProperties struct { + SecureBootEnabled *bool `json:"secureBootEnabled,omitempty"` + Type *VirtualMachineSecurityType `json:"type,omitempty"` + VTpmEnabled *bool `json:"vTpmEnabled,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_securityinfoproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_securityinfoproperties.go new file mode 100644 index 00000000000..a30e6db05a0 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_securityinfoproperties.go @@ -0,0 +1,10 @@ +package sessionhostconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityInfoProperties struct { + SecureBootEnabled *bool `json:"secureBootEnabled,omitempty"` + Type *VirtualMachineSecurityType `json:"type,omitempty"` + VTpmEnabled *bool `json:"vTpmEnabled,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_sessionhostconfiguration.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_sessionhostconfiguration.go new file mode 100644 index 00000000000..011f3d73969 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_sessionhostconfiguration.go @@ -0,0 +1,16 @@ +package sessionhostconfiguration + +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 SessionHostConfiguration struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties SessionHostConfigurationProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_sessionhostconfigurationpatch.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_sessionhostconfigurationpatch.go new file mode 100644 index 00000000000..f53e3d97e30 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_sessionhostconfigurationpatch.go @@ -0,0 +1,8 @@ +package sessionhostconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SessionHostConfigurationPatch struct { + Properties *SessionHostConfigurationPatchProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_sessionhostconfigurationpatchproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_sessionhostconfigurationpatchproperties.go new file mode 100644 index 00000000000..1e2c06d1764 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_sessionhostconfigurationpatchproperties.go @@ -0,0 +1,22 @@ +package sessionhostconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SessionHostConfigurationPatchProperties struct { + AvailabilityZones *[]int64 `json:"availabilityZones,omitempty"` + BootDiagnosticsInfo *BootDiagnosticsInfoPatchProperties `json:"bootDiagnosticsInfo,omitempty"` + CustomConfigurationScriptURL *string `json:"customConfigurationScriptUrl,omitempty"` + DiskInfo *DiskInfoPatchProperties `json:"diskInfo,omitempty"` + DomainInfo *DomainInfoPatchProperties `json:"domainInfo,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ImageInfo *ImageInfoPatchProperties `json:"imageInfo,omitempty"` + NetworkInfo *NetworkInfoPatchProperties `json:"networkInfo,omitempty"` + SecurityInfo *SecurityInfoPatchProperties `json:"securityInfo,omitempty"` + VMAdminCredentials *KeyVaultCredentialsPatchProperties `json:"vmAdminCredentials,omitempty"` + VMLocation *string `json:"vmLocation,omitempty"` + VMNamePrefix *string `json:"vmNamePrefix,omitempty"` + VMResourceGroup *string `json:"vmResourceGroup,omitempty"` + VMSizeId *string `json:"vmSizeId,omitempty"` + VMTags *map[string]string `json:"vmTags,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_sessionhostconfigurationproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_sessionhostconfigurationproperties.go new file mode 100644 index 00000000000..335cd1d8abe --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/model_sessionhostconfigurationproperties.go @@ -0,0 +1,42 @@ +package sessionhostconfiguration + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SessionHostConfigurationProperties struct { + AvailabilityZones *[]int64 `json:"availabilityZones,omitempty"` + BootDiagnosticsInfo *BootDiagnosticsInfoProperties `json:"bootDiagnosticsInfo,omitempty"` + CustomConfigurationScriptURL *string `json:"customConfigurationScriptUrl,omitempty"` + DiskInfo DiskInfoProperties `json:"diskInfo"` + DomainInfo DomainInfoProperties `json:"domainInfo"` + FriendlyName *string `json:"friendlyName,omitempty"` + ImageInfo ImageInfoProperties `json:"imageInfo"` + NetworkInfo NetworkInfoProperties `json:"networkInfo"` + ProvisioningState *ProvisioningStateSHC `json:"provisioningState,omitempty"` + SecurityInfo *SecurityInfoProperties `json:"securityInfo,omitempty"` + VMAdminCredentials KeyVaultCredentialsProperties `json:"vmAdminCredentials"` + VMLocation *string `json:"vmLocation,omitempty"` + VMNamePrefix string `json:"vmNamePrefix"` + VMResourceGroup *string `json:"vmResourceGroup,omitempty"` + VMSizeId string `json:"vmSizeId"` + VMTags *map[string]string `json:"vmTags,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *SessionHostConfigurationProperties) GetVersionAsTime() (*time.Time, error) { + if o.Version == nil { + return nil, nil + } + return dates.ParseAsFormat(o.Version, "2006-01-02T15:04:05Z07:00") +} + +func (o *SessionHostConfigurationProperties) SetVersionAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.Version = &formatted +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/predicates.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/predicates.go new file mode 100644 index 00000000000..834315d5ac9 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/predicates.go @@ -0,0 +1,27 @@ +package sessionhostconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SessionHostConfigurationOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p SessionHostConfigurationOperationPredicate) Matches(input SessionHostConfiguration) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/version.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/version.go new file mode 100644 index 00000000000..a5f48c0ab06 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostconfiguration/version.go @@ -0,0 +1,10 @@ +package sessionhostconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-08-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/sessionhostconfiguration/2024-04-08-preview" +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/README.md b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/README.md new file mode 100644 index 00000000000..c96dd857213 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/README.md @@ -0,0 +1,116 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement` Documentation + +The `sessionhostmanagement` SDK allows for interaction with Azure Resource Manager `desktopvirtualization` (API Version `2024-04-08-preview`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement" +``` + + +### Client Initialization + +```go +client := sessionhostmanagement.NewSessionHostManagementClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SessionHostManagementClient.ControlSessionHostUpdatePost` + +```go +ctx := context.TODO() +id := sessionhostmanagement.NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName") + +payload := sessionhostmanagement.HostPoolUpdateControlParameter{ + // ... +} + + +if err := client.ControlSessionHostUpdatePostThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SessionHostManagementClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := sessionhostmanagement.NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName") + +payload := sessionhostmanagement.SessionHostManagement{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SessionHostManagementClient.InitiateSessionHostUpdatePost` + +```go +ctx := context.TODO() +id := sessionhostmanagement.NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName") + +payload := sessionhostmanagement.UpdateSessionHostsRequestBody{ + // ... +} + + +read, err := client.InitiateSessionHostUpdatePost(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SessionHostManagementClient.Update` + +```go +ctx := context.TODO() +id := sessionhostmanagement.NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName") + +payload := sessionhostmanagement.SessionHostManagementPatch{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SessionHostManagementClient.UpdateStatusGet` + +```go +ctx := context.TODO() +id := sessionhostmanagement.NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName") + +read, err := client.UpdateStatusGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/client.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/client.go new file mode 100644 index 00000000000..973adbe9f98 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/client.go @@ -0,0 +1,26 @@ +package sessionhostmanagement + +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 SessionHostManagementClient struct { + Client *resourcemanager.Client +} + +func NewSessionHostManagementClientWithBaseURI(sdkApi sdkEnv.Api) (*SessionHostManagementClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "sessionhostmanagement", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SessionHostManagementClient: %+v", err) + } + + return &SessionHostManagementClient{ + Client: client, + }, nil +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/constants.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/constants.go new file mode 100644 index 00000000000..c66144033c0 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/constants.go @@ -0,0 +1,60 @@ +package sessionhostmanagement + +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 HostPoolUpdateAction string + +const ( + HostPoolUpdateActionCancel HostPoolUpdateAction = "Cancel" + HostPoolUpdateActionPause HostPoolUpdateAction = "Pause" + HostPoolUpdateActionResume HostPoolUpdateAction = "Resume" + HostPoolUpdateActionRetry HostPoolUpdateAction = "Retry" + HostPoolUpdateActionStart HostPoolUpdateAction = "Start" +) + +func PossibleValuesForHostPoolUpdateAction() []string { + return []string{ + string(HostPoolUpdateActionCancel), + string(HostPoolUpdateActionPause), + string(HostPoolUpdateActionResume), + string(HostPoolUpdateActionRetry), + string(HostPoolUpdateActionStart), + } +} + +func (s *HostPoolUpdateAction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHostPoolUpdateAction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHostPoolUpdateAction(input string) (*HostPoolUpdateAction, error) { + vals := map[string]HostPoolUpdateAction{ + "cancel": HostPoolUpdateActionCancel, + "pause": HostPoolUpdateActionPause, + "resume": HostPoolUpdateActionResume, + "retry": HostPoolUpdateActionRetry, + "start": HostPoolUpdateActionStart, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HostPoolUpdateAction(input) + return &out, nil +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/id_hostpool.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/id_hostpool.go new file mode 100644 index 00000000000..589253a439b --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/id_hostpool.go @@ -0,0 +1,130 @@ +package sessionhostmanagement + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&HostPoolId{}) +} + +var _ resourceids.ResourceId = &HostPoolId{} + +// HostPoolId is a struct representing the Resource ID for a Host Pool +type HostPoolId struct { + SubscriptionId string + ResourceGroupName string + HostPoolName string +} + +// NewHostPoolID returns a new HostPoolId struct +func NewHostPoolID(subscriptionId string, resourceGroupName string, hostPoolName string) HostPoolId { + return HostPoolId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + HostPoolName: hostPoolName, + } +} + +// ParseHostPoolID parses 'input' into a HostPoolId +func ParseHostPoolID(input string) (*HostPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostPoolId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostPoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseHostPoolIDInsensitively parses 'input' case-insensitively into a HostPoolId +// note: this method should only be used for API response data and not user input +func ParseHostPoolIDInsensitively(input string) (*HostPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostPoolId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostPoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *HostPoolId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.HostPoolName, ok = input.Parsed["hostPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hostPoolName", input) + } + + return nil +} + +// ValidateHostPoolID checks that 'input' can be parsed as a Host Pool ID +func ValidateHostPoolID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseHostPoolID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Host Pool ID +func (id HostPoolId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DesktopVirtualization/hostPools/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.HostPoolName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Host Pool ID +func (id HostPoolId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDesktopVirtualization", "Microsoft.DesktopVirtualization", "Microsoft.DesktopVirtualization"), + resourceids.StaticSegment("staticHostPools", "hostPools", "hostPools"), + resourceids.UserSpecifiedSegment("hostPoolName", "hostPoolName"), + } +} + +// String returns a human-readable description of this Host Pool ID +func (id HostPoolId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Host Pool Name: %q", id.HostPoolName), + } + return fmt.Sprintf("Host Pool (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/id_hostpool_test.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/id_hostpool_test.go new file mode 100644 index 00000000000..75b187c09d0 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/id_hostpool_test.go @@ -0,0 +1,282 @@ +package sessionhostmanagement + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &HostPoolId{} + +func TestNewHostPoolID(t *testing.T) { + id := NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.HostPoolName != "hostPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'HostPoolName'", id.HostPoolName, "hostPoolName") + } +} + +func TestFormatHostPoolID(t *testing.T) { + actual := NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseHostPoolID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostPoolId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName", + Expected: &HostPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostPoolName: "hostPoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostPoolID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostPoolName != v.Expected.HostPoolName { + t.Fatalf("Expected %q but got %q for HostPoolName", v.Expected.HostPoolName, actual.HostPoolName) + } + + } +} + +func TestParseHostPoolIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostPoolId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName", + Expected: &HostPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostPoolName: "hostPoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs/hOsTpOoLnAmE", + Expected: &HostPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + HostPoolName: "hOsTpOoLnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs/hOsTpOoLnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostPoolIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostPoolName != v.Expected.HostPoolName { + t.Fatalf("Expected %q but got %q for HostPoolName", v.Expected.HostPoolName, actual.HostPoolName) + } + + } +} + +func TestSegmentsForHostPoolId(t *testing.T) { + segments := HostPoolId{}.Segments() + if len(segments) == 0 { + t.Fatalf("HostPoolId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/method_controlsessionhostupdatepost.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/method_controlsessionhostupdatepost.go new file mode 100644 index 00000000000..903a233df20 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/method_controlsessionhostupdatepost.go @@ -0,0 +1,73 @@ +package sessionhostmanagement + +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 ControlSessionHostUpdatePostOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ControlSessionHostUpdatePost ... +func (c SessionHostManagementClient) ControlSessionHostUpdatePost(ctx context.Context, id HostPoolId, input HostPoolUpdateControlParameter) (result ControlSessionHostUpdatePostOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/sessionHostManagements/default/controlSessionHostUpdate", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + 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 +} + +// ControlSessionHostUpdatePostThenPoll performs ControlSessionHostUpdatePost then polls until it's completed +func (c SessionHostManagementClient) ControlSessionHostUpdatePostThenPoll(ctx context.Context, id HostPoolId, input HostPoolUpdateControlParameter) error { + result, err := c.ControlSessionHostUpdatePost(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ControlSessionHostUpdatePost: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ControlSessionHostUpdatePost: %+v", err) + } + + return nil +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/method_createorupdate.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/method_createorupdate.go new file mode 100644 index 00000000000..0b03e0cdd6d --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/method_createorupdate.go @@ -0,0 +1,59 @@ +package sessionhostmanagement + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SessionHostManagement +} + +// CreateOrUpdate ... +func (c SessionHostManagementClient) CreateOrUpdate(ctx context.Context, id HostPoolId, input SessionHostManagement) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/sessionHostManagements/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SessionHostManagement + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/method_initiatesessionhostupdatepost.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/method_initiatesessionhostupdatepost.go new file mode 100644 index 00000000000..b0ee9b96d60 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/method_initiatesessionhostupdatepost.go @@ -0,0 +1,51 @@ +package sessionhostmanagement + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InitiateSessionHostUpdatePostOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// InitiateSessionHostUpdatePost ... +func (c SessionHostManagementClient) InitiateSessionHostUpdatePost(ctx context.Context, id HostPoolId, input UpdateSessionHostsRequestBody) (result InitiateSessionHostUpdatePostOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/sessionHostManagements/default/initiateSessionHostUpdate", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + 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/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/method_update.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/method_update.go new file mode 100644 index 00000000000..fec3bb9a2ab --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/method_update.go @@ -0,0 +1,58 @@ +package sessionhostmanagement + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SessionHostManagement +} + +// Update ... +func (c SessionHostManagementClient) Update(ctx context.Context, id HostPoolId, input SessionHostManagementPatch) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: fmt.Sprintf("%s/sessionHostManagements/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SessionHostManagement + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/method_updatestatusget.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/method_updatestatusget.go new file mode 100644 index 00000000000..223947f13cd --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/method_updatestatusget.go @@ -0,0 +1,54 @@ +package sessionhostmanagement + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateStatusGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SessionHostManagementUpdateStatus +} + +// UpdateStatusGet ... +func (c SessionHostManagementClient) UpdateStatusGet(ctx context.Context, id HostPoolId) (result UpdateStatusGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/sessionHostManagements/default/sessionHostUpdateStatuses/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SessionHostManagementUpdateStatus + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_erroradditionalinfo.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_erroradditionalinfo.go new file mode 100644 index 00000000000..c2556ad4c8b --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_erroradditionalinfo.go @@ -0,0 +1,9 @@ +package sessionhostmanagement + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorAdditionalInfo struct { + Info *interface{} `json:"info,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_errordetail.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_errordetail.go new file mode 100644 index 00000000000..cc54f6992b3 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_errordetail.go @@ -0,0 +1,12 @@ +package sessionhostmanagement + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorDetail struct { + AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` + Code *string `json:"code,omitempty"` + Details *[]ErrorDetail `json:"details,omitempty"` + Message *string `json:"message,omitempty"` + Target *string `json:"target,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_hostpoolupdateconfigurationpatchproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_hostpoolupdateconfigurationpatchproperties.go new file mode 100644 index 00000000000..566b145e7c5 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_hostpoolupdateconfigurationpatchproperties.go @@ -0,0 +1,11 @@ +package sessionhostmanagement + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HostPoolUpdateConfigurationPatchProperties struct { + DeleteOriginalVM *bool `json:"deleteOriginalVm,omitempty"` + LogOffDelayMinutes *int64 `json:"logOffDelayMinutes,omitempty"` + LogOffMessage *string `json:"logOffMessage,omitempty"` + MaxVMsRemoved *int64 `json:"maxVmsRemoved,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_hostpoolupdateconfigurationproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_hostpoolupdateconfigurationproperties.go new file mode 100644 index 00000000000..f7ba0d302cd --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_hostpoolupdateconfigurationproperties.go @@ -0,0 +1,11 @@ +package sessionhostmanagement + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HostPoolUpdateConfigurationProperties struct { + DeleteOriginalVM *bool `json:"deleteOriginalVm,omitempty"` + LogOffDelayMinutes int64 `json:"logOffDelayMinutes"` + LogOffMessage *string `json:"logOffMessage,omitempty"` + MaxVMsRemoved int64 `json:"maxVmsRemoved"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_hostpoolupdatecontrolparameter.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_hostpoolupdatecontrolparameter.go new file mode 100644 index 00000000000..2ebee670e4c --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_hostpoolupdatecontrolparameter.go @@ -0,0 +1,9 @@ +package sessionhostmanagement + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HostPoolUpdateControlParameter struct { + Action HostPoolUpdateAction `json:"action"` + CancelMessage *string `json:"cancelMessage,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_sessionhostmanagement.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_sessionhostmanagement.go new file mode 100644 index 00000000000..d41a58bd678 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_sessionhostmanagement.go @@ -0,0 +1,16 @@ +package sessionhostmanagement + +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 SessionHostManagement struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties SessionHostManagementProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_sessionhostmanagementoperationprogress.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_sessionhostmanagementoperationprogress.go new file mode 100644 index 00000000000..3b7400bfa60 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_sessionhostmanagementoperationprogress.go @@ -0,0 +1,30 @@ +package sessionhostmanagement + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SessionHostManagementOperationProgress struct { + ExecutionStartTime *string `json:"executionStartTime,omitempty"` + SessionHostsCompleted *int64 `json:"sessionHostsCompleted,omitempty"` + SessionHostsInProgress *int64 `json:"sessionHostsInProgress,omitempty"` + SessionHostsRollbackFailed *int64 `json:"sessionHostsRollbackFailed,omitempty"` + TotalSessionHosts *int64 `json:"totalSessionHosts,omitempty"` +} + +func (o *SessionHostManagementOperationProgress) GetExecutionStartTimeAsTime() (*time.Time, error) { + if o.ExecutionStartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExecutionStartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *SessionHostManagementOperationProgress) SetExecutionStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExecutionStartTime = &formatted +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_sessionhostmanagementpatch.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_sessionhostmanagementpatch.go new file mode 100644 index 00000000000..6fdffb4a179 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_sessionhostmanagementpatch.go @@ -0,0 +1,8 @@ +package sessionhostmanagement + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SessionHostManagementPatch struct { + Properties *SessionHostManagementPatchProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_sessionhostmanagementpatchproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_sessionhostmanagementpatchproperties.go new file mode 100644 index 00000000000..e9802212afd --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_sessionhostmanagementpatchproperties.go @@ -0,0 +1,9 @@ +package sessionhostmanagement + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SessionHostManagementPatchProperties struct { + ScheduledDateTimeZone *string `json:"scheduledDateTimeZone,omitempty"` + Update *HostPoolUpdateConfigurationPatchProperties `json:"update,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_sessionhostmanagementproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_sessionhostmanagementproperties.go new file mode 100644 index 00000000000..4317906eb7f --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_sessionhostmanagementproperties.go @@ -0,0 +1,9 @@ +package sessionhostmanagement + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SessionHostManagementProperties struct { + ScheduledDateTimeZone string `json:"scheduledDateTimeZone"` + Update HostPoolUpdateConfigurationProperties `json:"update"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_sessionhostmanagementupdatestatus.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_sessionhostmanagementupdatestatus.go new file mode 100644 index 00000000000..cd83a682db9 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_sessionhostmanagementupdatestatus.go @@ -0,0 +1,45 @@ +package sessionhostmanagement + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SessionHostManagementUpdateStatus struct { + EndTime *string `json:"endTime,omitempty"` + Error *ErrorDetail `json:"error,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + PercentComplete *float64 `json:"percentComplete,omitempty"` + Properties *SessionHostManagementUpdateStatusProperties `json:"properties,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status string `json:"status"` +} + +func (o *SessionHostManagementUpdateStatus) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *SessionHostManagementUpdateStatus) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *SessionHostManagementUpdateStatus) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *SessionHostManagementUpdateStatus) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_sessionhostmanagementupdatestatusproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_sessionhostmanagementupdatestatusproperties.go new file mode 100644 index 00000000000..e2ab84a838f --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_sessionhostmanagementupdatestatusproperties.go @@ -0,0 +1,29 @@ +package sessionhostmanagement + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SessionHostManagementUpdateStatusProperties struct { + CorrelationId *string `json:"correlationId,omitempty"` + Progress *SessionHostManagementOperationProgress `json:"progress,omitempty"` + ScheduledDateTime *string `json:"scheduledDateTime,omitempty"` + SessionHostManagement *SessionHostManagement `json:"sessionHostManagement,omitempty"` +} + +func (o *SessionHostManagementUpdateStatusProperties) GetScheduledDateTimeAsTime() (*time.Time, error) { + if o.ScheduledDateTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ScheduledDateTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *SessionHostManagementUpdateStatusProperties) SetScheduledDateTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ScheduledDateTime = &formatted +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_updatesessionhostsrequestbody.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_updatesessionhostsrequestbody.go new file mode 100644 index 00000000000..7bddeeb143d --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/model_updatesessionhostsrequestbody.go @@ -0,0 +1,28 @@ +package sessionhostmanagement + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateSessionHostsRequestBody struct { + ScheduledDateTime *string `json:"scheduledDateTime,omitempty"` + ScheduledDateTimeZone *string `json:"scheduledDateTimeZone,omitempty"` + Update *HostPoolUpdateConfigurationPatchProperties `json:"update,omitempty"` +} + +func (o *UpdateSessionHostsRequestBody) GetScheduledDateTimeAsTime() (*time.Time, error) { + if o.ScheduledDateTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ScheduledDateTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *UpdateSessionHostsRequestBody) SetScheduledDateTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ScheduledDateTime = &formatted +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/version.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/version.go new file mode 100644 index 00000000000..b08ccf66215 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagement/version.go @@ -0,0 +1,10 @@ +package sessionhostmanagement + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-08-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/sessionhostmanagement/2024-04-08-preview" +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagements/README.md b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagements/README.md new file mode 100644 index 00000000000..3f3fb12cee8 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagements/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagements` Documentation + +The `sessionhostmanagements` SDK allows for interaction with Azure Resource Manager `desktopvirtualization` (API Version `2024-04-08-preview`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagements" +``` + + +### Client Initialization + +```go +client := sessionhostmanagements.NewSessionHostManagementsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SessionHostManagementsClient.Get` + +```go +ctx := context.TODO() +id := sessionhostmanagements.NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName") + +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: `SessionHostManagementsClient.ListByHostPool` + +```go +ctx := context.TODO() +id := sessionhostmanagements.NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName") + +// alternatively `client.ListByHostPool(ctx, id)` can be used to do batched pagination +items, err := client.ListByHostPoolComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagements/client.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagements/client.go new file mode 100644 index 00000000000..d2cee7341f1 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagements/client.go @@ -0,0 +1,26 @@ +package sessionhostmanagements + +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 SessionHostManagementsClient struct { + Client *resourcemanager.Client +} + +func NewSessionHostManagementsClientWithBaseURI(sdkApi sdkEnv.Api) (*SessionHostManagementsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "sessionhostmanagements", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SessionHostManagementsClient: %+v", err) + } + + return &SessionHostManagementsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagements/id_hostpool.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagements/id_hostpool.go new file mode 100644 index 00000000000..49e4d5cc6f7 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagements/id_hostpool.go @@ -0,0 +1,130 @@ +package sessionhostmanagements + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&HostPoolId{}) +} + +var _ resourceids.ResourceId = &HostPoolId{} + +// HostPoolId is a struct representing the Resource ID for a Host Pool +type HostPoolId struct { + SubscriptionId string + ResourceGroupName string + HostPoolName string +} + +// NewHostPoolID returns a new HostPoolId struct +func NewHostPoolID(subscriptionId string, resourceGroupName string, hostPoolName string) HostPoolId { + return HostPoolId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + HostPoolName: hostPoolName, + } +} + +// ParseHostPoolID parses 'input' into a HostPoolId +func ParseHostPoolID(input string) (*HostPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostPoolId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostPoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseHostPoolIDInsensitively parses 'input' case-insensitively into a HostPoolId +// note: this method should only be used for API response data and not user input +func ParseHostPoolIDInsensitively(input string) (*HostPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostPoolId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostPoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *HostPoolId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.HostPoolName, ok = input.Parsed["hostPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hostPoolName", input) + } + + return nil +} + +// ValidateHostPoolID checks that 'input' can be parsed as a Host Pool ID +func ValidateHostPoolID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseHostPoolID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Host Pool ID +func (id HostPoolId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DesktopVirtualization/hostPools/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.HostPoolName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Host Pool ID +func (id HostPoolId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDesktopVirtualization", "Microsoft.DesktopVirtualization", "Microsoft.DesktopVirtualization"), + resourceids.StaticSegment("staticHostPools", "hostPools", "hostPools"), + resourceids.UserSpecifiedSegment("hostPoolName", "hostPoolName"), + } +} + +// String returns a human-readable description of this Host Pool ID +func (id HostPoolId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Host Pool Name: %q", id.HostPoolName), + } + return fmt.Sprintf("Host Pool (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagements/id_hostpool_test.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagements/id_hostpool_test.go new file mode 100644 index 00000000000..8f6daedd6d3 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagements/id_hostpool_test.go @@ -0,0 +1,282 @@ +package sessionhostmanagements + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &HostPoolId{} + +func TestNewHostPoolID(t *testing.T) { + id := NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.HostPoolName != "hostPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'HostPoolName'", id.HostPoolName, "hostPoolName") + } +} + +func TestFormatHostPoolID(t *testing.T) { + actual := NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseHostPoolID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostPoolId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName", + Expected: &HostPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostPoolName: "hostPoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostPoolID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostPoolName != v.Expected.HostPoolName { + t.Fatalf("Expected %q but got %q for HostPoolName", v.Expected.HostPoolName, actual.HostPoolName) + } + + } +} + +func TestParseHostPoolIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostPoolId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName", + Expected: &HostPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostPoolName: "hostPoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs/hOsTpOoLnAmE", + Expected: &HostPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + HostPoolName: "hOsTpOoLnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs/hOsTpOoLnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostPoolIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostPoolName != v.Expected.HostPoolName { + t.Fatalf("Expected %q but got %q for HostPoolName", v.Expected.HostPoolName, actual.HostPoolName) + } + + } +} + +func TestSegmentsForHostPoolId(t *testing.T) { + segments := HostPoolId{}.Segments() + if len(segments) == 0 { + t.Fatalf("HostPoolId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagements/method_get.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagements/method_get.go new file mode 100644 index 00000000000..2f398742f3e --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagements/method_get.go @@ -0,0 +1,54 @@ +package sessionhostmanagements + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *SessionHostManagement +} + +// Get ... +func (c SessionHostManagementsClient) Get(ctx context.Context, id HostPoolId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/sessionHostManagements/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SessionHostManagement + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagements/method_listbyhostpool.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagements/method_listbyhostpool.go new file mode 100644 index 00000000000..24cc3db7e0b --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagements/method_listbyhostpool.go @@ -0,0 +1,105 @@ +package sessionhostmanagements + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByHostPoolOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SessionHostManagement +} + +type ListByHostPoolCompleteResult struct { + LatestHttpResponse *http.Response + Items []SessionHostManagement +} + +type ListByHostPoolCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByHostPoolCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByHostPool ... +func (c SessionHostManagementsClient) ListByHostPool(ctx context.Context, id HostPoolId) (result ListByHostPoolOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByHostPoolCustomPager{}, + Path: fmt.Sprintf("%s/sessionHostManagements", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SessionHostManagement `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByHostPoolComplete retrieves all the results into a single object +func (c SessionHostManagementsClient) ListByHostPoolComplete(ctx context.Context, id HostPoolId) (ListByHostPoolCompleteResult, error) { + return c.ListByHostPoolCompleteMatchingPredicate(ctx, id, SessionHostManagementOperationPredicate{}) +} + +// ListByHostPoolCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SessionHostManagementsClient) ListByHostPoolCompleteMatchingPredicate(ctx context.Context, id HostPoolId, predicate SessionHostManagementOperationPredicate) (result ListByHostPoolCompleteResult, err error) { + items := make([]SessionHostManagement, 0) + + resp, err := c.ListByHostPool(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 = ListByHostPoolCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagements/model_hostpoolupdateconfigurationproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagements/model_hostpoolupdateconfigurationproperties.go new file mode 100644 index 00000000000..a84ab7a3dfb --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagements/model_hostpoolupdateconfigurationproperties.go @@ -0,0 +1,11 @@ +package sessionhostmanagements + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HostPoolUpdateConfigurationProperties struct { + DeleteOriginalVM *bool `json:"deleteOriginalVm,omitempty"` + LogOffDelayMinutes int64 `json:"logOffDelayMinutes"` + LogOffMessage *string `json:"logOffMessage,omitempty"` + MaxVMsRemoved int64 `json:"maxVmsRemoved"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagements/model_sessionhostmanagement.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagements/model_sessionhostmanagement.go new file mode 100644 index 00000000000..ad18752374f --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagements/model_sessionhostmanagement.go @@ -0,0 +1,16 @@ +package sessionhostmanagements + +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 SessionHostManagement struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties SessionHostManagementProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagements/model_sessionhostmanagementproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagements/model_sessionhostmanagementproperties.go new file mode 100644 index 00000000000..167782dbd4d --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagements/model_sessionhostmanagementproperties.go @@ -0,0 +1,9 @@ +package sessionhostmanagements + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SessionHostManagementProperties struct { + ScheduledDateTimeZone string `json:"scheduledDateTimeZone"` + Update HostPoolUpdateConfigurationProperties `json:"update"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagements/predicates.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagements/predicates.go new file mode 100644 index 00000000000..859aae14701 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagements/predicates.go @@ -0,0 +1,27 @@ +package sessionhostmanagements + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SessionHostManagementOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p SessionHostManagementOperationPredicate) Matches(input SessionHostManagement) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagements/version.go b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagements/version.go new file mode 100644 index 00000000000..b7e2d394b97 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/sessionhostmanagements/version.go @@ -0,0 +1,10 @@ +package sessionhostmanagements + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-08-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/sessionhostmanagements/2024-04-08-preview" +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/startmenuitem/README.md b/resource-manager/desktopvirtualization/2024-04-08-preview/startmenuitem/README.md new file mode 100644 index 00000000000..c44f2fb0173 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/startmenuitem/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/startmenuitem` Documentation + +The `startmenuitem` SDK allows for interaction with Azure Resource Manager `desktopvirtualization` (API Version `2024-04-08-preview`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/startmenuitem" +``` + + +### Client Initialization + +```go +client := startmenuitem.NewStartMenuItemClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `StartMenuItemClient.List` + +```go +ctx := context.TODO() +id := startmenuitem.NewApplicationGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGroupName") + +// alternatively `client.List(ctx, id, startmenuitem.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, startmenuitem.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/startmenuitem/client.go b/resource-manager/desktopvirtualization/2024-04-08-preview/startmenuitem/client.go new file mode 100644 index 00000000000..fb8fbf510c6 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/startmenuitem/client.go @@ -0,0 +1,26 @@ +package startmenuitem + +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 StartMenuItemClient struct { + Client *resourcemanager.Client +} + +func NewStartMenuItemClientWithBaseURI(sdkApi sdkEnv.Api) (*StartMenuItemClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "startmenuitem", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating StartMenuItemClient: %+v", err) + } + + return &StartMenuItemClient{ + Client: client, + }, nil +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/startmenuitem/id_applicationgroup.go b/resource-manager/desktopvirtualization/2024-04-08-preview/startmenuitem/id_applicationgroup.go new file mode 100644 index 00000000000..a463d5a4b41 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/startmenuitem/id_applicationgroup.go @@ -0,0 +1,130 @@ +package startmenuitem + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ApplicationGroupId{}) +} + +var _ resourceids.ResourceId = &ApplicationGroupId{} + +// ApplicationGroupId is a struct representing the Resource ID for a Application Group +type ApplicationGroupId struct { + SubscriptionId string + ResourceGroupName string + ApplicationGroupName string +} + +// NewApplicationGroupID returns a new ApplicationGroupId struct +func NewApplicationGroupID(subscriptionId string, resourceGroupName string, applicationGroupName string) ApplicationGroupId { + return ApplicationGroupId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ApplicationGroupName: applicationGroupName, + } +} + +// ParseApplicationGroupID parses 'input' into a ApplicationGroupId +func ParseApplicationGroupID(input string) (*ApplicationGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&ApplicationGroupId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ApplicationGroupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseApplicationGroupIDInsensitively parses 'input' case-insensitively into a ApplicationGroupId +// note: this method should only be used for API response data and not user input +func ParseApplicationGroupIDInsensitively(input string) (*ApplicationGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&ApplicationGroupId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ApplicationGroupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ApplicationGroupId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ApplicationGroupName, ok = input.Parsed["applicationGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "applicationGroupName", input) + } + + return nil +} + +// ValidateApplicationGroupID checks that 'input' can be parsed as a Application Group ID +func ValidateApplicationGroupID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseApplicationGroupID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Application Group ID +func (id ApplicationGroupId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DesktopVirtualization/applicationGroups/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ApplicationGroupName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Application Group ID +func (id ApplicationGroupId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDesktopVirtualization", "Microsoft.DesktopVirtualization", "Microsoft.DesktopVirtualization"), + resourceids.StaticSegment("staticApplicationGroups", "applicationGroups", "applicationGroups"), + resourceids.UserSpecifiedSegment("applicationGroupName", "applicationGroupName"), + } +} + +// String returns a human-readable description of this Application Group ID +func (id ApplicationGroupId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Application Group Name: %q", id.ApplicationGroupName), + } + return fmt.Sprintf("Application Group (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/startmenuitem/id_applicationgroup_test.go b/resource-manager/desktopvirtualization/2024-04-08-preview/startmenuitem/id_applicationgroup_test.go new file mode 100644 index 00000000000..e76502994e2 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/startmenuitem/id_applicationgroup_test.go @@ -0,0 +1,282 @@ +package startmenuitem + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ApplicationGroupId{} + +func TestNewApplicationGroupID(t *testing.T) { + id := NewApplicationGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGroupName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ApplicationGroupName != "applicationGroupName" { + t.Fatalf("Expected %q but got %q for Segment 'ApplicationGroupName'", id.ApplicationGroupName, "applicationGroupName") + } +} + +func TestFormatApplicationGroupID(t *testing.T) { + actual := NewApplicationGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGroupName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups/applicationGroupName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseApplicationGroupID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ApplicationGroupId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups/applicationGroupName", + Expected: &ApplicationGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ApplicationGroupName: "applicationGroupName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups/applicationGroupName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseApplicationGroupID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ApplicationGroupName != v.Expected.ApplicationGroupName { + t.Fatalf("Expected %q but got %q for ApplicationGroupName", v.Expected.ApplicationGroupName, actual.ApplicationGroupName) + } + + } +} + +func TestParseApplicationGroupIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ApplicationGroupId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/aPpLiCaTiOnGrOuPs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups/applicationGroupName", + Expected: &ApplicationGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ApplicationGroupName: "applicationGroupName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/applicationGroups/applicationGroupName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/aPpLiCaTiOnGrOuPs/aPpLiCaTiOnGrOuPnAmE", + Expected: &ApplicationGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ApplicationGroupName: "aPpLiCaTiOnGrOuPnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/aPpLiCaTiOnGrOuPs/aPpLiCaTiOnGrOuPnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseApplicationGroupIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ApplicationGroupName != v.Expected.ApplicationGroupName { + t.Fatalf("Expected %q but got %q for ApplicationGroupName", v.Expected.ApplicationGroupName, actual.ApplicationGroupName) + } + + } +} + +func TestSegmentsForApplicationGroupId(t *testing.T) { + segments := ApplicationGroupId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ApplicationGroupId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/startmenuitem/method_list.go b/resource-manager/desktopvirtualization/2024-04-08-preview/startmenuitem/method_list.go new file mode 100644 index 00000000000..3fd6cb1a47f --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/startmenuitem/method_list.go @@ -0,0 +1,142 @@ +package startmenuitem + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StartMenuItem +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []StartMenuItem +} + +type ListOperationOptions struct { + InitialSkip *int64 + IsDescending *bool + PageSize *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.InitialSkip != nil { + out.Append("initialSkip", fmt.Sprintf("%v", *o.InitialSkip)) + } + if o.IsDescending != nil { + out.Append("isDescending", fmt.Sprintf("%v", *o.IsDescending)) + } + if o.PageSize != nil { + out.Append("pageSize", fmt.Sprintf("%v", *o.PageSize)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c StartMenuItemClient) List(ctx context.Context, id ApplicationGroupId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/startMenuItems", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]StartMenuItem `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c StartMenuItemClient) ListComplete(ctx context.Context, id ApplicationGroupId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, StartMenuItemOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StartMenuItemClient) ListCompleteMatchingPredicate(ctx context.Context, id ApplicationGroupId, options ListOperationOptions, predicate StartMenuItemOperationPredicate) (result ListCompleteResult, err error) { + items := make([]StartMenuItem, 0) + + resp, err := c.List(ctx, id, options) + 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 = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/startmenuitem/model_startmenuitem.go b/resource-manager/desktopvirtualization/2024-04-08-preview/startmenuitem/model_startmenuitem.go new file mode 100644 index 00000000000..0005f606886 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/startmenuitem/model_startmenuitem.go @@ -0,0 +1,16 @@ +package startmenuitem + +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 StartMenuItem struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StartMenuItemProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/startmenuitem/model_startmenuitemproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/startmenuitem/model_startmenuitemproperties.go new file mode 100644 index 00000000000..53a69769271 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/startmenuitem/model_startmenuitemproperties.go @@ -0,0 +1,12 @@ +package startmenuitem + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StartMenuItemProperties struct { + AppAlias *string `json:"appAlias,omitempty"` + CommandLineArguments *string `json:"commandLineArguments,omitempty"` + FilePath *string `json:"filePath,omitempty"` + IconIndex *int64 `json:"iconIndex,omitempty"` + IconPath *string `json:"iconPath,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/startmenuitem/predicates.go b/resource-manager/desktopvirtualization/2024-04-08-preview/startmenuitem/predicates.go new file mode 100644 index 00000000000..d20fe5cba0c --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/startmenuitem/predicates.go @@ -0,0 +1,27 @@ +package startmenuitem + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StartMenuItemOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p StartMenuItemOperationPredicate) Matches(input StartMenuItem) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/startmenuitem/version.go b/resource-manager/desktopvirtualization/2024-04-08-preview/startmenuitem/version.go new file mode 100644 index 00000000000..3b95a819bcf --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/startmenuitem/version.go @@ -0,0 +1,10 @@ +package startmenuitem + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-08-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/startmenuitem/2024-04-08-preview" +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/README.md b/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/README.md new file mode 100644 index 00000000000..12f6e39cb15 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/README.md @@ -0,0 +1,123 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/usersession` Documentation + +The `usersession` SDK allows for interaction with Azure Resource Manager `desktopvirtualization` (API Version `2024-04-08-preview`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/usersession" +``` + + +### Client Initialization + +```go +client := usersession.NewUserSessionClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `UserSessionClient.Delete` + +```go +ctx := context.TODO() +id := usersession.NewUserSessionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName", "sessionHostName", "userSessionId") + +read, err := client.Delete(ctx, id, usersession.DefaultDeleteOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `UserSessionClient.Disconnect` + +```go +ctx := context.TODO() +id := usersession.NewUserSessionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName", "sessionHostName", "userSessionId") + +read, err := client.Disconnect(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `UserSessionClient.Get` + +```go +ctx := context.TODO() +id := usersession.NewUserSessionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName", "sessionHostName", "userSessionId") + +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: `UserSessionClient.List` + +```go +ctx := context.TODO() +id := usersession.NewSessionHostID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName", "sessionHostName") + +// alternatively `client.List(ctx, id, usersession.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, usersession.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `UserSessionClient.ListByHostPool` + +```go +ctx := context.TODO() +id := usersession.NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName") + +// alternatively `client.ListByHostPool(ctx, id, usersession.DefaultListByHostPoolOperationOptions())` can be used to do batched pagination +items, err := client.ListByHostPoolComplete(ctx, id, usersession.DefaultListByHostPoolOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `UserSessionClient.SendMessage` + +```go +ctx := context.TODO() +id := usersession.NewUserSessionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName", "sessionHostName", "userSessionId") + +payload := usersession.SendMessage{ + // ... +} + + +read, err := client.SendMessage(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/client.go b/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/client.go new file mode 100644 index 00000000000..25871535051 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/client.go @@ -0,0 +1,26 @@ +package usersession + +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 UserSessionClient struct { + Client *resourcemanager.Client +} + +func NewUserSessionClientWithBaseURI(sdkApi sdkEnv.Api) (*UserSessionClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "usersession", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating UserSessionClient: %+v", err) + } + + return &UserSessionClient{ + Client: client, + }, nil +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/constants.go b/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/constants.go new file mode 100644 index 00000000000..a4762571730 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/constants.go @@ -0,0 +1,104 @@ +package usersession + +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 ApplicationType string + +const ( + ApplicationTypeDesktop ApplicationType = "Desktop" + ApplicationTypeRemoteApp ApplicationType = "RemoteApp" +) + +func PossibleValuesForApplicationType() []string { + return []string{ + string(ApplicationTypeDesktop), + string(ApplicationTypeRemoteApp), + } +} + +func (s *ApplicationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationType(input string) (*ApplicationType, error) { + vals := map[string]ApplicationType{ + "desktop": ApplicationTypeDesktop, + "remoteapp": ApplicationTypeRemoteApp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationType(input) + return &out, nil +} + +type SessionState string + +const ( + SessionStateActive SessionState = "Active" + SessionStateDisconnected SessionState = "Disconnected" + SessionStateLogOff SessionState = "LogOff" + SessionStatePending SessionState = "Pending" + SessionStateUnknown SessionState = "Unknown" + SessionStateUserProfileDiskMounted SessionState = "UserProfileDiskMounted" +) + +func PossibleValuesForSessionState() []string { + return []string{ + string(SessionStateActive), + string(SessionStateDisconnected), + string(SessionStateLogOff), + string(SessionStatePending), + string(SessionStateUnknown), + string(SessionStateUserProfileDiskMounted), + } +} + +func (s *SessionState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSessionState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSessionState(input string) (*SessionState, error) { + vals := map[string]SessionState{ + "active": SessionStateActive, + "disconnected": SessionStateDisconnected, + "logoff": SessionStateLogOff, + "pending": SessionStatePending, + "unknown": SessionStateUnknown, + "userprofilediskmounted": SessionStateUserProfileDiskMounted, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SessionState(input) + return &out, nil +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/id_hostpool.go b/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/id_hostpool.go new file mode 100644 index 00000000000..0174874cf02 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/id_hostpool.go @@ -0,0 +1,130 @@ +package usersession + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&HostPoolId{}) +} + +var _ resourceids.ResourceId = &HostPoolId{} + +// HostPoolId is a struct representing the Resource ID for a Host Pool +type HostPoolId struct { + SubscriptionId string + ResourceGroupName string + HostPoolName string +} + +// NewHostPoolID returns a new HostPoolId struct +func NewHostPoolID(subscriptionId string, resourceGroupName string, hostPoolName string) HostPoolId { + return HostPoolId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + HostPoolName: hostPoolName, + } +} + +// ParseHostPoolID parses 'input' into a HostPoolId +func ParseHostPoolID(input string) (*HostPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostPoolId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostPoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseHostPoolIDInsensitively parses 'input' case-insensitively into a HostPoolId +// note: this method should only be used for API response data and not user input +func ParseHostPoolIDInsensitively(input string) (*HostPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostPoolId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostPoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *HostPoolId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.HostPoolName, ok = input.Parsed["hostPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hostPoolName", input) + } + + return nil +} + +// ValidateHostPoolID checks that 'input' can be parsed as a Host Pool ID +func ValidateHostPoolID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseHostPoolID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Host Pool ID +func (id HostPoolId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DesktopVirtualization/hostPools/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.HostPoolName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Host Pool ID +func (id HostPoolId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDesktopVirtualization", "Microsoft.DesktopVirtualization", "Microsoft.DesktopVirtualization"), + resourceids.StaticSegment("staticHostPools", "hostPools", "hostPools"), + resourceids.UserSpecifiedSegment("hostPoolName", "hostPoolName"), + } +} + +// String returns a human-readable description of this Host Pool ID +func (id HostPoolId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Host Pool Name: %q", id.HostPoolName), + } + return fmt.Sprintf("Host Pool (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/id_hostpool_test.go b/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/id_hostpool_test.go new file mode 100644 index 00000000000..3dda64ec8b2 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/id_hostpool_test.go @@ -0,0 +1,282 @@ +package usersession + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &HostPoolId{} + +func TestNewHostPoolID(t *testing.T) { + id := NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.HostPoolName != "hostPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'HostPoolName'", id.HostPoolName, "hostPoolName") + } +} + +func TestFormatHostPoolID(t *testing.T) { + actual := NewHostPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseHostPoolID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostPoolId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName", + Expected: &HostPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostPoolName: "hostPoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostPoolID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostPoolName != v.Expected.HostPoolName { + t.Fatalf("Expected %q but got %q for HostPoolName", v.Expected.HostPoolName, actual.HostPoolName) + } + + } +} + +func TestParseHostPoolIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostPoolId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName", + Expected: &HostPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostPoolName: "hostPoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs/hOsTpOoLnAmE", + Expected: &HostPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + HostPoolName: "hOsTpOoLnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs/hOsTpOoLnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostPoolIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostPoolName != v.Expected.HostPoolName { + t.Fatalf("Expected %q but got %q for HostPoolName", v.Expected.HostPoolName, actual.HostPoolName) + } + + } +} + +func TestSegmentsForHostPoolId(t *testing.T) { + segments := HostPoolId{}.Segments() + if len(segments) == 0 { + t.Fatalf("HostPoolId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/id_sessionhost.go b/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/id_sessionhost.go new file mode 100644 index 00000000000..bfa632c2b7f --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/id_sessionhost.go @@ -0,0 +1,139 @@ +package usersession + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SessionHostId{}) +} + +var _ resourceids.ResourceId = &SessionHostId{} + +// SessionHostId is a struct representing the Resource ID for a Session Host +type SessionHostId struct { + SubscriptionId string + ResourceGroupName string + HostPoolName string + SessionHostName string +} + +// NewSessionHostID returns a new SessionHostId struct +func NewSessionHostID(subscriptionId string, resourceGroupName string, hostPoolName string, sessionHostName string) SessionHostId { + return SessionHostId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + HostPoolName: hostPoolName, + SessionHostName: sessionHostName, + } +} + +// ParseSessionHostID parses 'input' into a SessionHostId +func ParseSessionHostID(input string) (*SessionHostId, error) { + parser := resourceids.NewParserFromResourceIdType(&SessionHostId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SessionHostId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSessionHostIDInsensitively parses 'input' case-insensitively into a SessionHostId +// note: this method should only be used for API response data and not user input +func ParseSessionHostIDInsensitively(input string) (*SessionHostId, error) { + parser := resourceids.NewParserFromResourceIdType(&SessionHostId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SessionHostId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SessionHostId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.HostPoolName, ok = input.Parsed["hostPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hostPoolName", input) + } + + if id.SessionHostName, ok = input.Parsed["sessionHostName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "sessionHostName", input) + } + + return nil +} + +// ValidateSessionHostID checks that 'input' can be parsed as a Session Host ID +func ValidateSessionHostID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSessionHostID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Session Host ID +func (id SessionHostId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DesktopVirtualization/hostPools/%s/sessionHosts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.HostPoolName, id.SessionHostName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Session Host ID +func (id SessionHostId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDesktopVirtualization", "Microsoft.DesktopVirtualization", "Microsoft.DesktopVirtualization"), + resourceids.StaticSegment("staticHostPools", "hostPools", "hostPools"), + resourceids.UserSpecifiedSegment("hostPoolName", "hostPoolName"), + resourceids.StaticSegment("staticSessionHosts", "sessionHosts", "sessionHosts"), + resourceids.UserSpecifiedSegment("sessionHostName", "sessionHostName"), + } +} + +// String returns a human-readable description of this Session Host ID +func (id SessionHostId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Host Pool Name: %q", id.HostPoolName), + fmt.Sprintf("Session Host Name: %q", id.SessionHostName), + } + return fmt.Sprintf("Session Host (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/id_sessionhost_test.go b/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/id_sessionhost_test.go new file mode 100644 index 00000000000..dbd5104ac5b --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/id_sessionhost_test.go @@ -0,0 +1,327 @@ +package usersession + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SessionHostId{} + +func TestNewSessionHostID(t *testing.T) { + id := NewSessionHostID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName", "sessionHostName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.HostPoolName != "hostPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'HostPoolName'", id.HostPoolName, "hostPoolName") + } + + if id.SessionHostName != "sessionHostName" { + t.Fatalf("Expected %q but got %q for Segment 'SessionHostName'", id.SessionHostName, "sessionHostName") + } +} + +func TestFormatSessionHostID(t *testing.T) { + actual := NewSessionHostID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName", "sessionHostName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/sessionHosts/sessionHostName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSessionHostID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SessionHostId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/sessionHosts", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/sessionHosts/sessionHostName", + Expected: &SessionHostId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostPoolName: "hostPoolName", + SessionHostName: "sessionHostName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/sessionHosts/sessionHostName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSessionHostID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostPoolName != v.Expected.HostPoolName { + t.Fatalf("Expected %q but got %q for HostPoolName", v.Expected.HostPoolName, actual.HostPoolName) + } + + if actual.SessionHostName != v.Expected.SessionHostName { + t.Fatalf("Expected %q but got %q for SessionHostName", v.Expected.SessionHostName, actual.SessionHostName) + } + + } +} + +func TestParseSessionHostIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SessionHostId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs/hOsTpOoLnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/sessionHosts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs/hOsTpOoLnAmE/sEsSiOnHoStS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/sessionHosts/sessionHostName", + Expected: &SessionHostId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostPoolName: "hostPoolName", + SessionHostName: "sessionHostName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/sessionHosts/sessionHostName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs/hOsTpOoLnAmE/sEsSiOnHoStS/sEsSiOnHoStNaMe", + Expected: &SessionHostId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + HostPoolName: "hOsTpOoLnAmE", + SessionHostName: "sEsSiOnHoStNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs/hOsTpOoLnAmE/sEsSiOnHoStS/sEsSiOnHoStNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSessionHostIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostPoolName != v.Expected.HostPoolName { + t.Fatalf("Expected %q but got %q for HostPoolName", v.Expected.HostPoolName, actual.HostPoolName) + } + + if actual.SessionHostName != v.Expected.SessionHostName { + t.Fatalf("Expected %q but got %q for SessionHostName", v.Expected.SessionHostName, actual.SessionHostName) + } + + } +} + +func TestSegmentsForSessionHostId(t *testing.T) { + segments := SessionHostId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SessionHostId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/id_usersession.go b/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/id_usersession.go new file mode 100644 index 00000000000..1c92fb56887 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/id_usersession.go @@ -0,0 +1,148 @@ +package usersession + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&UserSessionId{}) +} + +var _ resourceids.ResourceId = &UserSessionId{} + +// UserSessionId is a struct representing the Resource ID for a User Session +type UserSessionId struct { + SubscriptionId string + ResourceGroupName string + HostPoolName string + SessionHostName string + UserSessionId string +} + +// NewUserSessionID returns a new UserSessionId struct +func NewUserSessionID(subscriptionId string, resourceGroupName string, hostPoolName string, sessionHostName string, userSessionId string) UserSessionId { + return UserSessionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + HostPoolName: hostPoolName, + SessionHostName: sessionHostName, + UserSessionId: userSessionId, + } +} + +// ParseUserSessionID parses 'input' into a UserSessionId +func ParseUserSessionID(input string) (*UserSessionId, error) { + parser := resourceids.NewParserFromResourceIdType(&UserSessionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := UserSessionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseUserSessionIDInsensitively parses 'input' case-insensitively into a UserSessionId +// note: this method should only be used for API response data and not user input +func ParseUserSessionIDInsensitively(input string) (*UserSessionId, error) { + parser := resourceids.NewParserFromResourceIdType(&UserSessionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := UserSessionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *UserSessionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.HostPoolName, ok = input.Parsed["hostPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hostPoolName", input) + } + + if id.SessionHostName, ok = input.Parsed["sessionHostName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "sessionHostName", input) + } + + if id.UserSessionId, ok = input.Parsed["userSessionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "userSessionId", input) + } + + return nil +} + +// ValidateUserSessionID checks that 'input' can be parsed as a User Session ID +func ValidateUserSessionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseUserSessionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted User Session ID +func (id UserSessionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DesktopVirtualization/hostPools/%s/sessionHosts/%s/userSessions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.HostPoolName, id.SessionHostName, id.UserSessionId) +} + +// Segments returns a slice of Resource ID Segments which comprise this User Session ID +func (id UserSessionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDesktopVirtualization", "Microsoft.DesktopVirtualization", "Microsoft.DesktopVirtualization"), + resourceids.StaticSegment("staticHostPools", "hostPools", "hostPools"), + resourceids.UserSpecifiedSegment("hostPoolName", "hostPoolName"), + resourceids.StaticSegment("staticSessionHosts", "sessionHosts", "sessionHosts"), + resourceids.UserSpecifiedSegment("sessionHostName", "sessionHostName"), + resourceids.StaticSegment("staticUserSessions", "userSessions", "userSessions"), + resourceids.UserSpecifiedSegment("userSessionId", "userSessionId"), + } +} + +// String returns a human-readable description of this User Session ID +func (id UserSessionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Host Pool Name: %q", id.HostPoolName), + fmt.Sprintf("Session Host Name: %q", id.SessionHostName), + fmt.Sprintf("User Session: %q", id.UserSessionId), + } + return fmt.Sprintf("User Session (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/id_usersession_test.go b/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/id_usersession_test.go new file mode 100644 index 00000000000..aafc1bdcd27 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/id_usersession_test.go @@ -0,0 +1,372 @@ +package usersession + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &UserSessionId{} + +func TestNewUserSessionID(t *testing.T) { + id := NewUserSessionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName", "sessionHostName", "userSessionId") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.HostPoolName != "hostPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'HostPoolName'", id.HostPoolName, "hostPoolName") + } + + if id.SessionHostName != "sessionHostName" { + t.Fatalf("Expected %q but got %q for Segment 'SessionHostName'", id.SessionHostName, "sessionHostName") + } + + if id.UserSessionId != "userSessionId" { + t.Fatalf("Expected %q but got %q for Segment 'UserSessionId'", id.UserSessionId, "userSessionId") + } +} + +func TestFormatUserSessionID(t *testing.T) { + actual := NewUserSessionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostPoolName", "sessionHostName", "userSessionId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/sessionHosts/sessionHostName/userSessions/userSessionId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseUserSessionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *UserSessionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/sessionHosts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/sessionHosts/sessionHostName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/sessionHosts/sessionHostName/userSessions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/sessionHosts/sessionHostName/userSessions/userSessionId", + Expected: &UserSessionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostPoolName: "hostPoolName", + SessionHostName: "sessionHostName", + UserSessionId: "userSessionId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/sessionHosts/sessionHostName/userSessions/userSessionId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseUserSessionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostPoolName != v.Expected.HostPoolName { + t.Fatalf("Expected %q but got %q for HostPoolName", v.Expected.HostPoolName, actual.HostPoolName) + } + + if actual.SessionHostName != v.Expected.SessionHostName { + t.Fatalf("Expected %q but got %q for SessionHostName", v.Expected.SessionHostName, actual.SessionHostName) + } + + if actual.UserSessionId != v.Expected.UserSessionId { + t.Fatalf("Expected %q but got %q for UserSessionId", v.Expected.UserSessionId, actual.UserSessionId) + } + + } +} + +func TestParseUserSessionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *UserSessionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs/hOsTpOoLnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/sessionHosts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs/hOsTpOoLnAmE/sEsSiOnHoStS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/sessionHosts/sessionHostName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs/hOsTpOoLnAmE/sEsSiOnHoStS/sEsSiOnHoStNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/sessionHosts/sessionHostName/userSessions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs/hOsTpOoLnAmE/sEsSiOnHoStS/sEsSiOnHoStNaMe/uSeRsEsSiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/sessionHosts/sessionHostName/userSessions/userSessionId", + Expected: &UserSessionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostPoolName: "hostPoolName", + SessionHostName: "sessionHostName", + UserSessionId: "userSessionId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/hostPools/hostPoolName/sessionHosts/sessionHostName/userSessions/userSessionId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs/hOsTpOoLnAmE/sEsSiOnHoStS/sEsSiOnHoStNaMe/uSeRsEsSiOnS/uSeRsEsSiOnId", + Expected: &UserSessionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + HostPoolName: "hOsTpOoLnAmE", + SessionHostName: "sEsSiOnHoStNaMe", + UserSessionId: "uSeRsEsSiOnId", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/hOsTpOoLs/hOsTpOoLnAmE/sEsSiOnHoStS/sEsSiOnHoStNaMe/uSeRsEsSiOnS/uSeRsEsSiOnId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseUserSessionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostPoolName != v.Expected.HostPoolName { + t.Fatalf("Expected %q but got %q for HostPoolName", v.Expected.HostPoolName, actual.HostPoolName) + } + + if actual.SessionHostName != v.Expected.SessionHostName { + t.Fatalf("Expected %q but got %q for SessionHostName", v.Expected.SessionHostName, actual.SessionHostName) + } + + if actual.UserSessionId != v.Expected.UserSessionId { + t.Fatalf("Expected %q but got %q for UserSessionId", v.Expected.UserSessionId, actual.UserSessionId) + } + + } +} + +func TestSegmentsForUserSessionId(t *testing.T) { + segments := UserSessionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("UserSessionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/method_delete.go b/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/method_delete.go new file mode 100644 index 00000000000..ab809bdd242 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/method_delete.go @@ -0,0 +1,77 @@ +package usersession + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + Force *bool +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Force != nil { + out.Append("force", fmt.Sprintf("%v", *o.Force)) + } + return &out +} + +// Delete ... +func (c UserSessionClient) Delete(ctx context.Context, id UserSessionId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + 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/desktopvirtualization/2024-04-08-preview/usersession/method_disconnect.go b/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/method_disconnect.go new file mode 100644 index 00000000000..26722c46eba --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/method_disconnect.go @@ -0,0 +1,47 @@ +package usersession + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DisconnectOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Disconnect ... +func (c UserSessionClient) Disconnect(ctx context.Context, id UserSessionId) (result DisconnectOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/disconnect", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + 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/desktopvirtualization/2024-04-08-preview/usersession/method_get.go b/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/method_get.go new file mode 100644 index 00000000000..0836c7b82f1 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/method_get.go @@ -0,0 +1,53 @@ +package usersession + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *UserSession +} + +// Get ... +func (c UserSessionClient) Get(ctx context.Context, id UserSessionId) (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 UserSession + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/method_list.go b/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/method_list.go new file mode 100644 index 00000000000..dfbf45ec335 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/method_list.go @@ -0,0 +1,142 @@ +package usersession + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]UserSession +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []UserSession +} + +type ListOperationOptions struct { + InitialSkip *int64 + IsDescending *bool + PageSize *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.InitialSkip != nil { + out.Append("initialSkip", fmt.Sprintf("%v", *o.InitialSkip)) + } + if o.IsDescending != nil { + out.Append("isDescending", fmt.Sprintf("%v", *o.IsDescending)) + } + if o.PageSize != nil { + out.Append("pageSize", fmt.Sprintf("%v", *o.PageSize)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c UserSessionClient) List(ctx context.Context, id SessionHostId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/userSessions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]UserSession `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c UserSessionClient) ListComplete(ctx context.Context, id SessionHostId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, UserSessionOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c UserSessionClient) ListCompleteMatchingPredicate(ctx context.Context, id SessionHostId, options ListOperationOptions, predicate UserSessionOperationPredicate) (result ListCompleteResult, err error) { + items := make([]UserSession, 0) + + resp, err := c.List(ctx, id, options) + 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 = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/method_listbyhostpool.go b/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/method_listbyhostpool.go new file mode 100644 index 00000000000..7982632f254 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/method_listbyhostpool.go @@ -0,0 +1,146 @@ +package usersession + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByHostPoolOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]UserSession +} + +type ListByHostPoolCompleteResult struct { + LatestHttpResponse *http.Response + Items []UserSession +} + +type ListByHostPoolOperationOptions struct { + Filter *string + InitialSkip *int64 + IsDescending *bool + PageSize *int64 +} + +func DefaultListByHostPoolOperationOptions() ListByHostPoolOperationOptions { + return ListByHostPoolOperationOptions{} +} + +func (o ListByHostPoolOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByHostPoolOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListByHostPoolOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.InitialSkip != nil { + out.Append("initialSkip", fmt.Sprintf("%v", *o.InitialSkip)) + } + if o.IsDescending != nil { + out.Append("isDescending", fmt.Sprintf("%v", *o.IsDescending)) + } + if o.PageSize != nil { + out.Append("pageSize", fmt.Sprintf("%v", *o.PageSize)) + } + return &out +} + +type ListByHostPoolCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByHostPoolCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByHostPool ... +func (c UserSessionClient) ListByHostPool(ctx context.Context, id HostPoolId, options ListByHostPoolOperationOptions) (result ListByHostPoolOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListByHostPoolCustomPager{}, + Path: fmt.Sprintf("%s/userSessions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]UserSession `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByHostPoolComplete retrieves all the results into a single object +func (c UserSessionClient) ListByHostPoolComplete(ctx context.Context, id HostPoolId, options ListByHostPoolOperationOptions) (ListByHostPoolCompleteResult, error) { + return c.ListByHostPoolCompleteMatchingPredicate(ctx, id, options, UserSessionOperationPredicate{}) +} + +// ListByHostPoolCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c UserSessionClient) ListByHostPoolCompleteMatchingPredicate(ctx context.Context, id HostPoolId, options ListByHostPoolOperationOptions, predicate UserSessionOperationPredicate) (result ListByHostPoolCompleteResult, err error) { + items := make([]UserSession, 0) + + resp, err := c.ListByHostPool(ctx, id, options) + 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 = ListByHostPoolCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/method_sendmessage.go b/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/method_sendmessage.go new file mode 100644 index 00000000000..f666934ee40 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/method_sendmessage.go @@ -0,0 +1,51 @@ +package usersession + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SendMessageOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// SendMessage ... +func (c UserSessionClient) SendMessage(ctx context.Context, id UserSessionId, input SendMessage) (result SendMessageOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/sendMessage", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + 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/desktopvirtualization/2024-04-08-preview/usersession/model_sendmessage.go b/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/model_sendmessage.go new file mode 100644 index 00000000000..6e74c2bcb0a --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/model_sendmessage.go @@ -0,0 +1,9 @@ +package usersession + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SendMessage struct { + MessageBody *string `json:"messageBody,omitempty"` + MessageTitle *string `json:"messageTitle,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/model_usersession.go b/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/model_usersession.go new file mode 100644 index 00000000000..34c95e10b6f --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/model_usersession.go @@ -0,0 +1,16 @@ +package usersession + +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 UserSession struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *UserSessionProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/model_usersessionproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/model_usersessionproperties.go new file mode 100644 index 00000000000..e9f81a882eb --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/model_usersessionproperties.go @@ -0,0 +1,31 @@ +package usersession + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserSessionProperties struct { + ActiveDirectoryUserName *string `json:"activeDirectoryUserName,omitempty"` + ApplicationType *ApplicationType `json:"applicationType,omitempty"` + CreateTime *string `json:"createTime,omitempty"` + ObjectId *string `json:"objectId,omitempty"` + SessionState *SessionState `json:"sessionState,omitempty"` + UserPrincipalName *string `json:"userPrincipalName,omitempty"` +} + +func (o *UserSessionProperties) GetCreateTimeAsTime() (*time.Time, error) { + if o.CreateTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreateTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *UserSessionProperties) SetCreateTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreateTime = &formatted +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/predicates.go b/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/predicates.go new file mode 100644 index 00000000000..6d37fbea4d8 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/predicates.go @@ -0,0 +1,27 @@ +package usersession + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserSessionOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p UserSessionOperationPredicate) Matches(input UserSession) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/version.go b/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/version.go new file mode 100644 index 00000000000..16daafc162b --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/usersession/version.go @@ -0,0 +1,10 @@ +package usersession + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-08-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/usersession/2024-04-08-preview" +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/README.md b/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/README.md new file mode 100644 index 00000000000..94f8dd82ce6 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/README.md @@ -0,0 +1,129 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2024-04-08-preview/workspace` Documentation + +The `workspace` SDK allows for interaction with Azure Resource Manager `desktopvirtualization` (API Version `2024-04-08-preview`). + +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/desktopvirtualization/2024-04-08-preview/workspace" +``` + + +### Client Initialization + +```go +client := workspace.NewWorkspaceClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `WorkspaceClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := workspace.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +payload := workspace.Workspace{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WorkspaceClient.Delete` + +```go +ctx := context.TODO() +id := workspace.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WorkspaceClient.Get` + +```go +ctx := context.TODO() +id := workspace.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +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: `WorkspaceClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id, workspace.DefaultListByResourceGroupOperationOptions())` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id, workspace.DefaultListByResourceGroupOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WorkspaceClient.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: `WorkspaceClient.Update` + +```go +ctx := context.TODO() +id := workspace.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +payload := workspace.WorkspacePatch{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/client.go b/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/client.go new file mode 100644 index 00000000000..ead98c0060b --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/client.go @@ -0,0 +1,26 @@ +package workspace + +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 WorkspaceClient struct { + Client *resourcemanager.Client +} + +func NewWorkspaceClientWithBaseURI(sdkApi sdkEnv.Api) (*WorkspaceClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "workspace", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating WorkspaceClient: %+v", err) + } + + return &WorkspaceClient{ + Client: client, + }, nil +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/constants.go b/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/constants.go new file mode 100644 index 00000000000..bf80ea3b9e6 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/constants.go @@ -0,0 +1,189 @@ +package workspace + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProvisioningState string + +const ( + PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" + PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" + PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" + PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" +) + +func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { + return []string{ + string(PrivateEndpointConnectionProvisioningStateCreating), + string(PrivateEndpointConnectionProvisioningStateDeleting), + string(PrivateEndpointConnectionProvisioningStateFailed), + string(PrivateEndpointConnectionProvisioningStateSucceeded), + } +} + +func (s *PrivateEndpointConnectionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointConnectionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { + vals := map[string]PrivateEndpointConnectionProvisioningState{ + "creating": PrivateEndpointConnectionProvisioningStateCreating, + "deleting": PrivateEndpointConnectionProvisioningStateDeleting, + "failed": PrivateEndpointConnectionProvisioningStateFailed, + "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointConnectionProvisioningState(input) + return &out, nil +} + +type PrivateEndpointServiceConnectionStatus string + +const ( + PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" + PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" + PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" +) + +func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { + return []string{ + string(PrivateEndpointServiceConnectionStatusApproved), + string(PrivateEndpointServiceConnectionStatusPending), + string(PrivateEndpointServiceConnectionStatusRejected), + } +} + +func (s *PrivateEndpointServiceConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointServiceConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { + vals := map[string]PrivateEndpointServiceConnectionStatus{ + "approved": PrivateEndpointServiceConnectionStatusApproved, + "pending": PrivateEndpointServiceConnectionStatusPending, + "rejected": PrivateEndpointServiceConnectionStatusRejected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointServiceConnectionStatus(input) + return &out, nil +} + +type PublicNetworkAccess string + +const ( + PublicNetworkAccessDisabled PublicNetworkAccess = "Disabled" + PublicNetworkAccessEnabled PublicNetworkAccess = "Enabled" +) + +func PossibleValuesForPublicNetworkAccess() []string { + return []string{ + string(PublicNetworkAccessDisabled), + string(PublicNetworkAccessEnabled), + } +} + +func (s *PublicNetworkAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicNetworkAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicNetworkAccess(input string) (*PublicNetworkAccess, error) { + vals := map[string]PublicNetworkAccess{ + "disabled": PublicNetworkAccessDisabled, + "enabled": PublicNetworkAccessEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicNetworkAccess(input) + return &out, nil +} + +type SkuTier string + +const ( + SkuTierBasic SkuTier = "Basic" + SkuTierFree SkuTier = "Free" + SkuTierPremium SkuTier = "Premium" + SkuTierStandard SkuTier = "Standard" +) + +func PossibleValuesForSkuTier() []string { + return []string{ + string(SkuTierBasic), + string(SkuTierFree), + string(SkuTierPremium), + string(SkuTierStandard), + } +} + +func (s *SkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSkuTier(input string) (*SkuTier, error) { + vals := map[string]SkuTier{ + "basic": SkuTierBasic, + "free": SkuTierFree, + "premium": SkuTierPremium, + "standard": SkuTierStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SkuTier(input) + return &out, nil +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/id_workspace.go b/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/id_workspace.go new file mode 100644 index 00000000000..f94105bfa0c --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/id_workspace.go @@ -0,0 +1,130 @@ +package workspace + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&WorkspaceId{}) +} + +var _ resourceids.ResourceId = &WorkspaceId{} + +// WorkspaceId is a struct representing the Resource ID for a Workspace +type WorkspaceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string +} + +// NewWorkspaceID returns a new WorkspaceId struct +func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + } +} + +// ParseWorkspaceID parses 'input' into a WorkspaceId +func ParseWorkspaceID(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + return nil +} + +// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID +func ValidateWorkspaceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace ID +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DesktopVirtualization/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace ID +func (id WorkspaceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDesktopVirtualization", "Microsoft.DesktopVirtualization", "Microsoft.DesktopVirtualization"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + } +} + +// String returns a human-readable description of this Workspace ID +func (id WorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + } + return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/id_workspace_test.go b/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/id_workspace_test.go new file mode 100644 index 00000000000..c5e260f0486 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/id_workspace_test.go @@ -0,0 +1,282 @@ +package workspace + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &WorkspaceId{} + +func TestNewWorkspaceID(t *testing.T) { + id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } +} + +func TestFormatWorkspaceID(t *testing.T) { + actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/workspaces/workspaceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/workspaces/workspaceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestParseWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DesktopVirtualization/workspaces/workspaceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/wOrKsPaCeS/wOrKsPaCeNaMe", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEsKtOpViRtUaLiZaTiOn/wOrKsPaCeS/wOrKsPaCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestSegmentsForWorkspaceId(t *testing.T) { + segments := WorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspaceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/method_createorupdate.go b/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/method_createorupdate.go new file mode 100644 index 00000000000..3a6d6d331f2 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/method_createorupdate.go @@ -0,0 +1,58 @@ +package workspace + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Workspace +} + +// CreateOrUpdate ... +func (c WorkspaceClient) CreateOrUpdate(ctx context.Context, id WorkspaceId, input Workspace) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Workspace + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/method_delete.go b/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/method_delete.go new file mode 100644 index 00000000000..f790b393264 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/method_delete.go @@ -0,0 +1,47 @@ +package workspace + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c WorkspaceClient) Delete(ctx context.Context, id WorkspaceId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/method_get.go b/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/method_get.go new file mode 100644 index 00000000000..3a673fbc7c2 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/method_get.go @@ -0,0 +1,53 @@ +package workspace + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *Workspace +} + +// Get ... +func (c WorkspaceClient) Get(ctx context.Context, id WorkspaceId) (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 Workspace + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/method_listbyresourcegroup.go b/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/method_listbyresourcegroup.go new file mode 100644 index 00000000000..58fc7e68a7a --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/method_listbyresourcegroup.go @@ -0,0 +1,143 @@ +package workspace + +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 *[]Workspace +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []Workspace +} + +type ListByResourceGroupOperationOptions struct { + InitialSkip *int64 + IsDescending *bool + PageSize *int64 +} + +func DefaultListByResourceGroupOperationOptions() ListByResourceGroupOperationOptions { + return ListByResourceGroupOperationOptions{} +} + +func (o ListByResourceGroupOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByResourceGroupOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListByResourceGroupOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.InitialSkip != nil { + out.Append("initialSkip", fmt.Sprintf("%v", *o.InitialSkip)) + } + if o.IsDescending != nil { + out.Append("isDescending", fmt.Sprintf("%v", *o.IsDescending)) + } + if o.PageSize != nil { + out.Append("pageSize", fmt.Sprintf("%v", *o.PageSize)) + } + return &out +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c WorkspaceClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DesktopVirtualization/workspaces", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Workspace `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 WorkspaceClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, options, WorkspaceOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WorkspaceClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions, predicate WorkspaceOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]Workspace, 0) + + resp, err := c.ListByResourceGroup(ctx, id, options) + 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/desktopvirtualization/2024-04-08-preview/workspace/method_listbysubscription.go b/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/method_listbysubscription.go new file mode 100644 index 00000000000..ada2238424f --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/method_listbysubscription.go @@ -0,0 +1,106 @@ +package workspace + +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 *[]Workspace +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []Workspace +} + +type ListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySubscription ... +func (c WorkspaceClient) 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, + Pager: &ListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DesktopVirtualization/workspaces", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Workspace `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 WorkspaceClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, WorkspaceOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WorkspaceClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate WorkspaceOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]Workspace, 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/desktopvirtualization/2024-04-08-preview/workspace/method_update.go b/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/method_update.go new file mode 100644 index 00000000000..f7f12884d0f --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/method_update.go @@ -0,0 +1,57 @@ +package workspace + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Workspace +} + +// Update ... +func (c WorkspaceClient) Update(ctx context.Context, id WorkspaceId, input WorkspacePatch) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Workspace + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/model_plan.go b/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/model_plan.go new file mode 100644 index 00000000000..5fb713a75fe --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/model_plan.go @@ -0,0 +1,12 @@ +package workspace + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Plan struct { + Name string `json:"name"` + Product string `json:"product"` + PromotionCode *string `json:"promotionCode,omitempty"` + Publisher string `json:"publisher"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/model_privateendpoint.go b/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/model_privateendpoint.go new file mode 100644 index 00000000000..f3aaa3c262c --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/model_privateendpoint.go @@ -0,0 +1,8 @@ +package workspace + +// 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/desktopvirtualization/2024-04-08-preview/workspace/model_privateendpointconnection.go b/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/model_privateendpointconnection.go new file mode 100644 index 00000000000..2ebe85353a0 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/model_privateendpointconnection.go @@ -0,0 +1,16 @@ +package workspace + +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/desktopvirtualization/2024-04-08-preview/workspace/model_privateendpointconnectionproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..3de607295a6 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/model_privateendpointconnectionproperties.go @@ -0,0 +1,11 @@ +package workspace + +// 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"` + ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/model_privatelinkserviceconnectionstate.go b/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..074cb7dfa9e --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package workspace + +// 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 *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/model_sku.go b/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/model_sku.go new file mode 100644 index 00000000000..8b18e233d75 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/model_sku.go @@ -0,0 +1,12 @@ +package workspace + +// 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 *int64 `json:"capacity,omitempty"` + Family *string `json:"family,omitempty"` + Name string `json:"name"` + Size *string `json:"size,omitempty"` + Tier *SkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/model_workspace.go b/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/model_workspace.go new file mode 100644 index 00000000000..d734cf10db6 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/model_workspace.go @@ -0,0 +1,25 @@ +package workspace + +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 Workspace struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + ManagedBy *string `json:"managedBy,omitempty"` + Name *string `json:"name,omitempty"` + Plan *Plan `json:"plan,omitempty"` + Properties *WorkspaceProperties `json:"properties,omitempty"` + Sku *Sku `json:"sku,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/model_workspacepatch.go b/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/model_workspacepatch.go new file mode 100644 index 00000000000..1ac870f647e --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/model_workspacepatch.go @@ -0,0 +1,9 @@ +package workspace + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspacePatch struct { + Properties *WorkspacePatchProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/model_workspacepatchproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/model_workspacepatchproperties.go new file mode 100644 index 00000000000..3f010914b65 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/model_workspacepatchproperties.go @@ -0,0 +1,11 @@ +package workspace + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspacePatchProperties struct { + ApplicationGroupReferences *[]string `json:"applicationGroupReferences,omitempty"` + Description *string `json:"description,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/model_workspaceproperties.go b/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/model_workspaceproperties.go new file mode 100644 index 00000000000..d180ba181cf --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/model_workspaceproperties.go @@ -0,0 +1,14 @@ +package workspace + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceProperties struct { + ApplicationGroupReferences *[]string `json:"applicationGroupReferences,omitempty"` + CloudPcResource *bool `json:"cloudPcResource,omitempty"` + Description *string `json:"description,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ObjectId *string `json:"objectId,omitempty"` + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/predicates.go b/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/predicates.go new file mode 100644 index 00000000000..68a9586c403 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/predicates.go @@ -0,0 +1,47 @@ +package workspace + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceOperationPredicate struct { + Etag *string + Id *string + Kind *string + Location *string + ManagedBy *string + Name *string + Type *string +} + +func (p WorkspaceOperationPredicate) Matches(input Workspace) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.ManagedBy != nil && (input.ManagedBy == nil || *p.ManagedBy != *input.ManagedBy) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/version.go b/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/version.go new file mode 100644 index 00000000000..5cbdd8008c7 --- /dev/null +++ b/resource-manager/desktopvirtualization/2024-04-08-preview/workspace/version.go @@ -0,0 +1,10 @@ +package workspace + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-08-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/workspace/2024-04-08-preview" +} diff --git a/resource-manager/network/2024-05-01/networkmanagereffectiveconnectivityconfiguration/constants.go b/resource-manager/network/2024-05-01/networkmanagereffectiveconnectivityconfiguration/constants.go index caa8b3c8747..9007e4a33df 100644 --- a/resource-manager/network/2024-05-01/networkmanagereffectiveconnectivityconfiguration/constants.go +++ b/resource-manager/network/2024-05-01/networkmanagereffectiveconnectivityconfiguration/constants.go @@ -217,6 +217,8 @@ func parseIsGlobal(input string) (*IsGlobal, error) { type ProvisioningState string const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" ProvisioningStateDeleting ProvisioningState = "Deleting" ProvisioningStateFailed ProvisioningState = "Failed" ProvisioningStateSucceeded ProvisioningState = "Succeeded" @@ -225,6 +227,8 @@ const ( func PossibleValuesForProvisioningState() []string { return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateCreating), string(ProvisioningStateDeleting), string(ProvisioningStateFailed), string(ProvisioningStateSucceeded), @@ -247,6 +251,8 @@ func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { func parseProvisioningState(input string) (*ProvisioningState, error) { vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "creating": ProvisioningStateCreating, "deleting": ProvisioningStateDeleting, "failed": ProvisioningStateFailed, "succeeded": ProvisioningStateSucceeded, diff --git a/resource-manager/network/2024-05-01/networkmanagereffectivesecurityadminrules/constants.go b/resource-manager/network/2024-05-01/networkmanagereffectivesecurityadminrules/constants.go index 67086d778e3..6dbd1e6db74 100644 --- a/resource-manager/network/2024-05-01/networkmanagereffectivesecurityadminrules/constants.go +++ b/resource-manager/network/2024-05-01/networkmanagereffectivesecurityadminrules/constants.go @@ -138,6 +138,8 @@ func parseGroupMemberType(input string) (*GroupMemberType, error) { type ProvisioningState string const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" ProvisioningStateDeleting ProvisioningState = "Deleting" ProvisioningStateFailed ProvisioningState = "Failed" ProvisioningStateSucceeded ProvisioningState = "Succeeded" @@ -146,6 +148,8 @@ const ( func PossibleValuesForProvisioningState() []string { return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateCreating), string(ProvisioningStateDeleting), string(ProvisioningStateFailed), string(ProvisioningStateSucceeded), @@ -168,6 +172,8 @@ func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { func parseProvisioningState(input string) (*ProvisioningState, error) { vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "creating": ProvisioningStateCreating, "deleting": ProvisioningStateDeleting, "failed": ProvisioningStateFailed, "succeeded": ProvisioningStateSucceeded,