From 3fe7a17d84ab8b8f0f84d45f27e5bf0d9865b597 Mon Sep 17 00:00:00 2001 From: hc-github-team-tf-azure <> Date: Mon, 3 Mar 2025 13:16:08 +0000 Subject: [PATCH] Updating based on a7bf2ed52 --- ...model_oraclelinkedservicetypeproperties.go | 2 +- ...model_oraclelinkedservicetypeproperties.go | 2 +- resource-manager/logz/2020-10-01/client.go | 64 --- .../logz/2020-10-01/monitors/README.md | 160 -------- .../logz/2020-10-01/monitors/constants.go | 280 ------------- .../logz/2020-10-01/monitors/id_monitor.go | 130 ------ .../monitors/method_listmonitoredresources.go | 105 ----- .../monitors/method_listuserroles.go | 105 ----- .../monitors/model_identityproperties.go | 10 - .../monitors/model_logzmonitorresource.go | 19 - ...del_logzmonitorresourceupdateparameters.go | 9 - .../model_logzorganizationproperties.go | 11 - .../monitors/model_monitoredresource.go | 17 - .../monitors/model_monitorproperties.go | 15 - .../2020-10-01/monitors/model_plandata.go | 29 -- .../2020-10-01/monitors/model_userinfo.go | 11 - .../logz/2020-10-01/monitors/predicates.go | 73 ---- .../logz/2020-10-01/singlesignon/README.md | 70 ---- .../logz/2020-10-01/singlesignon/constants.go | 119 ------ .../2020-10-01/singlesignon/id_monitor.go | 130 ------ .../id_singlesignonconfiguration.go | 139 ------- .../model_logzsinglesignonproperties.go | 11 - .../logz/2020-10-01/subaccount/README.md | 120 ------ .../logz/2020-10-01/subaccount/constants.go | 236 ----------- .../logz/2020-10-01/subaccount/id_account.go | 139 ------- .../2020-10-01/subaccount/id_account_test.go | 327 --------------- .../logz/2020-10-01/subaccount/id_monitor.go | 130 ------ .../logz/2020-10-01/subaccount/method_list.go | 105 ----- .../method_listmonitoredresources.go | 105 ----- .../subaccount/model_identityproperties.go | 10 - .../subaccount/model_logzmonitorresource.go | 19 - ...del_logzmonitorresourceupdateparameters.go | 9 - .../model_logzorganizationproperties.go | 11 - .../subaccount/model_monitoredresource.go | 17 - .../subaccount/model_monitorproperties.go | 15 - .../2020-10-01/subaccount/model_plandata.go | 29 -- .../2020-10-01/subaccount/model_userinfo.go | 11 - .../logz/2020-10-01/subaccount/predicates.go | 65 --- .../logz/2020-10-01/tagrules/README.md | 160 -------- .../logz/2020-10-01/tagrules/constants.go | 113 ------ .../logz/2020-10-01/tagrules/id_account.go | 139 ------- .../2020-10-01/tagrules/id_accounttagrule.go | 148 ------- .../tagrules/id_accounttagrule_test.go | 372 ------------------ .../logz/2020-10-01/tagrules/id_monitor.go | 130 ------ .../logz/2020-10-01/tagrules/id_tagrule.go | 139 ------- .../logz/2020-10-01/tagrules/method_list.go | 105 ----- .../tagrules/method_subaccounttagrulesget.go | 53 --- .../tagrules/method_subaccounttagruleslist.go | 105 ----- .../2020-10-01/tagrules/model_filteringtag.go | 10 - .../2020-10-01/tagrules/model_logrules.go | 11 - .../tagrules/model_monitoringtagrules.go | 16 - .../model_monitoringtagrulesproperties.go | 14 - .../logz/2020-10-01/vmhost/README.md | 130 ------ .../logz/2020-10-01/vmhost/constants.go | 51 --- .../logz/2020-10-01/vmhost/id_account.go | 139 ------- .../logz/2020-10-01/vmhost/id_account_test.go | 327 --------------- .../logz/2020-10-01/vmhost/id_monitor.go | 130 ------ .../logz/2020-10-01/vmhost/id_monitor_test.go | 282 ------------- .../vmhost/method_monitorlistvmhosts.go | 105 ----- .../vmhost/method_monitorlistvmhostupdate.go | 105 ----- .../method_subaccountlistvmhostupdate.go | 105 ----- .../vmhost/method_subaccountvmhostpayload.go | 54 --- .../vmhost/model_vmextensionpayload.go | 9 - .../vmhost/model_vmhostupdaterequest.go | 9 - .../2020-10-01/vmhost/model_vmresources.go | 9 - .../logz/2020-10-01/vmhost/predicates.go | 22 -- .../model_kubernetesonlinedeployment.go | 4 + .../model_managedonlinedeployment.go | 4 + .../model_onlinedeployment.go | 3 + .../mixedreality/2025-01-01/client.go | 46 +++ .../mixedreality/2025-01-01/key/README.md | 57 +++ .../2025-01-01/key}/client.go | 12 +- .../mixedreality/2025-01-01/key/constants.go | 18 + .../key/id_remoterenderingaccount.go | 130 ++++++ .../key/id_remoterenderingaccount_test.go} | 92 ++--- ...method_remoterenderingaccountslistkeys.go} | 14 +- ...d_remoterenderingaccountsregeneratekeys.go | 58 +++ .../key/model_accountkeyregeneraterequest.go} | 6 +- .../2025-01-01/key/model_accountkeys.go | 9 + .../2025-01-01/key}/version.go | 6 +- .../mixedreality/2025-01-01/proxy/README.md | 59 +++ .../2025-01-01/proxy}/client.go | 12 +- .../2025-01-01/proxy/constants.go | 98 +++++ .../2025-01-01/proxy/id_location.go | 121 ++++++ .../2025-01-01/proxy/id_location_test.go | 237 +++++++++++ .../method_checknameavailabilitylocal.go | 58 +++ ...moterenderingaccountslistbysubscription.go | 106 +++++ .../model_checknameavailabilityrequest.go} | 7 +- .../model_checknameavailabilityresponse.go | 10 + .../model_mixedrealityaccountproperties.go | 10 + .../proxy/model_remoterenderingaccount.go | 23 ++ .../2025-01-01/proxy/model_sku.go | 12 + .../2025-01-01/proxy/predicates.go | 32 ++ .../2025-01-01/proxy}/version.go | 6 +- .../2025-01-01/resource/README.md | 129 ++++++ .../2025-01-01/resource}/client.go | 12 +- .../2025-01-01/resource/constants.go | 57 +++ .../resource/id_remoterenderingaccount.go | 130 ++++++ .../id_remoterenderingaccount_test.go} | 92 ++--- .../method_remoterenderingaccountscreate.go | 58 +++ .../method_remoterenderingaccountsdelete.go | 47 +++ .../method_remoterenderingaccountsget.go | 53 +++ ...oterenderingaccountslistbyresourcegroup.go | 106 +++++ ...moterenderingaccountslistbysubscription.go | 106 +++++ .../method_remoterenderingaccountsupdate.go | 57 +++ .../model_mixedrealityaccountproperties.go | 10 + .../resource/model_remoterenderingaccount.go | 23 ++ .../2025-01-01/resource/model_sku.go | 12 + .../2025-01-01/resource/predicates.go | 32 ++ .../2025-01-01/resource}/version.go | 6 +- .../constants.go | 6 + .../constants.go | 6 + .../constants.go | 6 + .../constants.go | 6 + .../2024-08-01/replicas/model_server.go | 18 +- .../2024-08-01/servers/model_server.go | 18 +- .../servers/model_serverforupdate.go | 8 +- .../resources/2025-03-01/client.go | 73 ++++ .../2025-03-01/policyassignments/README.md | 237 +++++++++++ .../2025-03-01/policyassignments}/client.go | 12 +- .../2025-03-01/policyassignments/constants.go | 189 +++++++++ .../id_policyassignmentid.go | 109 +++++ .../id_policyassignmentid_test.go | 147 +++++++ .../id_scopedpolicyassignment.go | 120 ++++++ .../id_scopedpolicyassignment_test.go | 222 +++++++++++ .../policyassignments/method_create.go | 57 +++ .../policyassignments/method_createbyid.go | 57 +++ .../policyassignments/method_delete.go | 54 +++ .../policyassignments/method_deletebyid.go | 54 +++ .../policyassignments/method_get.go | 83 ++++ .../policyassignments/method_getbyid.go | 53 +++ .../policyassignments/method_list.go | 143 +++++++ .../method_listformanagementgroup.go | 143 +++++++ .../method_listforresource.go | 143 +++++++ .../method_listforresourcegroup.go | 143 +++++++ .../policyassignments}/method_update.go | 8 +- .../policyassignments/method_updatebyid.go | 57 +++ .../model_noncompliancemessage.go | 9 + .../policyassignments/model_override.go | 10 + .../model_parametervaluesvalue.go} | 6 +- .../model_policyassignment.go | 19 + .../model_policyassignmentproperties.go | 23 ++ .../model_policyassignmentupdate.go | 14 + .../model_policyassignmentupdateproperties.go | 9 + .../model_resourceselector.go | 9 + .../policyassignments/model_selector.go | 10 + .../policyassignments/predicates.go | 32 ++ .../2025-03-01/policyassignments}/version.go | 6 +- .../2025-03-01/policydefinitions/README.md | 194 +++++++++ .../2025-03-01/policydefinitions/client.go | 26 ++ .../2025-03-01/policydefinitions/constants.go | 113 ++++++ .../policydefinitions/id_policydefinition.go | 112 ++++++ .../id_policydefinition_test.go | 192 +++++++++ .../id_providerpolicydefinition.go | 121 ++++++ .../id_providerpolicydefinition_test.go | 237 +++++++++++ .../id_providers2policydefinition.go | 123 ++++++ .../id_providers2policydefinition_test.go | 267 +++++++++++++ .../method_createorupdate.go | 10 +- .../method_createorupdateatmanagementgroup.go | 57 +++ .../policydefinitions}/method_delete.go | 5 +- .../method_deleteatmanagementgroup.go | 47 +++ .../policydefinitions}/method_get.go | 8 +- .../method_getatmanagementgroup.go | 53 +++ .../policydefinitions/method_getbuiltin.go | 53 +++ .../policydefinitions/method_list.go | 139 +++++++ .../policydefinitions/method_listbuiltin.go | 138 +++++++ .../method_listbymanagementgroup.go | 139 +++++++ ...odel_externalevaluationendpointsettings.go | 9 + ...l_externalevaluationenforcementsettings.go | 11 + .../model_parameterdefinitionsvalue.go | 12 + ...model_parameterdefinitionsvaluemetadata.go | 11 + .../model_policydefinition.go} | 6 +- .../model_policydefinitionproperties.go | 17 + .../policydefinitions}/predicates.go | 6 +- .../2025-03-01/policydefinitions/version.go | 10 + .../policydefinitionversions/README.md | 245 ++++++++++++ .../policydefinitionversions/client.go | 26 ++ .../policydefinitionversions/constants.go | 113 ++++++ .../id_policydefinition.go | 112 ++++++ .../id_policydefinition_test.go | 192 +++++++++ .../id_policydefinitionversion.go | 130 ++++++ .../id_policydefinitionversion_test.go | 282 +++++++++++++ .../id_providerpolicydefinition.go | 121 ++++++ .../id_providerpolicydefinition_test.go | 237 +++++++++++ .../id_providers2policydefinition.go | 123 ++++++ .../id_providers2policydefinition_test.go | 267 +++++++++++++ .../id_providers2policydefinitionversion.go | 132 +++++++ ..._providers2policydefinitionversion_test.go | 312 +++++++++++++++ .../policydefinitionversions/id_version.go | 121 ++++++ .../id_version_test.go | 237 +++++++++++ .../method_createorupdate.go | 58 +++ .../method_createorupdateatmanagementgroup.go | 58 +++ .../method_delete.go} | 9 +- .../method_deleteatmanagementgroup.go | 47 +++ .../policydefinitionversions}/method_get.go | 8 +- .../method_getatmanagementgroup.go | 53 +++ .../method_getbuiltin.go | 53 +++ .../policydefinitionversions}/method_list.go | 55 ++- .../method_listall.go | 106 +++++ .../method_listallatmanagementgroup.go | 106 +++++ .../method_listallbuiltins.go} | 40 +- .../method_listbuiltin.go | 134 +++++++ .../method_listbymanagementgroup.go | 134 +++++++ ...odel_externalevaluationendpointsettings.go | 9 + ...l_externalevaluationenforcementsettings.go | 11 + .../model_parameterdefinitionsvalue.go | 12 + ...model_parameterdefinitionsvaluemetadata.go | 11 + .../model_policydefinitionversion.go | 16 + ...model_policydefinitionversionproperties.go | 16 + .../policydefinitionversions/predicates.go | 27 ++ .../policydefinitionversions/version.go | 10 + .../2025-03-01/policysetdefinitions/README.md | 194 +++++++++ .../2025-03-01/policysetdefinitions/client.go | 26 ++ .../policysetdefinitions/constants.go | 113 ++++++ .../id_policysetdefinition.go | 112 ++++++ .../id_policysetdefinition_test.go | 192 +++++++++ .../id_providerpolicysetdefinition.go | 121 ++++++ .../id_providerpolicysetdefinition_test.go | 237 +++++++++++ .../id_providers2policysetdefinition.go | 123 ++++++ .../id_providers2policysetdefinition_test.go | 267 +++++++++++++ .../method_createorupdate.go} | 13 +- .../method_createorupdateatmanagementgroup.go | 58 +++ .../policysetdefinitions/method_delete.go | 47 +++ .../method_deleteatmanagementgroup.go | 47 +++ .../policysetdefinitions/method_get.go | 83 ++++ .../method_getatmanagementgroup.go | 83 ++++ .../policysetdefinitions/method_getbuiltin.go | 83 ++++ .../policysetdefinitions/method_list.go | 143 +++++++ .../method_listbuiltin.go | 142 +++++++ .../method_listbymanagementgroup.go | 143 +++++++ .../model_parameterdefinitionsvalue.go | 12 + ...model_parameterdefinitionsvaluemetadata.go | 11 + .../model_parametervaluesvalue.go | 8 + .../model_policydefinitiongroup.go | 12 + .../model_policydefinitionreference.go | 14 + .../model_policysetdefinition.go | 16 + .../model_policysetdefinitionproperties.go | 16 + .../policysetdefinitions}/predicates.go | 6 +- .../policysetdefinitions/version.go | 10 + .../policysetdefinitionversions/README.md | 245 ++++++++++++ .../policysetdefinitionversions/client.go | 26 ++ .../policysetdefinitionversions/constants.go | 113 ++++++ .../id_policysetdefinition.go | 112 ++++++ .../id_policysetdefinition_test.go | 192 +++++++++ .../id_policysetdefinitionversion.go | 121 ++++++ .../id_policysetdefinitionversion_test.go | 237 +++++++++++ .../id_providerpolicysetdefinition.go | 121 ++++++ .../id_providerpolicysetdefinition_test.go | 237 +++++++++++ .../id_providerpolicysetdefinitionversion.go | 130 ++++++ ...providerpolicysetdefinitionversion_test.go | 282 +++++++++++++ .../id_providers2policysetdefinition.go | 123 ++++++ .../id_providers2policysetdefinition_test.go | 267 +++++++++++++ ...id_providers2policysetdefinitionversion.go | 132 +++++++ ...oviders2policysetdefinitionversion_test.go | 312 +++++++++++++++ .../method_createorupdate.go | 58 +++ .../method_createorupdateatmanagementgroup.go | 58 +++ .../method_delete.go | 47 +++ .../method_deleteatmanagementgroup.go | 47 +++ .../policysetdefinitionversions/method_get.go | 83 ++++ .../method_getatmanagementgroup.go | 83 ++++ .../method_getbuiltin.go | 83 ++++ .../method_list.go | 138 +++++++ .../method_listall.go | 106 +++++ .../method_listallatmanagementgroup.go | 106 +++++ .../method_listallbuiltins.go | 105 +++++ .../method_listbuiltin.go | 138 +++++++ .../method_listbymanagementgroup.go | 138 +++++++ .../model_parameterdefinitionsvalue.go | 12 + ...model_parameterdefinitionsvaluemetadata.go | 11 + .../model_parametervaluesvalue.go | 8 + .../model_policydefinitiongroup.go | 12 + .../model_policydefinitionreference.go | 14 + .../model_policysetdefinitionversion.go | 16 + ...el_policysetdefinitionversionproperties.go | 15 + .../policysetdefinitionversions/predicates.go | 27 ++ .../policysetdefinitionversions/version.go | 10 + .../2025-03-01/policytokens/README.md | 38 ++ .../2025-03-01/policytokens}/client.go | 12 +- .../2025-03-01/policytokens/constants.go | 92 +++++ .../policytokens/method_acquire.go} | 27 +- ...ernalevaluationendpointinvocationresult.go | 43 ++ .../policytokens/model_policyloginfo.go | 28 ++ .../model_policytokenoperation.go | 10 + .../policytokens/model_policytokenrequest.go | 9 + .../policytokens/model_policytokenresponse.go | 45 +++ .../2025-03-01/policytokens}/version.go | 6 +- .../standbypool/2025-03-01/client.go | 64 +++ .../README.md | 53 +++ .../client.go | 26 ++ .../constants.go | 142 +++++++ .../id_runtimeview.go | 139 +++++++ .../id_runtimeview_test.go} | 110 +++--- .../id_standbycontainergrouppool.go | 130 ++++++ .../id_standbycontainergrouppool_test.go | 282 +++++++++++++ .../method_get.go | 53 +++ .../method_listbystandbypool.go | 105 +++++ ...odel_containergroupinstancecountsummary.go | 9 + .../model_poolcontainergroupstatecount.go | 9 + .../model_poolstatus.go | 9 + ...standbycontainergrouppoolforecastvalues.go | 8 + ...del_standbycontainergrouppoolprediction.go | 25 ++ ...bycontainergrouppoolruntimeviewresource.go | 16 + ...rgrouppoolruntimeviewresourceproperties.go | 11 + .../predicates.go | 27 ++ .../version.go | 10 + .../standbycontainergrouppools/README.md | 121 ++++++ .../standbycontainergrouppools/client.go | 26 ++ .../standbycontainergrouppools/constants.go | 95 +++++ .../id_standbycontainergrouppool.go | 130 ++++++ .../id_standbycontainergrouppool_test.go} | 92 ++--- .../method_createorupdate.go | 8 +- .../method_delete.go | 7 +- .../standbycontainergrouppools}/method_get.go | 8 +- .../method_listbyresourcegroup.go | 20 +- .../method_listbysubscription.go | 20 +- .../method_update.go | 8 +- .../model_containergroupprofile.go | 9 + .../model_containergroupproperties.go | 9 + ...ndbycontainergrouppoolelasticityprofile.go | 9 + ...model_standbycontainergrouppoolresource.go | 18 + ...dbycontainergrouppoolresourceproperties.go | 15 + ...standbycontainergrouppoolresourceupdate.go | 9 + ...tainergrouppoolresourceupdateproperties.go | 14 + .../model_subnet.go} | 6 +- .../standbycontainergrouppools/predicates.go | 32 ++ .../standbycontainergrouppools/version.go | 10 + .../README.md | 53 +++ .../client.go | 26 ++ .../constants.go | 157 ++++++++ .../id_standbyvirtualmachinepool.go | 130 ++++++ .../id_standbyvirtualmachinepool_test.go | 282 +++++++++++++ ...id_standbyvirtualmachinepoolruntimeview.go | 139 +++++++ ...ndbyvirtualmachinepoolruntimeview_test.go} | 122 +++--- .../method_get.go | 53 +++ .../method_listbystandbypool.go | 105 +++++ .../model_poolstatus.go | 9 + .../model_poolvirtualmachinestatecount.go | 9 + ...standbyvirtualmachinepoolforecastvalues.go | 8 + ...del_standbyvirtualmachinepoolprediction.go | 25 ++ ...byvirtualmachinepoolruntimeviewresource.go | 16 + ...achinepoolruntimeviewresourceproperties.go | 11 + ...odel_virtualmachineinstancecountsummary.go | 9 + .../predicates.go | 27 ++ .../version.go | 10 + .../standbyvirtualmachinepools/README.md | 121 ++++++ .../standbyvirtualmachinepools/client.go | 26 ++ .../standbyvirtualmachinepools/constants.go | 101 +++++ .../id_standbyvirtualmachinepool.go | 130 ++++++ .../id_standbyvirtualmachinepool_test.go | 282 +++++++++++++ .../method_createorupdate.go} | 20 +- .../method_delete.go | 7 +- .../standbyvirtualmachinepools/method_get.go | 53 +++ .../method_listbyresourcegroup.go | 106 +++++ .../method_listbysubscription.go | 106 +++++ .../method_update.go | 57 +++ ...ndbyvirtualmachinepoolelasticityprofile.go | 9 + ...model_standbyvirtualmachinepoolresource.go | 18 + ...dbyvirtualmachinepoolresourceproperties.go | 11 + ...standbyvirtualmachinepoolresourceupdate.go | 9 + ...tualmachinepoolresourceupdateproperties.go | 10 + .../standbyvirtualmachinepools/predicates.go | 32 ++ .../standbyvirtualmachinepools/version.go | 10 + .../standbyvirtualmachines/README.md | 53 +++ .../standbyvirtualmachines/client.go | 26 ++ .../standbyvirtualmachines/constants.go | 57 +++ .../id_standbyvirtualmachine.go | 139 +++++++ .../id_standbyvirtualmachine_test.go} | 122 +++--- .../id_standbyvirtualmachinepool.go | 130 ++++++ .../id_standbyvirtualmachinepool_test.go} | 92 ++--- .../standbyvirtualmachines}/method_get.go | 8 +- ...listbystandbyvirtualmachinepoolresource.go | 105 +++++ .../model_standbyvirtualmachineresource.go | 16 + ...standbyvirtualmachineresourceproperties.go | 9 + .../standbyvirtualmachines/predicates.go | 27 ++ .../standbyvirtualmachines/version.go | 10 + .../fileshares/model_fileshareproperties.go | 36 -- 376 files changed, 21247 insertions(+), 6472 deletions(-) delete mode 100644 resource-manager/logz/2020-10-01/client.go delete mode 100644 resource-manager/logz/2020-10-01/monitors/README.md delete mode 100644 resource-manager/logz/2020-10-01/monitors/constants.go delete mode 100644 resource-manager/logz/2020-10-01/monitors/id_monitor.go delete mode 100644 resource-manager/logz/2020-10-01/monitors/method_listmonitoredresources.go delete mode 100644 resource-manager/logz/2020-10-01/monitors/method_listuserroles.go delete mode 100644 resource-manager/logz/2020-10-01/monitors/model_identityproperties.go delete mode 100644 resource-manager/logz/2020-10-01/monitors/model_logzmonitorresource.go delete mode 100644 resource-manager/logz/2020-10-01/monitors/model_logzmonitorresourceupdateparameters.go delete mode 100644 resource-manager/logz/2020-10-01/monitors/model_logzorganizationproperties.go delete mode 100644 resource-manager/logz/2020-10-01/monitors/model_monitoredresource.go delete mode 100644 resource-manager/logz/2020-10-01/monitors/model_monitorproperties.go delete mode 100644 resource-manager/logz/2020-10-01/monitors/model_plandata.go delete mode 100644 resource-manager/logz/2020-10-01/monitors/model_userinfo.go delete mode 100644 resource-manager/logz/2020-10-01/monitors/predicates.go delete mode 100644 resource-manager/logz/2020-10-01/singlesignon/README.md delete mode 100644 resource-manager/logz/2020-10-01/singlesignon/constants.go delete mode 100644 resource-manager/logz/2020-10-01/singlesignon/id_monitor.go delete mode 100644 resource-manager/logz/2020-10-01/singlesignon/id_singlesignonconfiguration.go delete mode 100644 resource-manager/logz/2020-10-01/singlesignon/model_logzsinglesignonproperties.go delete mode 100644 resource-manager/logz/2020-10-01/subaccount/README.md delete mode 100644 resource-manager/logz/2020-10-01/subaccount/constants.go delete mode 100644 resource-manager/logz/2020-10-01/subaccount/id_account.go delete mode 100644 resource-manager/logz/2020-10-01/subaccount/id_account_test.go delete mode 100644 resource-manager/logz/2020-10-01/subaccount/id_monitor.go delete mode 100644 resource-manager/logz/2020-10-01/subaccount/method_list.go delete mode 100644 resource-manager/logz/2020-10-01/subaccount/method_listmonitoredresources.go delete mode 100644 resource-manager/logz/2020-10-01/subaccount/model_identityproperties.go delete mode 100644 resource-manager/logz/2020-10-01/subaccount/model_logzmonitorresource.go delete mode 100644 resource-manager/logz/2020-10-01/subaccount/model_logzmonitorresourceupdateparameters.go delete mode 100644 resource-manager/logz/2020-10-01/subaccount/model_logzorganizationproperties.go delete mode 100644 resource-manager/logz/2020-10-01/subaccount/model_monitoredresource.go delete mode 100644 resource-manager/logz/2020-10-01/subaccount/model_monitorproperties.go delete mode 100644 resource-manager/logz/2020-10-01/subaccount/model_plandata.go delete mode 100644 resource-manager/logz/2020-10-01/subaccount/model_userinfo.go delete mode 100644 resource-manager/logz/2020-10-01/subaccount/predicates.go delete mode 100644 resource-manager/logz/2020-10-01/tagrules/README.md delete mode 100644 resource-manager/logz/2020-10-01/tagrules/constants.go delete mode 100644 resource-manager/logz/2020-10-01/tagrules/id_account.go delete mode 100644 resource-manager/logz/2020-10-01/tagrules/id_accounttagrule.go delete mode 100644 resource-manager/logz/2020-10-01/tagrules/id_accounttagrule_test.go delete mode 100644 resource-manager/logz/2020-10-01/tagrules/id_monitor.go delete mode 100644 resource-manager/logz/2020-10-01/tagrules/id_tagrule.go delete mode 100644 resource-manager/logz/2020-10-01/tagrules/method_list.go delete mode 100644 resource-manager/logz/2020-10-01/tagrules/method_subaccounttagrulesget.go delete mode 100644 resource-manager/logz/2020-10-01/tagrules/method_subaccounttagruleslist.go delete mode 100644 resource-manager/logz/2020-10-01/tagrules/model_filteringtag.go delete mode 100644 resource-manager/logz/2020-10-01/tagrules/model_logrules.go delete mode 100644 resource-manager/logz/2020-10-01/tagrules/model_monitoringtagrules.go delete mode 100644 resource-manager/logz/2020-10-01/tagrules/model_monitoringtagrulesproperties.go delete mode 100644 resource-manager/logz/2020-10-01/vmhost/README.md delete mode 100644 resource-manager/logz/2020-10-01/vmhost/constants.go delete mode 100644 resource-manager/logz/2020-10-01/vmhost/id_account.go delete mode 100644 resource-manager/logz/2020-10-01/vmhost/id_account_test.go delete mode 100644 resource-manager/logz/2020-10-01/vmhost/id_monitor.go delete mode 100644 resource-manager/logz/2020-10-01/vmhost/id_monitor_test.go delete mode 100644 resource-manager/logz/2020-10-01/vmhost/method_monitorlistvmhosts.go delete mode 100644 resource-manager/logz/2020-10-01/vmhost/method_monitorlistvmhostupdate.go delete mode 100644 resource-manager/logz/2020-10-01/vmhost/method_subaccountlistvmhostupdate.go delete mode 100644 resource-manager/logz/2020-10-01/vmhost/method_subaccountvmhostpayload.go delete mode 100644 resource-manager/logz/2020-10-01/vmhost/model_vmextensionpayload.go delete mode 100644 resource-manager/logz/2020-10-01/vmhost/model_vmhostupdaterequest.go delete mode 100644 resource-manager/logz/2020-10-01/vmhost/model_vmresources.go delete mode 100644 resource-manager/logz/2020-10-01/vmhost/predicates.go create mode 100644 resource-manager/mixedreality/2025-01-01/client.go create mode 100644 resource-manager/mixedreality/2025-01-01/key/README.md rename resource-manager/{logz/2020-10-01/vmhost => mixedreality/2025-01-01/key}/client.go (57%) create mode 100644 resource-manager/mixedreality/2025-01-01/key/constants.go create mode 100644 resource-manager/mixedreality/2025-01-01/key/id_remoterenderingaccount.go rename resource-manager/{logz/2020-10-01/monitors/id_monitor_test.go => mixedreality/2025-01-01/key/id_remoterenderingaccount_test.go} (62%) rename resource-manager/{logz/2020-10-01/vmhost/method_monitorvmhostpayload.go => mixedreality/2025-01-01/key/method_remoterenderingaccountslistkeys.go} (69%) create mode 100644 resource-manager/mixedreality/2025-01-01/key/method_remoterenderingaccountsregeneratekeys.go rename resource-manager/{logz/2020-10-01/monitors/model_userrolerequest.go => mixedreality/2025-01-01/key/model_accountkeyregeneraterequest.go} (61%) create mode 100644 resource-manager/mixedreality/2025-01-01/key/model_accountkeys.go rename resource-manager/{logz/2020-10-01/vmhost => mixedreality/2025-01-01/key}/version.go (64%) create mode 100644 resource-manager/mixedreality/2025-01-01/proxy/README.md rename resource-manager/{logz/2020-10-01/monitors => mixedreality/2025-01-01/proxy}/client.go (56%) create mode 100644 resource-manager/mixedreality/2025-01-01/proxy/constants.go create mode 100644 resource-manager/mixedreality/2025-01-01/proxy/id_location.go create mode 100644 resource-manager/mixedreality/2025-01-01/proxy/id_location_test.go create mode 100644 resource-manager/mixedreality/2025-01-01/proxy/method_checknameavailabilitylocal.go create mode 100644 resource-manager/mixedreality/2025-01-01/proxy/method_remoterenderingaccountslistbysubscription.go rename resource-manager/{logz/2020-10-01/monitors/model_monitorupdateproperties.go => mixedreality/2025-01-01/proxy/model_checknameavailabilityrequest.go} (55%) create mode 100644 resource-manager/mixedreality/2025-01-01/proxy/model_checknameavailabilityresponse.go create mode 100644 resource-manager/mixedreality/2025-01-01/proxy/model_mixedrealityaccountproperties.go create mode 100644 resource-manager/mixedreality/2025-01-01/proxy/model_remoterenderingaccount.go create mode 100644 resource-manager/mixedreality/2025-01-01/proxy/model_sku.go create mode 100644 resource-manager/mixedreality/2025-01-01/proxy/predicates.go rename resource-manager/{logz/2020-10-01/monitors => mixedreality/2025-01-01/proxy}/version.go (63%) create mode 100644 resource-manager/mixedreality/2025-01-01/resource/README.md rename resource-manager/{logz/2020-10-01/tagrules => mixedreality/2025-01-01/resource}/client.go (61%) create mode 100644 resource-manager/mixedreality/2025-01-01/resource/constants.go create mode 100644 resource-manager/mixedreality/2025-01-01/resource/id_remoterenderingaccount.go rename resource-manager/{logz/2020-10-01/singlesignon/id_monitor_test.go => mixedreality/2025-01-01/resource/id_remoterenderingaccount_test.go} (62%) create mode 100644 resource-manager/mixedreality/2025-01-01/resource/method_remoterenderingaccountscreate.go create mode 100644 resource-manager/mixedreality/2025-01-01/resource/method_remoterenderingaccountsdelete.go create mode 100644 resource-manager/mixedreality/2025-01-01/resource/method_remoterenderingaccountsget.go create mode 100644 resource-manager/mixedreality/2025-01-01/resource/method_remoterenderingaccountslistbyresourcegroup.go create mode 100644 resource-manager/mixedreality/2025-01-01/resource/method_remoterenderingaccountslistbysubscription.go create mode 100644 resource-manager/mixedreality/2025-01-01/resource/method_remoterenderingaccountsupdate.go create mode 100644 resource-manager/mixedreality/2025-01-01/resource/model_mixedrealityaccountproperties.go create mode 100644 resource-manager/mixedreality/2025-01-01/resource/model_remoterenderingaccount.go create mode 100644 resource-manager/mixedreality/2025-01-01/resource/model_sku.go create mode 100644 resource-manager/mixedreality/2025-01-01/resource/predicates.go rename resource-manager/{logz/2020-10-01/tagrules => mixedreality/2025-01-01/resource}/version.go (63%) create mode 100644 resource-manager/resources/2025-03-01/client.go create mode 100644 resource-manager/resources/2025-03-01/policyassignments/README.md rename resource-manager/{logz/2020-10-01/subaccount => resources/2025-03-01/policyassignments}/client.go (51%) create mode 100644 resource-manager/resources/2025-03-01/policyassignments/constants.go create mode 100644 resource-manager/resources/2025-03-01/policyassignments/id_policyassignmentid.go create mode 100644 resource-manager/resources/2025-03-01/policyassignments/id_policyassignmentid_test.go create mode 100644 resource-manager/resources/2025-03-01/policyassignments/id_scopedpolicyassignment.go create mode 100644 resource-manager/resources/2025-03-01/policyassignments/id_scopedpolicyassignment_test.go create mode 100644 resource-manager/resources/2025-03-01/policyassignments/method_create.go create mode 100644 resource-manager/resources/2025-03-01/policyassignments/method_createbyid.go create mode 100644 resource-manager/resources/2025-03-01/policyassignments/method_delete.go create mode 100644 resource-manager/resources/2025-03-01/policyassignments/method_deletebyid.go create mode 100644 resource-manager/resources/2025-03-01/policyassignments/method_get.go create mode 100644 resource-manager/resources/2025-03-01/policyassignments/method_getbyid.go create mode 100644 resource-manager/resources/2025-03-01/policyassignments/method_list.go create mode 100644 resource-manager/resources/2025-03-01/policyassignments/method_listformanagementgroup.go create mode 100644 resource-manager/resources/2025-03-01/policyassignments/method_listforresource.go create mode 100644 resource-manager/resources/2025-03-01/policyassignments/method_listforresourcegroup.go rename resource-manager/{logz/2020-10-01/subaccount => resources/2025-03-01/policyassignments}/method_update.go (79%) create mode 100644 resource-manager/resources/2025-03-01/policyassignments/method_updatebyid.go create mode 100644 resource-manager/resources/2025-03-01/policyassignments/model_noncompliancemessage.go create mode 100644 resource-manager/resources/2025-03-01/policyassignments/model_override.go rename resource-manager/{logz/2020-10-01/subaccount/model_monitorupdateproperties.go => resources/2025-03-01/policyassignments/model_parametervaluesvalue.go} (55%) create mode 100644 resource-manager/resources/2025-03-01/policyassignments/model_policyassignment.go create mode 100644 resource-manager/resources/2025-03-01/policyassignments/model_policyassignmentproperties.go create mode 100644 resource-manager/resources/2025-03-01/policyassignments/model_policyassignmentupdate.go create mode 100644 resource-manager/resources/2025-03-01/policyassignments/model_policyassignmentupdateproperties.go create mode 100644 resource-manager/resources/2025-03-01/policyassignments/model_resourceselector.go create mode 100644 resource-manager/resources/2025-03-01/policyassignments/model_selector.go create mode 100644 resource-manager/resources/2025-03-01/policyassignments/predicates.go rename resource-manager/{logz/2020-10-01/subaccount => resources/2025-03-01/policyassignments}/version.go (59%) create mode 100644 resource-manager/resources/2025-03-01/policydefinitions/README.md create mode 100644 resource-manager/resources/2025-03-01/policydefinitions/client.go create mode 100644 resource-manager/resources/2025-03-01/policydefinitions/constants.go create mode 100644 resource-manager/resources/2025-03-01/policydefinitions/id_policydefinition.go create mode 100644 resource-manager/resources/2025-03-01/policydefinitions/id_policydefinition_test.go create mode 100644 resource-manager/resources/2025-03-01/policydefinitions/id_providerpolicydefinition.go create mode 100644 resource-manager/resources/2025-03-01/policydefinitions/id_providerpolicydefinition_test.go create mode 100644 resource-manager/resources/2025-03-01/policydefinitions/id_providers2policydefinition.go create mode 100644 resource-manager/resources/2025-03-01/policydefinitions/id_providers2policydefinition_test.go rename resource-manager/{logz/2020-10-01/tagrules => resources/2025-03-01/policydefinitions}/method_createorupdate.go (77%) create mode 100644 resource-manager/resources/2025-03-01/policydefinitions/method_createorupdateatmanagementgroup.go rename resource-manager/{logz/2020-10-01/tagrules => resources/2025-03-01/policydefinitions}/method_delete.go (84%) create mode 100644 resource-manager/resources/2025-03-01/policydefinitions/method_deleteatmanagementgroup.go rename resource-manager/{logz/2020-10-01/monitors => resources/2025-03-01/policydefinitions}/method_get.go (81%) create mode 100644 resource-manager/resources/2025-03-01/policydefinitions/method_getatmanagementgroup.go create mode 100644 resource-manager/resources/2025-03-01/policydefinitions/method_getbuiltin.go create mode 100644 resource-manager/resources/2025-03-01/policydefinitions/method_list.go create mode 100644 resource-manager/resources/2025-03-01/policydefinitions/method_listbuiltin.go create mode 100644 resource-manager/resources/2025-03-01/policydefinitions/method_listbymanagementgroup.go create mode 100644 resource-manager/resources/2025-03-01/policydefinitions/model_externalevaluationendpointsettings.go create mode 100644 resource-manager/resources/2025-03-01/policydefinitions/model_externalevaluationenforcementsettings.go create mode 100644 resource-manager/resources/2025-03-01/policydefinitions/model_parameterdefinitionsvalue.go create mode 100644 resource-manager/resources/2025-03-01/policydefinitions/model_parameterdefinitionsvaluemetadata.go rename resource-manager/{logz/2020-10-01/singlesignon/model_logzsinglesignonresource.go => resources/2025-03-01/policydefinitions/model_policydefinition.go} (80%) create mode 100644 resource-manager/resources/2025-03-01/policydefinitions/model_policydefinitionproperties.go rename resource-manager/{logz/2020-10-01/tagrules => resources/2025-03-01/policydefinitions}/predicates.go (75%) create mode 100644 resource-manager/resources/2025-03-01/policydefinitions/version.go create mode 100644 resource-manager/resources/2025-03-01/policydefinitionversions/README.md create mode 100644 resource-manager/resources/2025-03-01/policydefinitionversions/client.go create mode 100644 resource-manager/resources/2025-03-01/policydefinitionversions/constants.go create mode 100644 resource-manager/resources/2025-03-01/policydefinitionversions/id_policydefinition.go create mode 100644 resource-manager/resources/2025-03-01/policydefinitionversions/id_policydefinition_test.go create mode 100644 resource-manager/resources/2025-03-01/policydefinitionversions/id_policydefinitionversion.go create mode 100644 resource-manager/resources/2025-03-01/policydefinitionversions/id_policydefinitionversion_test.go create mode 100644 resource-manager/resources/2025-03-01/policydefinitionversions/id_providerpolicydefinition.go create mode 100644 resource-manager/resources/2025-03-01/policydefinitionversions/id_providerpolicydefinition_test.go create mode 100644 resource-manager/resources/2025-03-01/policydefinitionversions/id_providers2policydefinition.go create mode 100644 resource-manager/resources/2025-03-01/policydefinitionversions/id_providers2policydefinition_test.go create mode 100644 resource-manager/resources/2025-03-01/policydefinitionversions/id_providers2policydefinitionversion.go create mode 100644 resource-manager/resources/2025-03-01/policydefinitionversions/id_providers2policydefinitionversion_test.go create mode 100644 resource-manager/resources/2025-03-01/policydefinitionversions/id_version.go create mode 100644 resource-manager/resources/2025-03-01/policydefinitionversions/id_version_test.go create mode 100644 resource-manager/resources/2025-03-01/policydefinitionversions/method_createorupdate.go create mode 100644 resource-manager/resources/2025-03-01/policydefinitionversions/method_createorupdateatmanagementgroup.go rename resource-manager/{logz/2020-10-01/tagrules/method_subaccounttagrulesdelete.go => resources/2025-03-01/policydefinitionversions/method_delete.go} (74%) create mode 100644 resource-manager/resources/2025-03-01/policydefinitionversions/method_deleteatmanagementgroup.go rename resource-manager/{logz/2020-10-01/singlesignon => resources/2025-03-01/policydefinitionversions}/method_get.go (79%) create mode 100644 resource-manager/resources/2025-03-01/policydefinitionversions/method_getatmanagementgroup.go create mode 100644 resource-manager/resources/2025-03-01/policydefinitionversions/method_getbuiltin.go rename resource-manager/{logz/2020-10-01/singlesignon => resources/2025-03-01/policydefinitionversions}/method_list.go (51%) create mode 100644 resource-manager/resources/2025-03-01/policydefinitionversions/method_listall.go create mode 100644 resource-manager/resources/2025-03-01/policydefinitionversions/method_listallatmanagementgroup.go rename resource-manager/{logz/2020-10-01/vmhost/method_subaccountlistvmhosts.go => resources/2025-03-01/policydefinitionversions/method_listallbuiltins.go} (50%) create mode 100644 resource-manager/resources/2025-03-01/policydefinitionversions/method_listbuiltin.go create mode 100644 resource-manager/resources/2025-03-01/policydefinitionversions/method_listbymanagementgroup.go create mode 100644 resource-manager/resources/2025-03-01/policydefinitionversions/model_externalevaluationendpointsettings.go create mode 100644 resource-manager/resources/2025-03-01/policydefinitionversions/model_externalevaluationenforcementsettings.go create mode 100644 resource-manager/resources/2025-03-01/policydefinitionversions/model_parameterdefinitionsvalue.go create mode 100644 resource-manager/resources/2025-03-01/policydefinitionversions/model_parameterdefinitionsvaluemetadata.go create mode 100644 resource-manager/resources/2025-03-01/policydefinitionversions/model_policydefinitionversion.go create mode 100644 resource-manager/resources/2025-03-01/policydefinitionversions/model_policydefinitionversionproperties.go create mode 100644 resource-manager/resources/2025-03-01/policydefinitionversions/predicates.go create mode 100644 resource-manager/resources/2025-03-01/policydefinitionversions/version.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitions/README.md create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitions/client.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitions/constants.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitions/id_policysetdefinition.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitions/id_policysetdefinition_test.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitions/id_providerpolicysetdefinition.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitions/id_providerpolicysetdefinition_test.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitions/id_providers2policysetdefinition.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitions/id_providers2policysetdefinition_test.go rename resource-manager/{logz/2020-10-01/tagrules/method_subaccounttagrulescreateorupdate.go => resources/2025-03-01/policysetdefinitions/method_createorupdate.go} (71%) create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitions/method_createorupdateatmanagementgroup.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitions/method_delete.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitions/method_deleteatmanagementgroup.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitions/method_get.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitions/method_getatmanagementgroup.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitions/method_getbuiltin.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitions/method_list.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitions/method_listbuiltin.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitions/method_listbymanagementgroup.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitions/model_parameterdefinitionsvalue.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitions/model_parameterdefinitionsvaluemetadata.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitions/model_parametervaluesvalue.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitions/model_policydefinitiongroup.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitions/model_policydefinitionreference.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitions/model_policysetdefinition.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitions/model_policysetdefinitionproperties.go rename resource-manager/{logz/2020-10-01/singlesignon => resources/2025-03-01/policysetdefinitions}/predicates.go (72%) create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitions/version.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitionversions/README.md create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitionversions/client.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitionversions/constants.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitionversions/id_policysetdefinition.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitionversions/id_policysetdefinition_test.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitionversions/id_policysetdefinitionversion.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitionversions/id_policysetdefinitionversion_test.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitionversions/id_providerpolicysetdefinition.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitionversions/id_providerpolicysetdefinition_test.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitionversions/id_providerpolicysetdefinitionversion.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitionversions/id_providerpolicysetdefinitionversion_test.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitionversions/id_providers2policysetdefinition.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitionversions/id_providers2policysetdefinition_test.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitionversions/id_providers2policysetdefinitionversion.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitionversions/id_providers2policysetdefinitionversion_test.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitionversions/method_createorupdate.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitionversions/method_createorupdateatmanagementgroup.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitionversions/method_delete.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitionversions/method_deleteatmanagementgroup.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitionversions/method_get.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitionversions/method_getatmanagementgroup.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitionversions/method_getbuiltin.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitionversions/method_list.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitionversions/method_listall.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitionversions/method_listallatmanagementgroup.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitionversions/method_listallbuiltins.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitionversions/method_listbuiltin.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitionversions/method_listbymanagementgroup.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitionversions/model_parameterdefinitionsvalue.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitionversions/model_parameterdefinitionsvaluemetadata.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitionversions/model_parametervaluesvalue.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitionversions/model_policydefinitiongroup.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitionversions/model_policydefinitionreference.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitionversions/model_policysetdefinitionversion.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitionversions/model_policysetdefinitionversionproperties.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitionversions/predicates.go create mode 100644 resource-manager/resources/2025-03-01/policysetdefinitionversions/version.go create mode 100644 resource-manager/resources/2025-03-01/policytokens/README.md rename resource-manager/{logz/2020-10-01/singlesignon => resources/2025-03-01/policytokens}/client.go (58%) create mode 100644 resource-manager/resources/2025-03-01/policytokens/constants.go rename resource-manager/{logz/2020-10-01/monitors/method_create.go => resources/2025-03-01/policytokens/method_acquire.go} (58%) create mode 100644 resource-manager/resources/2025-03-01/policytokens/model_externalevaluationendpointinvocationresult.go create mode 100644 resource-manager/resources/2025-03-01/policytokens/model_policyloginfo.go create mode 100644 resource-manager/resources/2025-03-01/policytokens/model_policytokenoperation.go create mode 100644 resource-manager/resources/2025-03-01/policytokens/model_policytokenrequest.go create mode 100644 resource-manager/resources/2025-03-01/policytokens/model_policytokenresponse.go rename resource-manager/{logz/2020-10-01/singlesignon => resources/2025-03-01/policytokens}/version.go (61%) create mode 100644 resource-manager/standbypool/2025-03-01/client.go create mode 100644 resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/README.md create mode 100644 resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/client.go create mode 100644 resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/constants.go create mode 100644 resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/id_runtimeview.go rename resource-manager/{logz/2020-10-01/singlesignon/id_singlesignonconfiguration_test.go => standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/id_runtimeview_test.go} (59%) create mode 100644 resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/id_standbycontainergrouppool.go create mode 100644 resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/id_standbycontainergrouppool_test.go create mode 100644 resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/method_get.go create mode 100644 resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/method_listbystandbypool.go create mode 100644 resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/model_containergroupinstancecountsummary.go create mode 100644 resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/model_poolcontainergroupstatecount.go create mode 100644 resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/model_poolstatus.go create mode 100644 resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/model_standbycontainergrouppoolforecastvalues.go create mode 100644 resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/model_standbycontainergrouppoolprediction.go create mode 100644 resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/model_standbycontainergrouppoolruntimeviewresource.go create mode 100644 resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/model_standbycontainergrouppoolruntimeviewresourceproperties.go create mode 100644 resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/predicates.go create mode 100644 resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/version.go create mode 100644 resource-manager/standbypool/2025-03-01/standbycontainergrouppools/README.md create mode 100644 resource-manager/standbypool/2025-03-01/standbycontainergrouppools/client.go create mode 100644 resource-manager/standbypool/2025-03-01/standbycontainergrouppools/constants.go create mode 100644 resource-manager/standbypool/2025-03-01/standbycontainergrouppools/id_standbycontainergrouppool.go rename resource-manager/{logz/2020-10-01/subaccount/id_monitor_test.go => standbypool/2025-03-01/standbycontainergrouppools/id_standbycontainergrouppool_test.go} (61%) rename resource-manager/{logz/2020-10-01/singlesignon => standbypool/2025-03-01/standbycontainergrouppools}/method_createorupdate.go (77%) rename resource-manager/{logz/2020-10-01/monitors => standbypool/2025-03-01/standbycontainergrouppools}/method_delete.go (82%) rename resource-manager/{logz/2020-10-01/subaccount => standbypool/2025-03-01/standbycontainergrouppools}/method_get.go (77%) rename resource-manager/{logz/2020-10-01/monitors => standbypool/2025-03-01/standbycontainergrouppools}/method_listbyresourcegroup.go (67%) rename resource-manager/{logz/2020-10-01/monitors => standbypool/2025-03-01/standbycontainergrouppools}/method_listbysubscription.go (65%) rename resource-manager/{logz/2020-10-01/monitors => standbypool/2025-03-01/standbycontainergrouppools}/method_update.go (75%) create mode 100644 resource-manager/standbypool/2025-03-01/standbycontainergrouppools/model_containergroupprofile.go create mode 100644 resource-manager/standbypool/2025-03-01/standbycontainergrouppools/model_containergroupproperties.go create mode 100644 resource-manager/standbypool/2025-03-01/standbycontainergrouppools/model_standbycontainergrouppoolelasticityprofile.go create mode 100644 resource-manager/standbypool/2025-03-01/standbycontainergrouppools/model_standbycontainergrouppoolresource.go create mode 100644 resource-manager/standbypool/2025-03-01/standbycontainergrouppools/model_standbycontainergrouppoolresourceproperties.go create mode 100644 resource-manager/standbypool/2025-03-01/standbycontainergrouppools/model_standbycontainergrouppoolresourceupdate.go create mode 100644 resource-manager/standbypool/2025-03-01/standbycontainergrouppools/model_standbycontainergrouppoolresourceupdateproperties.go rename resource-manager/{logz/2020-10-01/monitors/model_userroleresponse.go => standbypool/2025-03-01/standbycontainergrouppools/model_subnet.go} (64%) create mode 100644 resource-manager/standbypool/2025-03-01/standbycontainergrouppools/predicates.go create mode 100644 resource-manager/standbypool/2025-03-01/standbycontainergrouppools/version.go create mode 100644 resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/README.md create mode 100644 resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/client.go create mode 100644 resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/constants.go create mode 100644 resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/id_standbyvirtualmachinepool.go create mode 100644 resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/id_standbyvirtualmachinepool_test.go create mode 100644 resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/id_standbyvirtualmachinepoolruntimeview.go rename resource-manager/{logz/2020-10-01/tagrules/id_account_test.go => standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/id_standbyvirtualmachinepoolruntimeview_test.go} (54%) create mode 100644 resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/method_get.go create mode 100644 resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/method_listbystandbypool.go create mode 100644 resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/model_poolstatus.go create mode 100644 resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/model_poolvirtualmachinestatecount.go create mode 100644 resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/model_standbyvirtualmachinepoolforecastvalues.go create mode 100644 resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/model_standbyvirtualmachinepoolprediction.go create mode 100644 resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/model_standbyvirtualmachinepoolruntimeviewresource.go create mode 100644 resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/model_standbyvirtualmachinepoolruntimeviewresourceproperties.go create mode 100644 resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/model_virtualmachineinstancecountsummary.go create mode 100644 resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/predicates.go create mode 100644 resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/version.go create mode 100644 resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/README.md create mode 100644 resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/client.go create mode 100644 resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/constants.go create mode 100644 resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/id_standbyvirtualmachinepool.go create mode 100644 resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/id_standbyvirtualmachinepool_test.go rename resource-manager/{logz/2020-10-01/subaccount/method_create.go => standbypool/2025-03-01/standbyvirtualmachinepools/method_createorupdate.go} (62%) rename resource-manager/{logz/2020-10-01/subaccount => standbypool/2025-03-01/standbyvirtualmachinepools}/method_delete.go (82%) create mode 100644 resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/method_get.go create mode 100644 resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/method_listbyresourcegroup.go create mode 100644 resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/method_listbysubscription.go create mode 100644 resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/method_update.go create mode 100644 resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/model_standbyvirtualmachinepoolelasticityprofile.go create mode 100644 resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/model_standbyvirtualmachinepoolresource.go create mode 100644 resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/model_standbyvirtualmachinepoolresourceproperties.go create mode 100644 resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/model_standbyvirtualmachinepoolresourceupdate.go create mode 100644 resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/model_standbyvirtualmachinepoolresourceupdateproperties.go create mode 100644 resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/predicates.go create mode 100644 resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/version.go create mode 100644 resource-manager/standbypool/2025-03-01/standbyvirtualmachines/README.md create mode 100644 resource-manager/standbypool/2025-03-01/standbyvirtualmachines/client.go create mode 100644 resource-manager/standbypool/2025-03-01/standbyvirtualmachines/constants.go create mode 100644 resource-manager/standbypool/2025-03-01/standbyvirtualmachines/id_standbyvirtualmachine.go rename resource-manager/{logz/2020-10-01/tagrules/id_tagrule_test.go => standbypool/2025-03-01/standbyvirtualmachines/id_standbyvirtualmachine_test.go} (54%) create mode 100644 resource-manager/standbypool/2025-03-01/standbyvirtualmachines/id_standbyvirtualmachinepool.go rename resource-manager/{logz/2020-10-01/tagrules/id_monitor_test.go => standbypool/2025-03-01/standbyvirtualmachines/id_standbyvirtualmachinepool_test.go} (61%) rename resource-manager/{logz/2020-10-01/tagrules => standbypool/2025-03-01/standbyvirtualmachines}/method_get.go (78%) create mode 100644 resource-manager/standbypool/2025-03-01/standbyvirtualmachines/method_listbystandbyvirtualmachinepoolresource.go create mode 100644 resource-manager/standbypool/2025-03-01/standbyvirtualmachines/model_standbyvirtualmachineresource.go create mode 100644 resource-manager/standbypool/2025-03-01/standbyvirtualmachines/model_standbyvirtualmachineresourceproperties.go create mode 100644 resource-manager/standbypool/2025-03-01/standbyvirtualmachines/predicates.go create mode 100644 resource-manager/standbypool/2025-03-01/standbyvirtualmachines/version.go diff --git a/resource-manager/datafactory/2018-06-01/dataflowdebugsession/model_oraclelinkedservicetypeproperties.go b/resource-manager/datafactory/2018-06-01/dataflowdebugsession/model_oraclelinkedservicetypeproperties.go index 805f6f48549..1058956ccbb 100644 --- a/resource-manager/datafactory/2018-06-01/dataflowdebugsession/model_oraclelinkedservicetypeproperties.go +++ b/resource-manager/datafactory/2018-06-01/dataflowdebugsession/model_oraclelinkedservicetypeproperties.go @@ -5,7 +5,7 @@ package dataflowdebugsession type OracleLinkedServiceTypeProperties struct { AuthenticationType *OracleAuthenticationType `json:"authenticationType,omitempty"` - ConnectionString interface{} `json:"connectionString"` + ConnectionString *interface{} `json:"connectionString,omitempty"` CryptoChecksumClient *interface{} `json:"cryptoChecksumClient,omitempty"` CryptoChecksumTypesClient *interface{} `json:"cryptoChecksumTypesClient,omitempty"` EnableBulkLoad *bool `json:"enableBulkLoad,omitempty"` diff --git a/resource-manager/datafactory/2018-06-01/linkedservices/model_oraclelinkedservicetypeproperties.go b/resource-manager/datafactory/2018-06-01/linkedservices/model_oraclelinkedservicetypeproperties.go index 997e92c1290..1cec94fc261 100644 --- a/resource-manager/datafactory/2018-06-01/linkedservices/model_oraclelinkedservicetypeproperties.go +++ b/resource-manager/datafactory/2018-06-01/linkedservices/model_oraclelinkedservicetypeproperties.go @@ -5,7 +5,7 @@ package linkedservices type OracleLinkedServiceTypeProperties struct { AuthenticationType *OracleAuthenticationType `json:"authenticationType,omitempty"` - ConnectionString interface{} `json:"connectionString"` + ConnectionString *interface{} `json:"connectionString,omitempty"` CryptoChecksumClient *interface{} `json:"cryptoChecksumClient,omitempty"` CryptoChecksumTypesClient *interface{} `json:"cryptoChecksumTypesClient,omitempty"` EnableBulkLoad *bool `json:"enableBulkLoad,omitempty"` diff --git a/resource-manager/logz/2020-10-01/client.go b/resource-manager/logz/2020-10-01/client.go deleted file mode 100644 index ae334fea922..00000000000 --- a/resource-manager/logz/2020-10-01/client.go +++ /dev/null @@ -1,64 +0,0 @@ -package v2020_10_01 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -import ( - "fmt" - - "github.com/hashicorp/go-azure-sdk/resource-manager/logz/2020-10-01/monitors" - "github.com/hashicorp/go-azure-sdk/resource-manager/logz/2020-10-01/singlesignon" - "github.com/hashicorp/go-azure-sdk/resource-manager/logz/2020-10-01/subaccount" - "github.com/hashicorp/go-azure-sdk/resource-manager/logz/2020-10-01/tagrules" - "github.com/hashicorp/go-azure-sdk/resource-manager/logz/2020-10-01/vmhost" - "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" - sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" -) - -type Client struct { - Monitors *monitors.MonitorsClient - SingleSignOn *singlesignon.SingleSignOnClient - SubAccount *subaccount.SubAccountClient - TagRules *tagrules.TagRulesClient - VMHost *vmhost.VMHostClient -} - -func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { - monitorsClient, err := monitors.NewMonitorsClientWithBaseURI(sdkApi) - if err != nil { - return nil, fmt.Errorf("building Monitors client: %+v", err) - } - configureFunc(monitorsClient.Client) - - singleSignOnClient, err := singlesignon.NewSingleSignOnClientWithBaseURI(sdkApi) - if err != nil { - return nil, fmt.Errorf("building SingleSignOn client: %+v", err) - } - configureFunc(singleSignOnClient.Client) - - subAccountClient, err := subaccount.NewSubAccountClientWithBaseURI(sdkApi) - if err != nil { - return nil, fmt.Errorf("building SubAccount client: %+v", err) - } - configureFunc(subAccountClient.Client) - - tagRulesClient, err := tagrules.NewTagRulesClientWithBaseURI(sdkApi) - if err != nil { - return nil, fmt.Errorf("building TagRules client: %+v", err) - } - configureFunc(tagRulesClient.Client) - - vMHostClient, err := vmhost.NewVMHostClientWithBaseURI(sdkApi) - if err != nil { - return nil, fmt.Errorf("building VMHost client: %+v", err) - } - configureFunc(vMHostClient.Client) - - return &Client{ - Monitors: monitorsClient, - SingleSignOn: singleSignOnClient, - SubAccount: subAccountClient, - TagRules: tagRulesClient, - VMHost: vMHostClient, - }, nil -} diff --git a/resource-manager/logz/2020-10-01/monitors/README.md b/resource-manager/logz/2020-10-01/monitors/README.md deleted file mode 100644 index 7893fe4ecae..00000000000 --- a/resource-manager/logz/2020-10-01/monitors/README.md +++ /dev/null @@ -1,160 +0,0 @@ - -## `github.com/hashicorp/go-azure-sdk/resource-manager/logz/2020-10-01/monitors` Documentation - -The `monitors` SDK allows for interaction with Azure Resource Manager `logz` (API Version `2020-10-01`). - -This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). - -### Import Path - -```go -import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -import "github.com/hashicorp/go-azure-sdk/resource-manager/logz/2020-10-01/monitors" -``` - - -### Client Initialization - -```go -client := monitors.NewMonitorsClientWithBaseURI("https://management.azure.com") -client.Client.Authorizer = authorizer -``` - - -### Example Usage: `MonitorsClient.Create` - -```go -ctx := context.TODO() -id := monitors.NewMonitorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName") - -payload := monitors.LogzMonitorResource{ - // ... -} - - -if err := client.CreateThenPoll(ctx, id, payload); err != nil { - // handle the error -} -``` - - -### Example Usage: `MonitorsClient.Delete` - -```go -ctx := context.TODO() -id := monitors.NewMonitorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName") - -if err := client.DeleteThenPoll(ctx, id); err != nil { - // handle the error -} -``` - - -### Example Usage: `MonitorsClient.Get` - -```go -ctx := context.TODO() -id := monitors.NewMonitorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName") - -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: `MonitorsClient.ListByResourceGroup` - -```go -ctx := context.TODO() -id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") - -// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination -items, err := client.ListByResourceGroupComplete(ctx, id) -if err != nil { - // handle the error -} -for _, item := range items { - // do something -} -``` - - -### Example Usage: `MonitorsClient.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: `MonitorsClient.ListMonitoredResources` - -```go -ctx := context.TODO() -id := monitors.NewMonitorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName") - -// alternatively `client.ListMonitoredResources(ctx, id)` can be used to do batched pagination -items, err := client.ListMonitoredResourcesComplete(ctx, id) -if err != nil { - // handle the error -} -for _, item := range items { - // do something -} -``` - - -### Example Usage: `MonitorsClient.ListUserRoles` - -```go -ctx := context.TODO() -id := monitors.NewMonitorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName") - -payload := monitors.UserRoleRequest{ - // ... -} - - -// alternatively `client.ListUserRoles(ctx, id, payload)` can be used to do batched pagination -items, err := client.ListUserRolesComplete(ctx, id, payload) -if err != nil { - // handle the error -} -for _, item := range items { - // do something -} -``` - - -### Example Usage: `MonitorsClient.Update` - -```go -ctx := context.TODO() -id := monitors.NewMonitorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName") - -payload := monitors.LogzMonitorResourceUpdateParameters{ - // ... -} - - -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/logz/2020-10-01/monitors/constants.go b/resource-manager/logz/2020-10-01/monitors/constants.go deleted file mode 100644 index c4cd1530ff6..00000000000 --- a/resource-manager/logz/2020-10-01/monitors/constants.go +++ /dev/null @@ -1,280 +0,0 @@ -package monitors - -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 LiftrResourceCategories string - -const ( - LiftrResourceCategoriesMonitorLogs LiftrResourceCategories = "MonitorLogs" - LiftrResourceCategoriesUnknown LiftrResourceCategories = "Unknown" -) - -func PossibleValuesForLiftrResourceCategories() []string { - return []string{ - string(LiftrResourceCategoriesMonitorLogs), - string(LiftrResourceCategoriesUnknown), - } -} - -func (s *LiftrResourceCategories) UnmarshalJSON(bytes []byte) error { - var decoded string - if err := json.Unmarshal(bytes, &decoded); err != nil { - return fmt.Errorf("unmarshaling: %+v", err) - } - out, err := parseLiftrResourceCategories(decoded) - if err != nil { - return fmt.Errorf("parsing %q: %+v", decoded, err) - } - *s = *out - return nil -} - -func parseLiftrResourceCategories(input string) (*LiftrResourceCategories, error) { - vals := map[string]LiftrResourceCategories{ - "monitorlogs": LiftrResourceCategoriesMonitorLogs, - "unknown": LiftrResourceCategoriesUnknown, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := LiftrResourceCategories(input) - return &out, nil -} - -type ManagedIdentityTypes string - -const ( - ManagedIdentityTypesSystemAssigned ManagedIdentityTypes = "SystemAssigned" - ManagedIdentityTypesUserAssigned ManagedIdentityTypes = "UserAssigned" -) - -func PossibleValuesForManagedIdentityTypes() []string { - return []string{ - string(ManagedIdentityTypesSystemAssigned), - string(ManagedIdentityTypesUserAssigned), - } -} - -func (s *ManagedIdentityTypes) UnmarshalJSON(bytes []byte) error { - var decoded string - if err := json.Unmarshal(bytes, &decoded); err != nil { - return fmt.Errorf("unmarshaling: %+v", err) - } - out, err := parseManagedIdentityTypes(decoded) - if err != nil { - return fmt.Errorf("parsing %q: %+v", decoded, err) - } - *s = *out - return nil -} - -func parseManagedIdentityTypes(input string) (*ManagedIdentityTypes, error) { - vals := map[string]ManagedIdentityTypes{ - "systemassigned": ManagedIdentityTypesSystemAssigned, - "userassigned": ManagedIdentityTypesUserAssigned, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ManagedIdentityTypes(input) - return &out, nil -} - -type MarketplaceSubscriptionStatus string - -const ( - MarketplaceSubscriptionStatusActive MarketplaceSubscriptionStatus = "Active" - MarketplaceSubscriptionStatusSuspended MarketplaceSubscriptionStatus = "Suspended" -) - -func PossibleValuesForMarketplaceSubscriptionStatus() []string { - return []string{ - string(MarketplaceSubscriptionStatusActive), - string(MarketplaceSubscriptionStatusSuspended), - } -} - -func (s *MarketplaceSubscriptionStatus) UnmarshalJSON(bytes []byte) error { - var decoded string - if err := json.Unmarshal(bytes, &decoded); err != nil { - return fmt.Errorf("unmarshaling: %+v", err) - } - out, err := parseMarketplaceSubscriptionStatus(decoded) - if err != nil { - return fmt.Errorf("parsing %q: %+v", decoded, err) - } - *s = *out - return nil -} - -func parseMarketplaceSubscriptionStatus(input string) (*MarketplaceSubscriptionStatus, error) { - vals := map[string]MarketplaceSubscriptionStatus{ - "active": MarketplaceSubscriptionStatusActive, - "suspended": MarketplaceSubscriptionStatusSuspended, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := MarketplaceSubscriptionStatus(input) - return &out, nil -} - -type MonitoringStatus string - -const ( - MonitoringStatusDisabled MonitoringStatus = "Disabled" - MonitoringStatusEnabled MonitoringStatus = "Enabled" -) - -func PossibleValuesForMonitoringStatus() []string { - return []string{ - string(MonitoringStatusDisabled), - string(MonitoringStatusEnabled), - } -} - -func (s *MonitoringStatus) UnmarshalJSON(bytes []byte) error { - var decoded string - if err := json.Unmarshal(bytes, &decoded); err != nil { - return fmt.Errorf("unmarshaling: %+v", err) - } - out, err := parseMonitoringStatus(decoded) - if err != nil { - return fmt.Errorf("parsing %q: %+v", decoded, err) - } - *s = *out - return nil -} - -func parseMonitoringStatus(input string) (*MonitoringStatus, error) { - vals := map[string]MonitoringStatus{ - "disabled": MonitoringStatusDisabled, - "enabled": MonitoringStatusEnabled, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := MonitoringStatus(input) - return &out, nil -} - -type ProvisioningState string - -const ( - ProvisioningStateAccepted ProvisioningState = "Accepted" - ProvisioningStateCanceled ProvisioningState = "Canceled" - ProvisioningStateCreating ProvisioningState = "Creating" - ProvisioningStateDeleted ProvisioningState = "Deleted" - ProvisioningStateDeleting ProvisioningState = "Deleting" - ProvisioningStateFailed ProvisioningState = "Failed" - ProvisioningStateNotSpecified ProvisioningState = "NotSpecified" - ProvisioningStateSucceeded ProvisioningState = "Succeeded" - ProvisioningStateUpdating ProvisioningState = "Updating" -) - -func PossibleValuesForProvisioningState() []string { - return []string{ - string(ProvisioningStateAccepted), - string(ProvisioningStateCanceled), - string(ProvisioningStateCreating), - string(ProvisioningStateDeleted), - string(ProvisioningStateDeleting), - string(ProvisioningStateFailed), - string(ProvisioningStateNotSpecified), - string(ProvisioningStateSucceeded), - string(ProvisioningStateUpdating), - } -} - -func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { - var decoded string - if err := json.Unmarshal(bytes, &decoded); err != nil { - return fmt.Errorf("unmarshaling: %+v", err) - } - out, err := parseProvisioningState(decoded) - if err != nil { - return fmt.Errorf("parsing %q: %+v", decoded, err) - } - *s = *out - return nil -} - -func parseProvisioningState(input string) (*ProvisioningState, error) { - vals := map[string]ProvisioningState{ - "accepted": ProvisioningStateAccepted, - "canceled": ProvisioningStateCanceled, - "creating": ProvisioningStateCreating, - "deleted": ProvisioningStateDeleted, - "deleting": ProvisioningStateDeleting, - "failed": ProvisioningStateFailed, - "notspecified": ProvisioningStateNotSpecified, - "succeeded": ProvisioningStateSucceeded, - "updating": ProvisioningStateUpdating, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ProvisioningState(input) - return &out, nil -} - -type UserRole string - -const ( - UserRoleAdmin UserRole = "Admin" - UserRoleNone UserRole = "None" - UserRoleUser UserRole = "User" -) - -func PossibleValuesForUserRole() []string { - return []string{ - string(UserRoleAdmin), - string(UserRoleNone), - string(UserRoleUser), - } -} - -func (s *UserRole) UnmarshalJSON(bytes []byte) error { - var decoded string - if err := json.Unmarshal(bytes, &decoded); err != nil { - return fmt.Errorf("unmarshaling: %+v", err) - } - out, err := parseUserRole(decoded) - if err != nil { - return fmt.Errorf("parsing %q: %+v", decoded, err) - } - *s = *out - return nil -} - -func parseUserRole(input string) (*UserRole, error) { - vals := map[string]UserRole{ - "admin": UserRoleAdmin, - "none": UserRoleNone, - "user": UserRoleUser, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := UserRole(input) - return &out, nil -} diff --git a/resource-manager/logz/2020-10-01/monitors/id_monitor.go b/resource-manager/logz/2020-10-01/monitors/id_monitor.go deleted file mode 100644 index 5240183ead0..00000000000 --- a/resource-manager/logz/2020-10-01/monitors/id_monitor.go +++ /dev/null @@ -1,130 +0,0 @@ -package monitors - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -func init() { - recaser.RegisterResourceId(&MonitorId{}) -} - -var _ resourceids.ResourceId = &MonitorId{} - -// MonitorId is a struct representing the Resource ID for a Monitor -type MonitorId struct { - SubscriptionId string - ResourceGroupName string - MonitorName string -} - -// NewMonitorID returns a new MonitorId struct -func NewMonitorID(subscriptionId string, resourceGroupName string, monitorName string) MonitorId { - return MonitorId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - MonitorName: monitorName, - } -} - -// ParseMonitorID parses 'input' into a MonitorId -func ParseMonitorID(input string) (*MonitorId, error) { - parser := resourceids.NewParserFromResourceIdType(&MonitorId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := MonitorId{} - if err = id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -// ParseMonitorIDInsensitively parses 'input' case-insensitively into a MonitorId -// note: this method should only be used for API response data and not user input -func ParseMonitorIDInsensitively(input string) (*MonitorId, error) { - parser := resourceids.NewParserFromResourceIdType(&MonitorId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := MonitorId{} - if err = id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -func (id *MonitorId) FromParseResult(input resourceids.ParseResult) error { - var ok bool - - if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) - } - - if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) - } - - if id.MonitorName, ok = input.Parsed["monitorName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "monitorName", input) - } - - return nil -} - -// ValidateMonitorID checks that 'input' can be parsed as a Monitor ID -func ValidateMonitorID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParseMonitorID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Monitor ID -func (id MonitorId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Logz/monitors/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.MonitorName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Monitor ID -func (id MonitorId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftLogz", "Microsoft.Logz", "Microsoft.Logz"), - resourceids.StaticSegment("staticMonitors", "monitors", "monitors"), - resourceids.UserSpecifiedSegment("monitorName", "monitorName"), - } -} - -// String returns a human-readable description of this Monitor ID -func (id MonitorId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Monitor Name: %q", id.MonitorName), - } - return fmt.Sprintf("Monitor (%s)", strings.Join(components, "\n")) -} diff --git a/resource-manager/logz/2020-10-01/monitors/method_listmonitoredresources.go b/resource-manager/logz/2020-10-01/monitors/method_listmonitoredresources.go deleted file mode 100644 index d0bd5640be2..00000000000 --- a/resource-manager/logz/2020-10-01/monitors/method_listmonitoredresources.go +++ /dev/null @@ -1,105 +0,0 @@ -package monitors - -import ( - "context" - "fmt" - "net/http" - - "github.com/hashicorp/go-azure-sdk/sdk/client" - "github.com/hashicorp/go-azure-sdk/sdk/odata" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListMonitoredResourcesOperationResponse struct { - HttpResponse *http.Response - OData *odata.OData - Model *[]MonitoredResource -} - -type ListMonitoredResourcesCompleteResult struct { - LatestHttpResponse *http.Response - Items []MonitoredResource -} - -type ListMonitoredResourcesCustomPager struct { - NextLink *odata.Link `json:"nextLink"` -} - -func (p *ListMonitoredResourcesCustomPager) NextPageLink() *odata.Link { - defer func() { - p.NextLink = nil - }() - - return p.NextLink -} - -// ListMonitoredResources ... -func (c MonitorsClient) ListMonitoredResources(ctx context.Context, id MonitorId) (result ListMonitoredResourcesOperationResponse, err error) { - opts := client.RequestOptions{ - ContentType: "application/json; charset=utf-8", - ExpectedStatusCodes: []int{ - http.StatusOK, - }, - HttpMethod: http.MethodPost, - Pager: &ListMonitoredResourcesCustomPager{}, - Path: fmt.Sprintf("%s/listMonitoredResources", id.ID()), - } - - req, err := c.Client.NewRequest(ctx, opts) - if err != nil { - return - } - - var resp *client.Response - resp, err = req.ExecutePaged(ctx) - if resp != nil { - result.OData = resp.OData - result.HttpResponse = resp.Response - } - if err != nil { - return - } - - var values struct { - Values *[]MonitoredResource `json:"value"` - } - if err = resp.Unmarshal(&values); err != nil { - return - } - - result.Model = values.Values - - return -} - -// ListMonitoredResourcesComplete retrieves all the results into a single object -func (c MonitorsClient) ListMonitoredResourcesComplete(ctx context.Context, id MonitorId) (ListMonitoredResourcesCompleteResult, error) { - return c.ListMonitoredResourcesCompleteMatchingPredicate(ctx, id, MonitoredResourceOperationPredicate{}) -} - -// ListMonitoredResourcesCompleteMatchingPredicate retrieves all the results and then applies the predicate -func (c MonitorsClient) ListMonitoredResourcesCompleteMatchingPredicate(ctx context.Context, id MonitorId, predicate MonitoredResourceOperationPredicate) (result ListMonitoredResourcesCompleteResult, err error) { - items := make([]MonitoredResource, 0) - - resp, err := c.ListMonitoredResources(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 = ListMonitoredResourcesCompleteResult{ - LatestHttpResponse: resp.HttpResponse, - Items: items, - } - return -} diff --git a/resource-manager/logz/2020-10-01/monitors/method_listuserroles.go b/resource-manager/logz/2020-10-01/monitors/method_listuserroles.go deleted file mode 100644 index 8706ea14c14..00000000000 --- a/resource-manager/logz/2020-10-01/monitors/method_listuserroles.go +++ /dev/null @@ -1,105 +0,0 @@ -package monitors - -import ( - "context" - "fmt" - "net/http" - - "github.com/hashicorp/go-azure-sdk/sdk/client" - "github.com/hashicorp/go-azure-sdk/sdk/odata" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListUserRolesOperationResponse struct { - HttpResponse *http.Response - OData *odata.OData - Model *[]UserRoleResponse -} - -type ListUserRolesCompleteResult struct { - LatestHttpResponse *http.Response - Items []UserRoleResponse -} - -type ListUserRolesCustomPager struct { - NextLink *odata.Link `json:"nextLink"` -} - -func (p *ListUserRolesCustomPager) NextPageLink() *odata.Link { - defer func() { - p.NextLink = nil - }() - - return p.NextLink -} - -// ListUserRoles ... -func (c MonitorsClient) ListUserRoles(ctx context.Context, id MonitorId, input UserRoleRequest) (result ListUserRolesOperationResponse, err error) { - opts := client.RequestOptions{ - ContentType: "application/json; charset=utf-8", - ExpectedStatusCodes: []int{ - http.StatusOK, - }, - HttpMethod: http.MethodPost, - Pager: &ListUserRolesCustomPager{}, - Path: fmt.Sprintf("%s/listUserRoles", id.ID()), - } - - req, err := c.Client.NewRequest(ctx, opts) - if err != nil { - return - } - - var resp *client.Response - resp, err = req.ExecutePaged(ctx) - if resp != nil { - result.OData = resp.OData - result.HttpResponse = resp.Response - } - if err != nil { - return - } - - var values struct { - Values *[]UserRoleResponse `json:"value"` - } - if err = resp.Unmarshal(&values); err != nil { - return - } - - result.Model = values.Values - - return -} - -// ListUserRolesComplete retrieves all the results into a single object -func (c MonitorsClient) ListUserRolesComplete(ctx context.Context, id MonitorId, input UserRoleRequest) (ListUserRolesCompleteResult, error) { - return c.ListUserRolesCompleteMatchingPredicate(ctx, id, input, UserRoleResponseOperationPredicate{}) -} - -// ListUserRolesCompleteMatchingPredicate retrieves all the results and then applies the predicate -func (c MonitorsClient) ListUserRolesCompleteMatchingPredicate(ctx context.Context, id MonitorId, input UserRoleRequest, predicate UserRoleResponseOperationPredicate) (result ListUserRolesCompleteResult, err error) { - items := make([]UserRoleResponse, 0) - - resp, err := c.ListUserRoles(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 = ListUserRolesCompleteResult{ - LatestHttpResponse: resp.HttpResponse, - Items: items, - } - return -} diff --git a/resource-manager/logz/2020-10-01/monitors/model_identityproperties.go b/resource-manager/logz/2020-10-01/monitors/model_identityproperties.go deleted file mode 100644 index fe9bba0fcd4..00000000000 --- a/resource-manager/logz/2020-10-01/monitors/model_identityproperties.go +++ /dev/null @@ -1,10 +0,0 @@ -package monitors - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type IdentityProperties struct { - PrincipalId *string `json:"principalId,omitempty"` - TenantId *string `json:"tenantId,omitempty"` - Type *ManagedIdentityTypes `json:"type,omitempty"` -} diff --git a/resource-manager/logz/2020-10-01/monitors/model_logzmonitorresource.go b/resource-manager/logz/2020-10-01/monitors/model_logzmonitorresource.go deleted file mode 100644 index 4fb37b1262c..00000000000 --- a/resource-manager/logz/2020-10-01/monitors/model_logzmonitorresource.go +++ /dev/null @@ -1,19 +0,0 @@ -package monitors - -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 LogzMonitorResource struct { - Id *string `json:"id,omitempty"` - Identity *IdentityProperties `json:"identity,omitempty"` - Location string `json:"location"` - Name *string `json:"name,omitempty"` - Properties *MonitorProperties `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/logz/2020-10-01/monitors/model_logzmonitorresourceupdateparameters.go b/resource-manager/logz/2020-10-01/monitors/model_logzmonitorresourceupdateparameters.go deleted file mode 100644 index 830e8f31a42..00000000000 --- a/resource-manager/logz/2020-10-01/monitors/model_logzmonitorresourceupdateparameters.go +++ /dev/null @@ -1,9 +0,0 @@ -package monitors - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type LogzMonitorResourceUpdateParameters struct { - Properties *MonitorUpdateProperties `json:"properties,omitempty"` - Tags *map[string]string `json:"tags,omitempty"` -} diff --git a/resource-manager/logz/2020-10-01/monitors/model_logzorganizationproperties.go b/resource-manager/logz/2020-10-01/monitors/model_logzorganizationproperties.go deleted file mode 100644 index df896c926b6..00000000000 --- a/resource-manager/logz/2020-10-01/monitors/model_logzorganizationproperties.go +++ /dev/null @@ -1,11 +0,0 @@ -package monitors - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type LogzOrganizationProperties struct { - CompanyName *string `json:"companyName,omitempty"` - EnterpriseAppId *string `json:"enterpriseAppId,omitempty"` - Id *string `json:"id,omitempty"` - SingleSignOnURL *string `json:"singleSignOnUrl,omitempty"` -} diff --git a/resource-manager/logz/2020-10-01/monitors/model_monitoredresource.go b/resource-manager/logz/2020-10-01/monitors/model_monitoredresource.go deleted file mode 100644 index 065846c750f..00000000000 --- a/resource-manager/logz/2020-10-01/monitors/model_monitoredresource.go +++ /dev/null @@ -1,17 +0,0 @@ -package monitors - -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 MonitoredResource struct { - Id *string `json:"id,omitempty"` - ReasonForLogsStatus *string `json:"reasonForLogsStatus,omitempty"` - ReasonForMetricsStatus *string `json:"reasonForMetricsStatus,omitempty"` - SendingLogs *bool `json:"sendingLogs,omitempty"` - SendingMetrics *bool `json:"sendingMetrics,omitempty"` - SystemData *systemdata.SystemData `json:"systemData,omitempty"` -} diff --git a/resource-manager/logz/2020-10-01/monitors/model_monitorproperties.go b/resource-manager/logz/2020-10-01/monitors/model_monitorproperties.go deleted file mode 100644 index d6729416f41..00000000000 --- a/resource-manager/logz/2020-10-01/monitors/model_monitorproperties.go +++ /dev/null @@ -1,15 +0,0 @@ -package monitors - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type MonitorProperties struct { - LiftrResourceCategory *LiftrResourceCategories `json:"liftrResourceCategory,omitempty"` - LiftrResourcePreference *int64 `json:"liftrResourcePreference,omitempty"` - LogzOrganizationProperties *LogzOrganizationProperties `json:"logzOrganizationProperties,omitempty"` - MarketplaceSubscriptionStatus *MarketplaceSubscriptionStatus `json:"marketplaceSubscriptionStatus,omitempty"` - MonitoringStatus *MonitoringStatus `json:"monitoringStatus,omitempty"` - PlanData *PlanData `json:"planData,omitempty"` - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` - UserInfo *UserInfo `json:"userInfo,omitempty"` -} diff --git a/resource-manager/logz/2020-10-01/monitors/model_plandata.go b/resource-manager/logz/2020-10-01/monitors/model_plandata.go deleted file mode 100644 index 00c8e7373ed..00000000000 --- a/resource-manager/logz/2020-10-01/monitors/model_plandata.go +++ /dev/null @@ -1,29 +0,0 @@ -package monitors - -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 PlanData struct { - BillingCycle *string `json:"billingCycle,omitempty"` - EffectiveDate *string `json:"effectiveDate,omitempty"` - PlanDetails *string `json:"planDetails,omitempty"` - UsageType *string `json:"usageType,omitempty"` -} - -func (o *PlanData) GetEffectiveDateAsTime() (*time.Time, error) { - if o.EffectiveDate == nil { - return nil, nil - } - return dates.ParseAsFormat(o.EffectiveDate, "2006-01-02T15:04:05Z07:00") -} - -func (o *PlanData) SetEffectiveDateAsTime(input time.Time) { - formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.EffectiveDate = &formatted -} diff --git a/resource-manager/logz/2020-10-01/monitors/model_userinfo.go b/resource-manager/logz/2020-10-01/monitors/model_userinfo.go deleted file mode 100644 index b79ecbab14f..00000000000 --- a/resource-manager/logz/2020-10-01/monitors/model_userinfo.go +++ /dev/null @@ -1,11 +0,0 @@ -package monitors - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UserInfo struct { - EmailAddress *string `json:"emailAddress,omitempty"` - FirstName *string `json:"firstName,omitempty"` - LastName *string `json:"lastName,omitempty"` - PhoneNumber *string `json:"phoneNumber,omitempty"` -} diff --git a/resource-manager/logz/2020-10-01/monitors/predicates.go b/resource-manager/logz/2020-10-01/monitors/predicates.go deleted file mode 100644 index c717fd40c26..00000000000 --- a/resource-manager/logz/2020-10-01/monitors/predicates.go +++ /dev/null @@ -1,73 +0,0 @@ -package monitors - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type LogzMonitorResourceOperationPredicate struct { - Id *string - Location *string - Name *string - Type *string -} - -func (p LogzMonitorResourceOperationPredicate) Matches(input LogzMonitorResource) bool { - - if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { - return false - } - - if p.Location != nil && *p.Location != input.Location { - return false - } - - if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { - return false - } - - if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { - return false - } - - return true -} - -type MonitoredResourceOperationPredicate struct { - Id *string - ReasonForLogsStatus *string - ReasonForMetricsStatus *string - SendingLogs *bool - SendingMetrics *bool -} - -func (p MonitoredResourceOperationPredicate) Matches(input MonitoredResource) bool { - - if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { - return false - } - - if p.ReasonForLogsStatus != nil && (input.ReasonForLogsStatus == nil || *p.ReasonForLogsStatus != *input.ReasonForLogsStatus) { - return false - } - - if p.ReasonForMetricsStatus != nil && (input.ReasonForMetricsStatus == nil || *p.ReasonForMetricsStatus != *input.ReasonForMetricsStatus) { - return false - } - - if p.SendingLogs != nil && (input.SendingLogs == nil || *p.SendingLogs != *input.SendingLogs) { - return false - } - - if p.SendingMetrics != nil && (input.SendingMetrics == nil || *p.SendingMetrics != *input.SendingMetrics) { - return false - } - - return true -} - -type UserRoleResponseOperationPredicate struct { -} - -func (p UserRoleResponseOperationPredicate) Matches(input UserRoleResponse) bool { - - return true -} diff --git a/resource-manager/logz/2020-10-01/singlesignon/README.md b/resource-manager/logz/2020-10-01/singlesignon/README.md deleted file mode 100644 index f580e03df5d..00000000000 --- a/resource-manager/logz/2020-10-01/singlesignon/README.md +++ /dev/null @@ -1,70 +0,0 @@ - -## `github.com/hashicorp/go-azure-sdk/resource-manager/logz/2020-10-01/singlesignon` Documentation - -The `singlesignon` SDK allows for interaction with Azure Resource Manager `logz` (API Version `2020-10-01`). - -This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). - -### Import Path - -```go -import "github.com/hashicorp/go-azure-sdk/resource-manager/logz/2020-10-01/singlesignon" -``` - - -### Client Initialization - -```go -client := singlesignon.NewSingleSignOnClientWithBaseURI("https://management.azure.com") -client.Client.Authorizer = authorizer -``` - - -### Example Usage: `SingleSignOnClient.CreateOrUpdate` - -```go -ctx := context.TODO() -id := singlesignon.NewSingleSignOnConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName", "singleSignOnConfigurationName") - -payload := singlesignon.LogzSingleSignOnResource{ - // ... -} - - -if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { - // handle the error -} -``` - - -### Example Usage: `SingleSignOnClient.Get` - -```go -ctx := context.TODO() -id := singlesignon.NewSingleSignOnConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName", "singleSignOnConfigurationName") - -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: `SingleSignOnClient.List` - -```go -ctx := context.TODO() -id := singlesignon.NewMonitorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName") - -// alternatively `client.List(ctx, id)` can be used to do batched pagination -items, err := client.ListComplete(ctx, id) -if err != nil { - // handle the error -} -for _, item := range items { - // do something -} -``` diff --git a/resource-manager/logz/2020-10-01/singlesignon/constants.go b/resource-manager/logz/2020-10-01/singlesignon/constants.go deleted file mode 100644 index c9cdd7eb362..00000000000 --- a/resource-manager/logz/2020-10-01/singlesignon/constants.go +++ /dev/null @@ -1,119 +0,0 @@ -package singlesignon - -import ( - "encoding/json" - "fmt" - "strings" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ProvisioningState string - -const ( - ProvisioningStateAccepted ProvisioningState = "Accepted" - ProvisioningStateCanceled ProvisioningState = "Canceled" - ProvisioningStateCreating ProvisioningState = "Creating" - ProvisioningStateDeleted ProvisioningState = "Deleted" - ProvisioningStateDeleting ProvisioningState = "Deleting" - ProvisioningStateFailed ProvisioningState = "Failed" - ProvisioningStateNotSpecified ProvisioningState = "NotSpecified" - ProvisioningStateSucceeded ProvisioningState = "Succeeded" - ProvisioningStateUpdating ProvisioningState = "Updating" -) - -func PossibleValuesForProvisioningState() []string { - return []string{ - string(ProvisioningStateAccepted), - string(ProvisioningStateCanceled), - string(ProvisioningStateCreating), - string(ProvisioningStateDeleted), - string(ProvisioningStateDeleting), - string(ProvisioningStateFailed), - string(ProvisioningStateNotSpecified), - string(ProvisioningStateSucceeded), - string(ProvisioningStateUpdating), - } -} - -func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { - var decoded string - if err := json.Unmarshal(bytes, &decoded); err != nil { - return fmt.Errorf("unmarshaling: %+v", err) - } - out, err := parseProvisioningState(decoded) - if err != nil { - return fmt.Errorf("parsing %q: %+v", decoded, err) - } - *s = *out - return nil -} - -func parseProvisioningState(input string) (*ProvisioningState, error) { - vals := map[string]ProvisioningState{ - "accepted": ProvisioningStateAccepted, - "canceled": ProvisioningStateCanceled, - "creating": ProvisioningStateCreating, - "deleted": ProvisioningStateDeleted, - "deleting": ProvisioningStateDeleting, - "failed": ProvisioningStateFailed, - "notspecified": ProvisioningStateNotSpecified, - "succeeded": ProvisioningStateSucceeded, - "updating": ProvisioningStateUpdating, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ProvisioningState(input) - return &out, nil -} - -type SingleSignOnStates string - -const ( - SingleSignOnStatesDisable SingleSignOnStates = "Disable" - SingleSignOnStatesEnable SingleSignOnStates = "Enable" - SingleSignOnStatesExisting SingleSignOnStates = "Existing" - SingleSignOnStatesInitial SingleSignOnStates = "Initial" -) - -func PossibleValuesForSingleSignOnStates() []string { - return []string{ - string(SingleSignOnStatesDisable), - string(SingleSignOnStatesEnable), - string(SingleSignOnStatesExisting), - string(SingleSignOnStatesInitial), - } -} - -func (s *SingleSignOnStates) UnmarshalJSON(bytes []byte) error { - var decoded string - if err := json.Unmarshal(bytes, &decoded); err != nil { - return fmt.Errorf("unmarshaling: %+v", err) - } - out, err := parseSingleSignOnStates(decoded) - if err != nil { - return fmt.Errorf("parsing %q: %+v", decoded, err) - } - *s = *out - return nil -} - -func parseSingleSignOnStates(input string) (*SingleSignOnStates, error) { - vals := map[string]SingleSignOnStates{ - "disable": SingleSignOnStatesDisable, - "enable": SingleSignOnStatesEnable, - "existing": SingleSignOnStatesExisting, - "initial": SingleSignOnStatesInitial, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := SingleSignOnStates(input) - return &out, nil -} diff --git a/resource-manager/logz/2020-10-01/singlesignon/id_monitor.go b/resource-manager/logz/2020-10-01/singlesignon/id_monitor.go deleted file mode 100644 index 3c5584e7bb7..00000000000 --- a/resource-manager/logz/2020-10-01/singlesignon/id_monitor.go +++ /dev/null @@ -1,130 +0,0 @@ -package singlesignon - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -func init() { - recaser.RegisterResourceId(&MonitorId{}) -} - -var _ resourceids.ResourceId = &MonitorId{} - -// MonitorId is a struct representing the Resource ID for a Monitor -type MonitorId struct { - SubscriptionId string - ResourceGroupName string - MonitorName string -} - -// NewMonitorID returns a new MonitorId struct -func NewMonitorID(subscriptionId string, resourceGroupName string, monitorName string) MonitorId { - return MonitorId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - MonitorName: monitorName, - } -} - -// ParseMonitorID parses 'input' into a MonitorId -func ParseMonitorID(input string) (*MonitorId, error) { - parser := resourceids.NewParserFromResourceIdType(&MonitorId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := MonitorId{} - if err = id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -// ParseMonitorIDInsensitively parses 'input' case-insensitively into a MonitorId -// note: this method should only be used for API response data and not user input -func ParseMonitorIDInsensitively(input string) (*MonitorId, error) { - parser := resourceids.NewParserFromResourceIdType(&MonitorId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := MonitorId{} - if err = id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -func (id *MonitorId) FromParseResult(input resourceids.ParseResult) error { - var ok bool - - if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) - } - - if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) - } - - if id.MonitorName, ok = input.Parsed["monitorName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "monitorName", input) - } - - return nil -} - -// ValidateMonitorID checks that 'input' can be parsed as a Monitor ID -func ValidateMonitorID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParseMonitorID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Monitor ID -func (id MonitorId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Logz/monitors/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.MonitorName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Monitor ID -func (id MonitorId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftLogz", "Microsoft.Logz", "Microsoft.Logz"), - resourceids.StaticSegment("staticMonitors", "monitors", "monitors"), - resourceids.UserSpecifiedSegment("monitorName", "monitorName"), - } -} - -// String returns a human-readable description of this Monitor ID -func (id MonitorId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Monitor Name: %q", id.MonitorName), - } - return fmt.Sprintf("Monitor (%s)", strings.Join(components, "\n")) -} diff --git a/resource-manager/logz/2020-10-01/singlesignon/id_singlesignonconfiguration.go b/resource-manager/logz/2020-10-01/singlesignon/id_singlesignonconfiguration.go deleted file mode 100644 index e6b77023bb3..00000000000 --- a/resource-manager/logz/2020-10-01/singlesignon/id_singlesignonconfiguration.go +++ /dev/null @@ -1,139 +0,0 @@ -package singlesignon - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -func init() { - recaser.RegisterResourceId(&SingleSignOnConfigurationId{}) -} - -var _ resourceids.ResourceId = &SingleSignOnConfigurationId{} - -// SingleSignOnConfigurationId is a struct representing the Resource ID for a Single Sign On Configuration -type SingleSignOnConfigurationId struct { - SubscriptionId string - ResourceGroupName string - MonitorName string - SingleSignOnConfigurationName string -} - -// NewSingleSignOnConfigurationID returns a new SingleSignOnConfigurationId struct -func NewSingleSignOnConfigurationID(subscriptionId string, resourceGroupName string, monitorName string, singleSignOnConfigurationName string) SingleSignOnConfigurationId { - return SingleSignOnConfigurationId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - MonitorName: monitorName, - SingleSignOnConfigurationName: singleSignOnConfigurationName, - } -} - -// ParseSingleSignOnConfigurationID parses 'input' into a SingleSignOnConfigurationId -func ParseSingleSignOnConfigurationID(input string) (*SingleSignOnConfigurationId, error) { - parser := resourceids.NewParserFromResourceIdType(&SingleSignOnConfigurationId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := SingleSignOnConfigurationId{} - if err = id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -// ParseSingleSignOnConfigurationIDInsensitively parses 'input' case-insensitively into a SingleSignOnConfigurationId -// note: this method should only be used for API response data and not user input -func ParseSingleSignOnConfigurationIDInsensitively(input string) (*SingleSignOnConfigurationId, error) { - parser := resourceids.NewParserFromResourceIdType(&SingleSignOnConfigurationId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := SingleSignOnConfigurationId{} - if err = id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -func (id *SingleSignOnConfigurationId) FromParseResult(input resourceids.ParseResult) error { - var ok bool - - if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) - } - - if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) - } - - if id.MonitorName, ok = input.Parsed["monitorName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "monitorName", input) - } - - if id.SingleSignOnConfigurationName, ok = input.Parsed["singleSignOnConfigurationName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "singleSignOnConfigurationName", input) - } - - return nil -} - -// ValidateSingleSignOnConfigurationID checks that 'input' can be parsed as a Single Sign On Configuration ID -func ValidateSingleSignOnConfigurationID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParseSingleSignOnConfigurationID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Single Sign On Configuration ID -func (id SingleSignOnConfigurationId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Logz/monitors/%s/singleSignOnConfigurations/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.MonitorName, id.SingleSignOnConfigurationName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Single Sign On Configuration ID -func (id SingleSignOnConfigurationId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftLogz", "Microsoft.Logz", "Microsoft.Logz"), - resourceids.StaticSegment("staticMonitors", "monitors", "monitors"), - resourceids.UserSpecifiedSegment("monitorName", "monitorName"), - resourceids.StaticSegment("staticSingleSignOnConfigurations", "singleSignOnConfigurations", "singleSignOnConfigurations"), - resourceids.UserSpecifiedSegment("singleSignOnConfigurationName", "singleSignOnConfigurationName"), - } -} - -// String returns a human-readable description of this Single Sign On Configuration ID -func (id SingleSignOnConfigurationId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Monitor Name: %q", id.MonitorName), - fmt.Sprintf("Single Sign On Configuration Name: %q", id.SingleSignOnConfigurationName), - } - return fmt.Sprintf("Single Sign On Configuration (%s)", strings.Join(components, "\n")) -} diff --git a/resource-manager/logz/2020-10-01/singlesignon/model_logzsinglesignonproperties.go b/resource-manager/logz/2020-10-01/singlesignon/model_logzsinglesignonproperties.go deleted file mode 100644 index 8f5004adb0f..00000000000 --- a/resource-manager/logz/2020-10-01/singlesignon/model_logzsinglesignonproperties.go +++ /dev/null @@ -1,11 +0,0 @@ -package singlesignon - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type LogzSingleSignOnProperties struct { - EnterpriseAppId *string `json:"enterpriseAppId,omitempty"` - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` - SingleSignOnState *SingleSignOnStates `json:"singleSignOnState,omitempty"` - SingleSignOnURL *string `json:"singleSignOnUrl,omitempty"` -} diff --git a/resource-manager/logz/2020-10-01/subaccount/README.md b/resource-manager/logz/2020-10-01/subaccount/README.md deleted file mode 100644 index 64b3329b6a9..00000000000 --- a/resource-manager/logz/2020-10-01/subaccount/README.md +++ /dev/null @@ -1,120 +0,0 @@ - -## `github.com/hashicorp/go-azure-sdk/resource-manager/logz/2020-10-01/subaccount` Documentation - -The `subaccount` SDK allows for interaction with Azure Resource Manager `logz` (API Version `2020-10-01`). - -This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). - -### Import Path - -```go -import "github.com/hashicorp/go-azure-sdk/resource-manager/logz/2020-10-01/subaccount" -``` - - -### Client Initialization - -```go -client := subaccount.NewSubAccountClientWithBaseURI("https://management.azure.com") -client.Client.Authorizer = authorizer -``` - - -### Example Usage: `SubAccountClient.Create` - -```go -ctx := context.TODO() -id := subaccount.NewAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName", "accountName") - -payload := subaccount.LogzMonitorResource{ - // ... -} - - -if err := client.CreateThenPoll(ctx, id, payload); err != nil { - // handle the error -} -``` - - -### Example Usage: `SubAccountClient.Delete` - -```go -ctx := context.TODO() -id := subaccount.NewAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName", "accountName") - -if err := client.DeleteThenPoll(ctx, id); err != nil { - // handle the error -} -``` - - -### Example Usage: `SubAccountClient.Get` - -```go -ctx := context.TODO() -id := subaccount.NewAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName", "accountName") - -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: `SubAccountClient.List` - -```go -ctx := context.TODO() -id := subaccount.NewMonitorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName") - -// alternatively `client.List(ctx, id)` can be used to do batched pagination -items, err := client.ListComplete(ctx, id) -if err != nil { - // handle the error -} -for _, item := range items { - // do something -} -``` - - -### Example Usage: `SubAccountClient.ListMonitoredResources` - -```go -ctx := context.TODO() -id := subaccount.NewAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName", "accountName") - -// alternatively `client.ListMonitoredResources(ctx, id)` can be used to do batched pagination -items, err := client.ListMonitoredResourcesComplete(ctx, id) -if err != nil { - // handle the error -} -for _, item := range items { - // do something -} -``` - - -### Example Usage: `SubAccountClient.Update` - -```go -ctx := context.TODO() -id := subaccount.NewAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName", "accountName") - -payload := subaccount.LogzMonitorResourceUpdateParameters{ - // ... -} - - -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/logz/2020-10-01/subaccount/constants.go b/resource-manager/logz/2020-10-01/subaccount/constants.go deleted file mode 100644 index a7097ddc03d..00000000000 --- a/resource-manager/logz/2020-10-01/subaccount/constants.go +++ /dev/null @@ -1,236 +0,0 @@ -package subaccount - -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 LiftrResourceCategories string - -const ( - LiftrResourceCategoriesMonitorLogs LiftrResourceCategories = "MonitorLogs" - LiftrResourceCategoriesUnknown LiftrResourceCategories = "Unknown" -) - -func PossibleValuesForLiftrResourceCategories() []string { - return []string{ - string(LiftrResourceCategoriesMonitorLogs), - string(LiftrResourceCategoriesUnknown), - } -} - -func (s *LiftrResourceCategories) UnmarshalJSON(bytes []byte) error { - var decoded string - if err := json.Unmarshal(bytes, &decoded); err != nil { - return fmt.Errorf("unmarshaling: %+v", err) - } - out, err := parseLiftrResourceCategories(decoded) - if err != nil { - return fmt.Errorf("parsing %q: %+v", decoded, err) - } - *s = *out - return nil -} - -func parseLiftrResourceCategories(input string) (*LiftrResourceCategories, error) { - vals := map[string]LiftrResourceCategories{ - "monitorlogs": LiftrResourceCategoriesMonitorLogs, - "unknown": LiftrResourceCategoriesUnknown, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := LiftrResourceCategories(input) - return &out, nil -} - -type ManagedIdentityTypes string - -const ( - ManagedIdentityTypesSystemAssigned ManagedIdentityTypes = "SystemAssigned" - ManagedIdentityTypesUserAssigned ManagedIdentityTypes = "UserAssigned" -) - -func PossibleValuesForManagedIdentityTypes() []string { - return []string{ - string(ManagedIdentityTypesSystemAssigned), - string(ManagedIdentityTypesUserAssigned), - } -} - -func (s *ManagedIdentityTypes) UnmarshalJSON(bytes []byte) error { - var decoded string - if err := json.Unmarshal(bytes, &decoded); err != nil { - return fmt.Errorf("unmarshaling: %+v", err) - } - out, err := parseManagedIdentityTypes(decoded) - if err != nil { - return fmt.Errorf("parsing %q: %+v", decoded, err) - } - *s = *out - return nil -} - -func parseManagedIdentityTypes(input string) (*ManagedIdentityTypes, error) { - vals := map[string]ManagedIdentityTypes{ - "systemassigned": ManagedIdentityTypesSystemAssigned, - "userassigned": ManagedIdentityTypesUserAssigned, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ManagedIdentityTypes(input) - return &out, nil -} - -type MarketplaceSubscriptionStatus string - -const ( - MarketplaceSubscriptionStatusActive MarketplaceSubscriptionStatus = "Active" - MarketplaceSubscriptionStatusSuspended MarketplaceSubscriptionStatus = "Suspended" -) - -func PossibleValuesForMarketplaceSubscriptionStatus() []string { - return []string{ - string(MarketplaceSubscriptionStatusActive), - string(MarketplaceSubscriptionStatusSuspended), - } -} - -func (s *MarketplaceSubscriptionStatus) UnmarshalJSON(bytes []byte) error { - var decoded string - if err := json.Unmarshal(bytes, &decoded); err != nil { - return fmt.Errorf("unmarshaling: %+v", err) - } - out, err := parseMarketplaceSubscriptionStatus(decoded) - if err != nil { - return fmt.Errorf("parsing %q: %+v", decoded, err) - } - *s = *out - return nil -} - -func parseMarketplaceSubscriptionStatus(input string) (*MarketplaceSubscriptionStatus, error) { - vals := map[string]MarketplaceSubscriptionStatus{ - "active": MarketplaceSubscriptionStatusActive, - "suspended": MarketplaceSubscriptionStatusSuspended, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := MarketplaceSubscriptionStatus(input) - return &out, nil -} - -type MonitoringStatus string - -const ( - MonitoringStatusDisabled MonitoringStatus = "Disabled" - MonitoringStatusEnabled MonitoringStatus = "Enabled" -) - -func PossibleValuesForMonitoringStatus() []string { - return []string{ - string(MonitoringStatusDisabled), - string(MonitoringStatusEnabled), - } -} - -func (s *MonitoringStatus) UnmarshalJSON(bytes []byte) error { - var decoded string - if err := json.Unmarshal(bytes, &decoded); err != nil { - return fmt.Errorf("unmarshaling: %+v", err) - } - out, err := parseMonitoringStatus(decoded) - if err != nil { - return fmt.Errorf("parsing %q: %+v", decoded, err) - } - *s = *out - return nil -} - -func parseMonitoringStatus(input string) (*MonitoringStatus, error) { - vals := map[string]MonitoringStatus{ - "disabled": MonitoringStatusDisabled, - "enabled": MonitoringStatusEnabled, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := MonitoringStatus(input) - return &out, nil -} - -type ProvisioningState string - -const ( - ProvisioningStateAccepted ProvisioningState = "Accepted" - ProvisioningStateCanceled ProvisioningState = "Canceled" - ProvisioningStateCreating ProvisioningState = "Creating" - ProvisioningStateDeleted ProvisioningState = "Deleted" - ProvisioningStateDeleting ProvisioningState = "Deleting" - ProvisioningStateFailed ProvisioningState = "Failed" - ProvisioningStateNotSpecified ProvisioningState = "NotSpecified" - ProvisioningStateSucceeded ProvisioningState = "Succeeded" - ProvisioningStateUpdating ProvisioningState = "Updating" -) - -func PossibleValuesForProvisioningState() []string { - return []string{ - string(ProvisioningStateAccepted), - string(ProvisioningStateCanceled), - string(ProvisioningStateCreating), - string(ProvisioningStateDeleted), - string(ProvisioningStateDeleting), - string(ProvisioningStateFailed), - string(ProvisioningStateNotSpecified), - string(ProvisioningStateSucceeded), - string(ProvisioningStateUpdating), - } -} - -func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { - var decoded string - if err := json.Unmarshal(bytes, &decoded); err != nil { - return fmt.Errorf("unmarshaling: %+v", err) - } - out, err := parseProvisioningState(decoded) - if err != nil { - return fmt.Errorf("parsing %q: %+v", decoded, err) - } - *s = *out - return nil -} - -func parseProvisioningState(input string) (*ProvisioningState, error) { - vals := map[string]ProvisioningState{ - "accepted": ProvisioningStateAccepted, - "canceled": ProvisioningStateCanceled, - "creating": ProvisioningStateCreating, - "deleted": ProvisioningStateDeleted, - "deleting": ProvisioningStateDeleting, - "failed": ProvisioningStateFailed, - "notspecified": ProvisioningStateNotSpecified, - "succeeded": ProvisioningStateSucceeded, - "updating": ProvisioningStateUpdating, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ProvisioningState(input) - return &out, nil -} diff --git a/resource-manager/logz/2020-10-01/subaccount/id_account.go b/resource-manager/logz/2020-10-01/subaccount/id_account.go deleted file mode 100644 index 9d6d7837918..00000000000 --- a/resource-manager/logz/2020-10-01/subaccount/id_account.go +++ /dev/null @@ -1,139 +0,0 @@ -package subaccount - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -func init() { - recaser.RegisterResourceId(&AccountId{}) -} - -var _ resourceids.ResourceId = &AccountId{} - -// AccountId is a struct representing the Resource ID for a Account -type AccountId struct { - SubscriptionId string - ResourceGroupName string - MonitorName string - AccountName string -} - -// NewAccountID returns a new AccountId struct -func NewAccountID(subscriptionId string, resourceGroupName string, monitorName string, accountName string) AccountId { - return AccountId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - MonitorName: monitorName, - AccountName: accountName, - } -} - -// ParseAccountID parses 'input' into a AccountId -func ParseAccountID(input string) (*AccountId, error) { - parser := resourceids.NewParserFromResourceIdType(&AccountId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := AccountId{} - if err = id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -// ParseAccountIDInsensitively parses 'input' case-insensitively into a AccountId -// note: this method should only be used for API response data and not user input -func ParseAccountIDInsensitively(input string) (*AccountId, error) { - parser := resourceids.NewParserFromResourceIdType(&AccountId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := AccountId{} - if err = id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -func (id *AccountId) FromParseResult(input resourceids.ParseResult) error { - var ok bool - - if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) - } - - if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) - } - - if id.MonitorName, ok = input.Parsed["monitorName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "monitorName", input) - } - - if id.AccountName, ok = input.Parsed["accountName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "accountName", input) - } - - return nil -} - -// ValidateAccountID checks that 'input' can be parsed as a Account ID -func ValidateAccountID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParseAccountID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Account ID -func (id AccountId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Logz/monitors/%s/accounts/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.MonitorName, id.AccountName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Account ID -func (id AccountId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftLogz", "Microsoft.Logz", "Microsoft.Logz"), - resourceids.StaticSegment("staticMonitors", "monitors", "monitors"), - resourceids.UserSpecifiedSegment("monitorName", "monitorName"), - resourceids.StaticSegment("staticAccounts", "accounts", "accounts"), - resourceids.UserSpecifiedSegment("accountName", "accountName"), - } -} - -// String returns a human-readable description of this Account ID -func (id AccountId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Monitor Name: %q", id.MonitorName), - fmt.Sprintf("Account Name: %q", id.AccountName), - } - return fmt.Sprintf("Account (%s)", strings.Join(components, "\n")) -} diff --git a/resource-manager/logz/2020-10-01/subaccount/id_account_test.go b/resource-manager/logz/2020-10-01/subaccount/id_account_test.go deleted file mode 100644 index 09fb0943699..00000000000 --- a/resource-manager/logz/2020-10-01/subaccount/id_account_test.go +++ /dev/null @@ -1,327 +0,0 @@ -package subaccount - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -var _ resourceids.ResourceId = &AccountId{} - -func TestNewAccountID(t *testing.T) { - id := NewAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName", "accountName") - - if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { - t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") - } - - if id.ResourceGroupName != "example-resource-group" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") - } - - if id.MonitorName != "monitorName" { - t.Fatalf("Expected %q but got %q for Segment 'MonitorName'", id.MonitorName, "monitorName") - } - - if id.AccountName != "accountName" { - t.Fatalf("Expected %q but got %q for Segment 'AccountName'", id.AccountName, "accountName") - } -} - -func TestFormatAccountID(t *testing.T) { - actual := NewAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName", "accountName").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/accounts/accountName" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseAccountID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *AccountId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/accounts", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/accounts/accountName", - Expected: &AccountId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - MonitorName: "monitorName", - AccountName: "accountName", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/accounts/accountName/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseAccountID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.MonitorName != v.Expected.MonitorName { - t.Fatalf("Expected %q but got %q for MonitorName", v.Expected.MonitorName, actual.MonitorName) - } - - if actual.AccountName != v.Expected.AccountName { - t.Fatalf("Expected %q but got %q for AccountName", v.Expected.AccountName, actual.AccountName) - } - - } -} - -func TestParseAccountIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *AccountId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ/mOnItOrS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ/mOnItOrS/mOnItOrNaMe", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/accounts", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ/mOnItOrS/mOnItOrNaMe/aCcOuNtS", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/accounts/accountName", - Expected: &AccountId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - MonitorName: "monitorName", - AccountName: "accountName", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/accounts/accountName/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ/mOnItOrS/mOnItOrNaMe/aCcOuNtS/aCcOuNtNaMe", - Expected: &AccountId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - MonitorName: "mOnItOrNaMe", - AccountName: "aCcOuNtNaMe", - }, - }, - { - // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ/mOnItOrS/mOnItOrNaMe/aCcOuNtS/aCcOuNtNaMe/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseAccountIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.MonitorName != v.Expected.MonitorName { - t.Fatalf("Expected %q but got %q for MonitorName", v.Expected.MonitorName, actual.MonitorName) - } - - if actual.AccountName != v.Expected.AccountName { - t.Fatalf("Expected %q but got %q for AccountName", v.Expected.AccountName, actual.AccountName) - } - - } -} - -func TestSegmentsForAccountId(t *testing.T) { - segments := AccountId{}.Segments() - if len(segments) == 0 { - t.Fatalf("AccountId has no segments") - } - - uniqueNames := make(map[string]struct{}, 0) - for _, segment := range segments { - uniqueNames[segment.Name] = struct{}{} - } - if len(uniqueNames) != len(segments) { - t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) - } -} diff --git a/resource-manager/logz/2020-10-01/subaccount/id_monitor.go b/resource-manager/logz/2020-10-01/subaccount/id_monitor.go deleted file mode 100644 index acc4dc23569..00000000000 --- a/resource-manager/logz/2020-10-01/subaccount/id_monitor.go +++ /dev/null @@ -1,130 +0,0 @@ -package subaccount - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -func init() { - recaser.RegisterResourceId(&MonitorId{}) -} - -var _ resourceids.ResourceId = &MonitorId{} - -// MonitorId is a struct representing the Resource ID for a Monitor -type MonitorId struct { - SubscriptionId string - ResourceGroupName string - MonitorName string -} - -// NewMonitorID returns a new MonitorId struct -func NewMonitorID(subscriptionId string, resourceGroupName string, monitorName string) MonitorId { - return MonitorId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - MonitorName: monitorName, - } -} - -// ParseMonitorID parses 'input' into a MonitorId -func ParseMonitorID(input string) (*MonitorId, error) { - parser := resourceids.NewParserFromResourceIdType(&MonitorId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := MonitorId{} - if err = id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -// ParseMonitorIDInsensitively parses 'input' case-insensitively into a MonitorId -// note: this method should only be used for API response data and not user input -func ParseMonitorIDInsensitively(input string) (*MonitorId, error) { - parser := resourceids.NewParserFromResourceIdType(&MonitorId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := MonitorId{} - if err = id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -func (id *MonitorId) FromParseResult(input resourceids.ParseResult) error { - var ok bool - - if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) - } - - if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) - } - - if id.MonitorName, ok = input.Parsed["monitorName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "monitorName", input) - } - - return nil -} - -// ValidateMonitorID checks that 'input' can be parsed as a Monitor ID -func ValidateMonitorID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParseMonitorID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Monitor ID -func (id MonitorId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Logz/monitors/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.MonitorName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Monitor ID -func (id MonitorId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftLogz", "Microsoft.Logz", "Microsoft.Logz"), - resourceids.StaticSegment("staticMonitors", "monitors", "monitors"), - resourceids.UserSpecifiedSegment("monitorName", "monitorName"), - } -} - -// String returns a human-readable description of this Monitor ID -func (id MonitorId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Monitor Name: %q", id.MonitorName), - } - return fmt.Sprintf("Monitor (%s)", strings.Join(components, "\n")) -} diff --git a/resource-manager/logz/2020-10-01/subaccount/method_list.go b/resource-manager/logz/2020-10-01/subaccount/method_list.go deleted file mode 100644 index 6c6010d5b4b..00000000000 --- a/resource-manager/logz/2020-10-01/subaccount/method_list.go +++ /dev/null @@ -1,105 +0,0 @@ -package subaccount - -import ( - "context" - "fmt" - "net/http" - - "github.com/hashicorp/go-azure-sdk/sdk/client" - "github.com/hashicorp/go-azure-sdk/sdk/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 *[]LogzMonitorResource -} - -type ListCompleteResult struct { - LatestHttpResponse *http.Response - Items []LogzMonitorResource -} - -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 SubAccountClient) List(ctx context.Context, id MonitorId) (result ListOperationResponse, err error) { - opts := client.RequestOptions{ - ContentType: "application/json; charset=utf-8", - ExpectedStatusCodes: []int{ - http.StatusOK, - }, - HttpMethod: http.MethodGet, - Pager: &ListCustomPager{}, - Path: fmt.Sprintf("%s/accounts", id.ID()), - } - - req, err := c.Client.NewRequest(ctx, opts) - if err != nil { - return - } - - var resp *client.Response - resp, err = req.ExecutePaged(ctx) - if resp != nil { - result.OData = resp.OData - result.HttpResponse = resp.Response - } - if err != nil { - return - } - - var values struct { - Values *[]LogzMonitorResource `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 SubAccountClient) ListComplete(ctx context.Context, id MonitorId) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, LogzMonitorResourceOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate -func (c SubAccountClient) ListCompleteMatchingPredicate(ctx context.Context, id MonitorId, predicate LogzMonitorResourceOperationPredicate) (result ListCompleteResult, err error) { - items := make([]LogzMonitorResource, 0) - - resp, err := c.List(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 = ListCompleteResult{ - LatestHttpResponse: resp.HttpResponse, - Items: items, - } - return -} diff --git a/resource-manager/logz/2020-10-01/subaccount/method_listmonitoredresources.go b/resource-manager/logz/2020-10-01/subaccount/method_listmonitoredresources.go deleted file mode 100644 index a16fbcab8af..00000000000 --- a/resource-manager/logz/2020-10-01/subaccount/method_listmonitoredresources.go +++ /dev/null @@ -1,105 +0,0 @@ -package subaccount - -import ( - "context" - "fmt" - "net/http" - - "github.com/hashicorp/go-azure-sdk/sdk/client" - "github.com/hashicorp/go-azure-sdk/sdk/odata" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListMonitoredResourcesOperationResponse struct { - HttpResponse *http.Response - OData *odata.OData - Model *[]MonitoredResource -} - -type ListMonitoredResourcesCompleteResult struct { - LatestHttpResponse *http.Response - Items []MonitoredResource -} - -type ListMonitoredResourcesCustomPager struct { - NextLink *odata.Link `json:"nextLink"` -} - -func (p *ListMonitoredResourcesCustomPager) NextPageLink() *odata.Link { - defer func() { - p.NextLink = nil - }() - - return p.NextLink -} - -// ListMonitoredResources ... -func (c SubAccountClient) ListMonitoredResources(ctx context.Context, id AccountId) (result ListMonitoredResourcesOperationResponse, err error) { - opts := client.RequestOptions{ - ContentType: "application/json; charset=utf-8", - ExpectedStatusCodes: []int{ - http.StatusOK, - }, - HttpMethod: http.MethodPost, - Pager: &ListMonitoredResourcesCustomPager{}, - Path: fmt.Sprintf("%s/listMonitoredResources", id.ID()), - } - - req, err := c.Client.NewRequest(ctx, opts) - if err != nil { - return - } - - var resp *client.Response - resp, err = req.ExecutePaged(ctx) - if resp != nil { - result.OData = resp.OData - result.HttpResponse = resp.Response - } - if err != nil { - return - } - - var values struct { - Values *[]MonitoredResource `json:"value"` - } - if err = resp.Unmarshal(&values); err != nil { - return - } - - result.Model = values.Values - - return -} - -// ListMonitoredResourcesComplete retrieves all the results into a single object -func (c SubAccountClient) ListMonitoredResourcesComplete(ctx context.Context, id AccountId) (ListMonitoredResourcesCompleteResult, error) { - return c.ListMonitoredResourcesCompleteMatchingPredicate(ctx, id, MonitoredResourceOperationPredicate{}) -} - -// ListMonitoredResourcesCompleteMatchingPredicate retrieves all the results and then applies the predicate -func (c SubAccountClient) ListMonitoredResourcesCompleteMatchingPredicate(ctx context.Context, id AccountId, predicate MonitoredResourceOperationPredicate) (result ListMonitoredResourcesCompleteResult, err error) { - items := make([]MonitoredResource, 0) - - resp, err := c.ListMonitoredResources(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 = ListMonitoredResourcesCompleteResult{ - LatestHttpResponse: resp.HttpResponse, - Items: items, - } - return -} diff --git a/resource-manager/logz/2020-10-01/subaccount/model_identityproperties.go b/resource-manager/logz/2020-10-01/subaccount/model_identityproperties.go deleted file mode 100644 index 43ab184ac0a..00000000000 --- a/resource-manager/logz/2020-10-01/subaccount/model_identityproperties.go +++ /dev/null @@ -1,10 +0,0 @@ -package subaccount - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type IdentityProperties struct { - PrincipalId *string `json:"principalId,omitempty"` - TenantId *string `json:"tenantId,omitempty"` - Type *ManagedIdentityTypes `json:"type,omitempty"` -} diff --git a/resource-manager/logz/2020-10-01/subaccount/model_logzmonitorresource.go b/resource-manager/logz/2020-10-01/subaccount/model_logzmonitorresource.go deleted file mode 100644 index 451d808a5c0..00000000000 --- a/resource-manager/logz/2020-10-01/subaccount/model_logzmonitorresource.go +++ /dev/null @@ -1,19 +0,0 @@ -package subaccount - -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 LogzMonitorResource struct { - Id *string `json:"id,omitempty"` - Identity *IdentityProperties `json:"identity,omitempty"` - Location string `json:"location"` - Name *string `json:"name,omitempty"` - Properties *MonitorProperties `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/logz/2020-10-01/subaccount/model_logzmonitorresourceupdateparameters.go b/resource-manager/logz/2020-10-01/subaccount/model_logzmonitorresourceupdateparameters.go deleted file mode 100644 index d895e261522..00000000000 --- a/resource-manager/logz/2020-10-01/subaccount/model_logzmonitorresourceupdateparameters.go +++ /dev/null @@ -1,9 +0,0 @@ -package subaccount - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type LogzMonitorResourceUpdateParameters struct { - Properties *MonitorUpdateProperties `json:"properties,omitempty"` - Tags *map[string]string `json:"tags,omitempty"` -} diff --git a/resource-manager/logz/2020-10-01/subaccount/model_logzorganizationproperties.go b/resource-manager/logz/2020-10-01/subaccount/model_logzorganizationproperties.go deleted file mode 100644 index bfbdb0cbc93..00000000000 --- a/resource-manager/logz/2020-10-01/subaccount/model_logzorganizationproperties.go +++ /dev/null @@ -1,11 +0,0 @@ -package subaccount - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type LogzOrganizationProperties struct { - CompanyName *string `json:"companyName,omitempty"` - EnterpriseAppId *string `json:"enterpriseAppId,omitempty"` - Id *string `json:"id,omitempty"` - SingleSignOnURL *string `json:"singleSignOnUrl,omitempty"` -} diff --git a/resource-manager/logz/2020-10-01/subaccount/model_monitoredresource.go b/resource-manager/logz/2020-10-01/subaccount/model_monitoredresource.go deleted file mode 100644 index 19fa9006c2c..00000000000 --- a/resource-manager/logz/2020-10-01/subaccount/model_monitoredresource.go +++ /dev/null @@ -1,17 +0,0 @@ -package subaccount - -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 MonitoredResource struct { - Id *string `json:"id,omitempty"` - ReasonForLogsStatus *string `json:"reasonForLogsStatus,omitempty"` - ReasonForMetricsStatus *string `json:"reasonForMetricsStatus,omitempty"` - SendingLogs *bool `json:"sendingLogs,omitempty"` - SendingMetrics *bool `json:"sendingMetrics,omitempty"` - SystemData *systemdata.SystemData `json:"systemData,omitempty"` -} diff --git a/resource-manager/logz/2020-10-01/subaccount/model_monitorproperties.go b/resource-manager/logz/2020-10-01/subaccount/model_monitorproperties.go deleted file mode 100644 index 61b2f218495..00000000000 --- a/resource-manager/logz/2020-10-01/subaccount/model_monitorproperties.go +++ /dev/null @@ -1,15 +0,0 @@ -package subaccount - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type MonitorProperties struct { - LiftrResourceCategory *LiftrResourceCategories `json:"liftrResourceCategory,omitempty"` - LiftrResourcePreference *int64 `json:"liftrResourcePreference,omitempty"` - LogzOrganizationProperties *LogzOrganizationProperties `json:"logzOrganizationProperties,omitempty"` - MarketplaceSubscriptionStatus *MarketplaceSubscriptionStatus `json:"marketplaceSubscriptionStatus,omitempty"` - MonitoringStatus *MonitoringStatus `json:"monitoringStatus,omitempty"` - PlanData *PlanData `json:"planData,omitempty"` - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` - UserInfo *UserInfo `json:"userInfo,omitempty"` -} diff --git a/resource-manager/logz/2020-10-01/subaccount/model_plandata.go b/resource-manager/logz/2020-10-01/subaccount/model_plandata.go deleted file mode 100644 index b1c5ebea255..00000000000 --- a/resource-manager/logz/2020-10-01/subaccount/model_plandata.go +++ /dev/null @@ -1,29 +0,0 @@ -package subaccount - -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 PlanData struct { - BillingCycle *string `json:"billingCycle,omitempty"` - EffectiveDate *string `json:"effectiveDate,omitempty"` - PlanDetails *string `json:"planDetails,omitempty"` - UsageType *string `json:"usageType,omitempty"` -} - -func (o *PlanData) GetEffectiveDateAsTime() (*time.Time, error) { - if o.EffectiveDate == nil { - return nil, nil - } - return dates.ParseAsFormat(o.EffectiveDate, "2006-01-02T15:04:05Z07:00") -} - -func (o *PlanData) SetEffectiveDateAsTime(input time.Time) { - formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.EffectiveDate = &formatted -} diff --git a/resource-manager/logz/2020-10-01/subaccount/model_userinfo.go b/resource-manager/logz/2020-10-01/subaccount/model_userinfo.go deleted file mode 100644 index 52461894fb1..00000000000 --- a/resource-manager/logz/2020-10-01/subaccount/model_userinfo.go +++ /dev/null @@ -1,11 +0,0 @@ -package subaccount - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UserInfo struct { - EmailAddress *string `json:"emailAddress,omitempty"` - FirstName *string `json:"firstName,omitempty"` - LastName *string `json:"lastName,omitempty"` - PhoneNumber *string `json:"phoneNumber,omitempty"` -} diff --git a/resource-manager/logz/2020-10-01/subaccount/predicates.go b/resource-manager/logz/2020-10-01/subaccount/predicates.go deleted file mode 100644 index 70c789ddee2..00000000000 --- a/resource-manager/logz/2020-10-01/subaccount/predicates.go +++ /dev/null @@ -1,65 +0,0 @@ -package subaccount - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type LogzMonitorResourceOperationPredicate struct { - Id *string - Location *string - Name *string - Type *string -} - -func (p LogzMonitorResourceOperationPredicate) Matches(input LogzMonitorResource) bool { - - if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { - return false - } - - if p.Location != nil && *p.Location != input.Location { - return false - } - - if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { - return false - } - - if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { - return false - } - - return true -} - -type MonitoredResourceOperationPredicate struct { - Id *string - ReasonForLogsStatus *string - ReasonForMetricsStatus *string - SendingLogs *bool - SendingMetrics *bool -} - -func (p MonitoredResourceOperationPredicate) Matches(input MonitoredResource) bool { - - if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { - return false - } - - if p.ReasonForLogsStatus != nil && (input.ReasonForLogsStatus == nil || *p.ReasonForLogsStatus != *input.ReasonForLogsStatus) { - return false - } - - if p.ReasonForMetricsStatus != nil && (input.ReasonForMetricsStatus == nil || *p.ReasonForMetricsStatus != *input.ReasonForMetricsStatus) { - return false - } - - if p.SendingLogs != nil && (input.SendingLogs == nil || *p.SendingLogs != *input.SendingLogs) { - return false - } - - if p.SendingMetrics != nil && (input.SendingMetrics == nil || *p.SendingMetrics != *input.SendingMetrics) { - return false - } - - return true -} diff --git a/resource-manager/logz/2020-10-01/tagrules/README.md b/resource-manager/logz/2020-10-01/tagrules/README.md deleted file mode 100644 index bce8907750c..00000000000 --- a/resource-manager/logz/2020-10-01/tagrules/README.md +++ /dev/null @@ -1,160 +0,0 @@ - -## `github.com/hashicorp/go-azure-sdk/resource-manager/logz/2020-10-01/tagrules` Documentation - -The `tagrules` SDK allows for interaction with Azure Resource Manager `logz` (API Version `2020-10-01`). - -This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). - -### Import Path - -```go -import "github.com/hashicorp/go-azure-sdk/resource-manager/logz/2020-10-01/tagrules" -``` - - -### Client Initialization - -```go -client := tagrules.NewTagRulesClientWithBaseURI("https://management.azure.com") -client.Client.Authorizer = authorizer -``` - - -### Example Usage: `TagRulesClient.CreateOrUpdate` - -```go -ctx := context.TODO() -id := tagrules.NewTagRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName", "tagRuleName") - -payload := tagrules.MonitoringTagRules{ - // ... -} - - -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: `TagRulesClient.Delete` - -```go -ctx := context.TODO() -id := tagrules.NewTagRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName", "tagRuleName") - -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: `TagRulesClient.Get` - -```go -ctx := context.TODO() -id := tagrules.NewTagRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName", "tagRuleName") - -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: `TagRulesClient.List` - -```go -ctx := context.TODO() -id := tagrules.NewMonitorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName") - -// alternatively `client.List(ctx, id)` can be used to do batched pagination -items, err := client.ListComplete(ctx, id) -if err != nil { - // handle the error -} -for _, item := range items { - // do something -} -``` - - -### Example Usage: `TagRulesClient.SubAccountTagRulesCreateOrUpdate` - -```go -ctx := context.TODO() -id := tagrules.NewAccountTagRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName", "accountName", "tagRuleName") - -payload := tagrules.MonitoringTagRules{ - // ... -} - - -read, err := client.SubAccountTagRulesCreateOrUpdate(ctx, id, payload) -if err != nil { - // handle the error -} -if model := read.Model; model != nil { - // do something with the model/response object -} -``` - - -### Example Usage: `TagRulesClient.SubAccountTagRulesDelete` - -```go -ctx := context.TODO() -id := tagrules.NewAccountTagRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName", "accountName", "tagRuleName") - -read, err := client.SubAccountTagRulesDelete(ctx, id) -if err != nil { - // handle the error -} -if model := read.Model; model != nil { - // do something with the model/response object -} -``` - - -### Example Usage: `TagRulesClient.SubAccountTagRulesGet` - -```go -ctx := context.TODO() -id := tagrules.NewAccountTagRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName", "accountName", "tagRuleName") - -read, err := client.SubAccountTagRulesGet(ctx, id) -if err != nil { - // handle the error -} -if model := read.Model; model != nil { - // do something with the model/response object -} -``` - - -### Example Usage: `TagRulesClient.SubAccountTagRulesList` - -```go -ctx := context.TODO() -id := tagrules.NewAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName", "accountName") - -// alternatively `client.SubAccountTagRulesList(ctx, id)` can be used to do batched pagination -items, err := client.SubAccountTagRulesListComplete(ctx, id) -if err != nil { - // handle the error -} -for _, item := range items { - // do something -} -``` diff --git a/resource-manager/logz/2020-10-01/tagrules/constants.go b/resource-manager/logz/2020-10-01/tagrules/constants.go deleted file mode 100644 index 8ff2f663e0a..00000000000 --- a/resource-manager/logz/2020-10-01/tagrules/constants.go +++ /dev/null @@ -1,113 +0,0 @@ -package tagrules - -import ( - "encoding/json" - "fmt" - "strings" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ProvisioningState string - -const ( - ProvisioningStateAccepted ProvisioningState = "Accepted" - ProvisioningStateCanceled ProvisioningState = "Canceled" - ProvisioningStateCreating ProvisioningState = "Creating" - ProvisioningStateDeleted ProvisioningState = "Deleted" - ProvisioningStateDeleting ProvisioningState = "Deleting" - ProvisioningStateFailed ProvisioningState = "Failed" - ProvisioningStateNotSpecified ProvisioningState = "NotSpecified" - ProvisioningStateSucceeded ProvisioningState = "Succeeded" - ProvisioningStateUpdating ProvisioningState = "Updating" -) - -func PossibleValuesForProvisioningState() []string { - return []string{ - string(ProvisioningStateAccepted), - string(ProvisioningStateCanceled), - string(ProvisioningStateCreating), - string(ProvisioningStateDeleted), - string(ProvisioningStateDeleting), - string(ProvisioningStateFailed), - string(ProvisioningStateNotSpecified), - string(ProvisioningStateSucceeded), - string(ProvisioningStateUpdating), - } -} - -func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { - var decoded string - if err := json.Unmarshal(bytes, &decoded); err != nil { - return fmt.Errorf("unmarshaling: %+v", err) - } - out, err := parseProvisioningState(decoded) - if err != nil { - return fmt.Errorf("parsing %q: %+v", decoded, err) - } - *s = *out - return nil -} - -func parseProvisioningState(input string) (*ProvisioningState, error) { - vals := map[string]ProvisioningState{ - "accepted": ProvisioningStateAccepted, - "canceled": ProvisioningStateCanceled, - "creating": ProvisioningStateCreating, - "deleted": ProvisioningStateDeleted, - "deleting": ProvisioningStateDeleting, - "failed": ProvisioningStateFailed, - "notspecified": ProvisioningStateNotSpecified, - "succeeded": ProvisioningStateSucceeded, - "updating": ProvisioningStateUpdating, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ProvisioningState(input) - return &out, nil -} - -type TagAction string - -const ( - TagActionExclude TagAction = "Exclude" - TagActionInclude TagAction = "Include" -) - -func PossibleValuesForTagAction() []string { - return []string{ - string(TagActionExclude), - string(TagActionInclude), - } -} - -func (s *TagAction) UnmarshalJSON(bytes []byte) error { - var decoded string - if err := json.Unmarshal(bytes, &decoded); err != nil { - return fmt.Errorf("unmarshaling: %+v", err) - } - out, err := parseTagAction(decoded) - if err != nil { - return fmt.Errorf("parsing %q: %+v", decoded, err) - } - *s = *out - return nil -} - -func parseTagAction(input string) (*TagAction, error) { - vals := map[string]TagAction{ - "exclude": TagActionExclude, - "include": TagActionInclude, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := TagAction(input) - return &out, nil -} diff --git a/resource-manager/logz/2020-10-01/tagrules/id_account.go b/resource-manager/logz/2020-10-01/tagrules/id_account.go deleted file mode 100644 index 36c88bd99d6..00000000000 --- a/resource-manager/logz/2020-10-01/tagrules/id_account.go +++ /dev/null @@ -1,139 +0,0 @@ -package tagrules - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -func init() { - recaser.RegisterResourceId(&AccountId{}) -} - -var _ resourceids.ResourceId = &AccountId{} - -// AccountId is a struct representing the Resource ID for a Account -type AccountId struct { - SubscriptionId string - ResourceGroupName string - MonitorName string - AccountName string -} - -// NewAccountID returns a new AccountId struct -func NewAccountID(subscriptionId string, resourceGroupName string, monitorName string, accountName string) AccountId { - return AccountId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - MonitorName: monitorName, - AccountName: accountName, - } -} - -// ParseAccountID parses 'input' into a AccountId -func ParseAccountID(input string) (*AccountId, error) { - parser := resourceids.NewParserFromResourceIdType(&AccountId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := AccountId{} - if err = id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -// ParseAccountIDInsensitively parses 'input' case-insensitively into a AccountId -// note: this method should only be used for API response data and not user input -func ParseAccountIDInsensitively(input string) (*AccountId, error) { - parser := resourceids.NewParserFromResourceIdType(&AccountId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := AccountId{} - if err = id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -func (id *AccountId) FromParseResult(input resourceids.ParseResult) error { - var ok bool - - if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) - } - - if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) - } - - if id.MonitorName, ok = input.Parsed["monitorName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "monitorName", input) - } - - if id.AccountName, ok = input.Parsed["accountName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "accountName", input) - } - - return nil -} - -// ValidateAccountID checks that 'input' can be parsed as a Account ID -func ValidateAccountID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParseAccountID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Account ID -func (id AccountId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Logz/monitors/%s/accounts/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.MonitorName, id.AccountName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Account ID -func (id AccountId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftLogz", "Microsoft.Logz", "Microsoft.Logz"), - resourceids.StaticSegment("staticMonitors", "monitors", "monitors"), - resourceids.UserSpecifiedSegment("monitorName", "monitorName"), - resourceids.StaticSegment("staticAccounts", "accounts", "accounts"), - resourceids.UserSpecifiedSegment("accountName", "accountName"), - } -} - -// String returns a human-readable description of this Account ID -func (id AccountId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Monitor Name: %q", id.MonitorName), - fmt.Sprintf("Account Name: %q", id.AccountName), - } - return fmt.Sprintf("Account (%s)", strings.Join(components, "\n")) -} diff --git a/resource-manager/logz/2020-10-01/tagrules/id_accounttagrule.go b/resource-manager/logz/2020-10-01/tagrules/id_accounttagrule.go deleted file mode 100644 index 9e0182692dc..00000000000 --- a/resource-manager/logz/2020-10-01/tagrules/id_accounttagrule.go +++ /dev/null @@ -1,148 +0,0 @@ -package tagrules - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -func init() { - recaser.RegisterResourceId(&AccountTagRuleId{}) -} - -var _ resourceids.ResourceId = &AccountTagRuleId{} - -// AccountTagRuleId is a struct representing the Resource ID for a Account Tag Rule -type AccountTagRuleId struct { - SubscriptionId string - ResourceGroupName string - MonitorName string - AccountName string - TagRuleName string -} - -// NewAccountTagRuleID returns a new AccountTagRuleId struct -func NewAccountTagRuleID(subscriptionId string, resourceGroupName string, monitorName string, accountName string, tagRuleName string) AccountTagRuleId { - return AccountTagRuleId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - MonitorName: monitorName, - AccountName: accountName, - TagRuleName: tagRuleName, - } -} - -// ParseAccountTagRuleID parses 'input' into a AccountTagRuleId -func ParseAccountTagRuleID(input string) (*AccountTagRuleId, error) { - parser := resourceids.NewParserFromResourceIdType(&AccountTagRuleId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := AccountTagRuleId{} - if err = id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -// ParseAccountTagRuleIDInsensitively parses 'input' case-insensitively into a AccountTagRuleId -// note: this method should only be used for API response data and not user input -func ParseAccountTagRuleIDInsensitively(input string) (*AccountTagRuleId, error) { - parser := resourceids.NewParserFromResourceIdType(&AccountTagRuleId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := AccountTagRuleId{} - if err = id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -func (id *AccountTagRuleId) FromParseResult(input resourceids.ParseResult) error { - var ok bool - - if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) - } - - if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) - } - - if id.MonitorName, ok = input.Parsed["monitorName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "monitorName", input) - } - - if id.AccountName, ok = input.Parsed["accountName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "accountName", input) - } - - if id.TagRuleName, ok = input.Parsed["tagRuleName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "tagRuleName", input) - } - - return nil -} - -// ValidateAccountTagRuleID checks that 'input' can be parsed as a Account Tag Rule ID -func ValidateAccountTagRuleID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParseAccountTagRuleID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Account Tag Rule ID -func (id AccountTagRuleId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Logz/monitors/%s/accounts/%s/tagRules/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.MonitorName, id.AccountName, id.TagRuleName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Account Tag Rule ID -func (id AccountTagRuleId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftLogz", "Microsoft.Logz", "Microsoft.Logz"), - resourceids.StaticSegment("staticMonitors", "monitors", "monitors"), - resourceids.UserSpecifiedSegment("monitorName", "monitorName"), - resourceids.StaticSegment("staticAccounts", "accounts", "accounts"), - resourceids.UserSpecifiedSegment("accountName", "accountName"), - resourceids.StaticSegment("staticTagRules", "tagRules", "tagRules"), - resourceids.UserSpecifiedSegment("tagRuleName", "tagRuleName"), - } -} - -// String returns a human-readable description of this Account Tag Rule ID -func (id AccountTagRuleId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Monitor Name: %q", id.MonitorName), - fmt.Sprintf("Account Name: %q", id.AccountName), - fmt.Sprintf("Tag Rule Name: %q", id.TagRuleName), - } - return fmt.Sprintf("Account Tag Rule (%s)", strings.Join(components, "\n")) -} diff --git a/resource-manager/logz/2020-10-01/tagrules/id_accounttagrule_test.go b/resource-manager/logz/2020-10-01/tagrules/id_accounttagrule_test.go deleted file mode 100644 index 77ea386733a..00000000000 --- a/resource-manager/logz/2020-10-01/tagrules/id_accounttagrule_test.go +++ /dev/null @@ -1,372 +0,0 @@ -package tagrules - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -var _ resourceids.ResourceId = &AccountTagRuleId{} - -func TestNewAccountTagRuleID(t *testing.T) { - id := NewAccountTagRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName", "accountName", "tagRuleName") - - if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { - t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") - } - - if id.ResourceGroupName != "example-resource-group" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") - } - - if id.MonitorName != "monitorName" { - t.Fatalf("Expected %q but got %q for Segment 'MonitorName'", id.MonitorName, "monitorName") - } - - if id.AccountName != "accountName" { - t.Fatalf("Expected %q but got %q for Segment 'AccountName'", id.AccountName, "accountName") - } - - if id.TagRuleName != "tagRuleName" { - t.Fatalf("Expected %q but got %q for Segment 'TagRuleName'", id.TagRuleName, "tagRuleName") - } -} - -func TestFormatAccountTagRuleID(t *testing.T) { - actual := NewAccountTagRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName", "accountName", "tagRuleName").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/accounts/accountName/tagRules/tagRuleName" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseAccountTagRuleID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *AccountTagRuleId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/accounts", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/accounts/accountName", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/accounts/accountName/tagRules", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/accounts/accountName/tagRules/tagRuleName", - Expected: &AccountTagRuleId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - MonitorName: "monitorName", - AccountName: "accountName", - TagRuleName: "tagRuleName", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/accounts/accountName/tagRules/tagRuleName/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseAccountTagRuleID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.MonitorName != v.Expected.MonitorName { - t.Fatalf("Expected %q but got %q for MonitorName", v.Expected.MonitorName, actual.MonitorName) - } - - if actual.AccountName != v.Expected.AccountName { - t.Fatalf("Expected %q but got %q for AccountName", v.Expected.AccountName, actual.AccountName) - } - - if actual.TagRuleName != v.Expected.TagRuleName { - t.Fatalf("Expected %q but got %q for TagRuleName", v.Expected.TagRuleName, actual.TagRuleName) - } - - } -} - -func TestParseAccountTagRuleIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *AccountTagRuleId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ/mOnItOrS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ/mOnItOrS/mOnItOrNaMe", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/accounts", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ/mOnItOrS/mOnItOrNaMe/aCcOuNtS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/accounts/accountName", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ/mOnItOrS/mOnItOrNaMe/aCcOuNtS/aCcOuNtNaMe", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/accounts/accountName/tagRules", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ/mOnItOrS/mOnItOrNaMe/aCcOuNtS/aCcOuNtNaMe/tAgRuLeS", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/accounts/accountName/tagRules/tagRuleName", - Expected: &AccountTagRuleId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - MonitorName: "monitorName", - AccountName: "accountName", - TagRuleName: "tagRuleName", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/accounts/accountName/tagRules/tagRuleName/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ/mOnItOrS/mOnItOrNaMe/aCcOuNtS/aCcOuNtNaMe/tAgRuLeS/tAgRuLeNaMe", - Expected: &AccountTagRuleId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - MonitorName: "mOnItOrNaMe", - AccountName: "aCcOuNtNaMe", - TagRuleName: "tAgRuLeNaMe", - }, - }, - { - // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ/mOnItOrS/mOnItOrNaMe/aCcOuNtS/aCcOuNtNaMe/tAgRuLeS/tAgRuLeNaMe/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseAccountTagRuleIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.MonitorName != v.Expected.MonitorName { - t.Fatalf("Expected %q but got %q for MonitorName", v.Expected.MonitorName, actual.MonitorName) - } - - if actual.AccountName != v.Expected.AccountName { - t.Fatalf("Expected %q but got %q for AccountName", v.Expected.AccountName, actual.AccountName) - } - - if actual.TagRuleName != v.Expected.TagRuleName { - t.Fatalf("Expected %q but got %q for TagRuleName", v.Expected.TagRuleName, actual.TagRuleName) - } - - } -} - -func TestSegmentsForAccountTagRuleId(t *testing.T) { - segments := AccountTagRuleId{}.Segments() - if len(segments) == 0 { - t.Fatalf("AccountTagRuleId has no segments") - } - - uniqueNames := make(map[string]struct{}, 0) - for _, segment := range segments { - uniqueNames[segment.Name] = struct{}{} - } - if len(uniqueNames) != len(segments) { - t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) - } -} diff --git a/resource-manager/logz/2020-10-01/tagrules/id_monitor.go b/resource-manager/logz/2020-10-01/tagrules/id_monitor.go deleted file mode 100644 index b515baae1b2..00000000000 --- a/resource-manager/logz/2020-10-01/tagrules/id_monitor.go +++ /dev/null @@ -1,130 +0,0 @@ -package tagrules - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -func init() { - recaser.RegisterResourceId(&MonitorId{}) -} - -var _ resourceids.ResourceId = &MonitorId{} - -// MonitorId is a struct representing the Resource ID for a Monitor -type MonitorId struct { - SubscriptionId string - ResourceGroupName string - MonitorName string -} - -// NewMonitorID returns a new MonitorId struct -func NewMonitorID(subscriptionId string, resourceGroupName string, monitorName string) MonitorId { - return MonitorId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - MonitorName: monitorName, - } -} - -// ParseMonitorID parses 'input' into a MonitorId -func ParseMonitorID(input string) (*MonitorId, error) { - parser := resourceids.NewParserFromResourceIdType(&MonitorId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := MonitorId{} - if err = id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -// ParseMonitorIDInsensitively parses 'input' case-insensitively into a MonitorId -// note: this method should only be used for API response data and not user input -func ParseMonitorIDInsensitively(input string) (*MonitorId, error) { - parser := resourceids.NewParserFromResourceIdType(&MonitorId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := MonitorId{} - if err = id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -func (id *MonitorId) FromParseResult(input resourceids.ParseResult) error { - var ok bool - - if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) - } - - if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) - } - - if id.MonitorName, ok = input.Parsed["monitorName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "monitorName", input) - } - - return nil -} - -// ValidateMonitorID checks that 'input' can be parsed as a Monitor ID -func ValidateMonitorID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParseMonitorID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Monitor ID -func (id MonitorId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Logz/monitors/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.MonitorName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Monitor ID -func (id MonitorId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftLogz", "Microsoft.Logz", "Microsoft.Logz"), - resourceids.StaticSegment("staticMonitors", "monitors", "monitors"), - resourceids.UserSpecifiedSegment("monitorName", "monitorName"), - } -} - -// String returns a human-readable description of this Monitor ID -func (id MonitorId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Monitor Name: %q", id.MonitorName), - } - return fmt.Sprintf("Monitor (%s)", strings.Join(components, "\n")) -} diff --git a/resource-manager/logz/2020-10-01/tagrules/id_tagrule.go b/resource-manager/logz/2020-10-01/tagrules/id_tagrule.go deleted file mode 100644 index 88465496384..00000000000 --- a/resource-manager/logz/2020-10-01/tagrules/id_tagrule.go +++ /dev/null @@ -1,139 +0,0 @@ -package tagrules - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -func init() { - recaser.RegisterResourceId(&TagRuleId{}) -} - -var _ resourceids.ResourceId = &TagRuleId{} - -// TagRuleId is a struct representing the Resource ID for a Tag Rule -type TagRuleId struct { - SubscriptionId string - ResourceGroupName string - MonitorName string - TagRuleName string -} - -// NewTagRuleID returns a new TagRuleId struct -func NewTagRuleID(subscriptionId string, resourceGroupName string, monitorName string, tagRuleName string) TagRuleId { - return TagRuleId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - MonitorName: monitorName, - TagRuleName: tagRuleName, - } -} - -// ParseTagRuleID parses 'input' into a TagRuleId -func ParseTagRuleID(input string) (*TagRuleId, error) { - parser := resourceids.NewParserFromResourceIdType(&TagRuleId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := TagRuleId{} - if err = id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -// ParseTagRuleIDInsensitively parses 'input' case-insensitively into a TagRuleId -// note: this method should only be used for API response data and not user input -func ParseTagRuleIDInsensitively(input string) (*TagRuleId, error) { - parser := resourceids.NewParserFromResourceIdType(&TagRuleId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := TagRuleId{} - if err = id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -func (id *TagRuleId) FromParseResult(input resourceids.ParseResult) error { - var ok bool - - if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) - } - - if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) - } - - if id.MonitorName, ok = input.Parsed["monitorName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "monitorName", input) - } - - if id.TagRuleName, ok = input.Parsed["tagRuleName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "tagRuleName", input) - } - - return nil -} - -// ValidateTagRuleID checks that 'input' can be parsed as a Tag Rule ID -func ValidateTagRuleID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParseTagRuleID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Tag Rule ID -func (id TagRuleId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Logz/monitors/%s/tagRules/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.MonitorName, id.TagRuleName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Tag Rule ID -func (id TagRuleId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftLogz", "Microsoft.Logz", "Microsoft.Logz"), - resourceids.StaticSegment("staticMonitors", "monitors", "monitors"), - resourceids.UserSpecifiedSegment("monitorName", "monitorName"), - resourceids.StaticSegment("staticTagRules", "tagRules", "tagRules"), - resourceids.UserSpecifiedSegment("tagRuleName", "tagRuleName"), - } -} - -// String returns a human-readable description of this Tag Rule ID -func (id TagRuleId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Monitor Name: %q", id.MonitorName), - fmt.Sprintf("Tag Rule Name: %q", id.TagRuleName), - } - return fmt.Sprintf("Tag Rule (%s)", strings.Join(components, "\n")) -} diff --git a/resource-manager/logz/2020-10-01/tagrules/method_list.go b/resource-manager/logz/2020-10-01/tagrules/method_list.go deleted file mode 100644 index 7a91120b4e3..00000000000 --- a/resource-manager/logz/2020-10-01/tagrules/method_list.go +++ /dev/null @@ -1,105 +0,0 @@ -package tagrules - -import ( - "context" - "fmt" - "net/http" - - "github.com/hashicorp/go-azure-sdk/sdk/client" - "github.com/hashicorp/go-azure-sdk/sdk/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 *[]MonitoringTagRules -} - -type ListCompleteResult struct { - LatestHttpResponse *http.Response - Items []MonitoringTagRules -} - -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 TagRulesClient) List(ctx context.Context, id MonitorId) (result ListOperationResponse, err error) { - opts := client.RequestOptions{ - ContentType: "application/json; charset=utf-8", - ExpectedStatusCodes: []int{ - http.StatusOK, - }, - HttpMethod: http.MethodGet, - Pager: &ListCustomPager{}, - Path: fmt.Sprintf("%s/tagRules", id.ID()), - } - - req, err := c.Client.NewRequest(ctx, opts) - if err != nil { - return - } - - var resp *client.Response - resp, err = req.ExecutePaged(ctx) - if resp != nil { - result.OData = resp.OData - result.HttpResponse = resp.Response - } - if err != nil { - return - } - - var values struct { - Values *[]MonitoringTagRules `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 TagRulesClient) ListComplete(ctx context.Context, id MonitorId) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, MonitoringTagRulesOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate -func (c TagRulesClient) ListCompleteMatchingPredicate(ctx context.Context, id MonitorId, predicate MonitoringTagRulesOperationPredicate) (result ListCompleteResult, err error) { - items := make([]MonitoringTagRules, 0) - - resp, err := c.List(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 = ListCompleteResult{ - LatestHttpResponse: resp.HttpResponse, - Items: items, - } - return -} diff --git a/resource-manager/logz/2020-10-01/tagrules/method_subaccounttagrulesget.go b/resource-manager/logz/2020-10-01/tagrules/method_subaccounttagrulesget.go deleted file mode 100644 index b94f6ec9a24..00000000000 --- a/resource-manager/logz/2020-10-01/tagrules/method_subaccounttagrulesget.go +++ /dev/null @@ -1,53 +0,0 @@ -package tagrules - -import ( - "context" - "net/http" - - "github.com/hashicorp/go-azure-sdk/sdk/client" - "github.com/hashicorp/go-azure-sdk/sdk/odata" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type SubAccountTagRulesGetOperationResponse struct { - HttpResponse *http.Response - OData *odata.OData - Model *MonitoringTagRules -} - -// SubAccountTagRulesGet ... -func (c TagRulesClient) SubAccountTagRulesGet(ctx context.Context, id AccountTagRuleId) (result SubAccountTagRulesGetOperationResponse, 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 MonitoringTagRules - result.Model = &model - if err = resp.Unmarshal(result.Model); err != nil { - return - } - - return -} diff --git a/resource-manager/logz/2020-10-01/tagrules/method_subaccounttagruleslist.go b/resource-manager/logz/2020-10-01/tagrules/method_subaccounttagruleslist.go deleted file mode 100644 index 39485b0dd4a..00000000000 --- a/resource-manager/logz/2020-10-01/tagrules/method_subaccounttagruleslist.go +++ /dev/null @@ -1,105 +0,0 @@ -package tagrules - -import ( - "context" - "fmt" - "net/http" - - "github.com/hashicorp/go-azure-sdk/sdk/client" - "github.com/hashicorp/go-azure-sdk/sdk/odata" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type SubAccountTagRulesListOperationResponse struct { - HttpResponse *http.Response - OData *odata.OData - Model *[]MonitoringTagRules -} - -type SubAccountTagRulesListCompleteResult struct { - LatestHttpResponse *http.Response - Items []MonitoringTagRules -} - -type SubAccountTagRulesListCustomPager struct { - NextLink *odata.Link `json:"nextLink"` -} - -func (p *SubAccountTagRulesListCustomPager) NextPageLink() *odata.Link { - defer func() { - p.NextLink = nil - }() - - return p.NextLink -} - -// SubAccountTagRulesList ... -func (c TagRulesClient) SubAccountTagRulesList(ctx context.Context, id AccountId) (result SubAccountTagRulesListOperationResponse, err error) { - opts := client.RequestOptions{ - ContentType: "application/json; charset=utf-8", - ExpectedStatusCodes: []int{ - http.StatusOK, - }, - HttpMethod: http.MethodGet, - Pager: &SubAccountTagRulesListCustomPager{}, - Path: fmt.Sprintf("%s/tagRules", id.ID()), - } - - req, err := c.Client.NewRequest(ctx, opts) - if err != nil { - return - } - - var resp *client.Response - resp, err = req.ExecutePaged(ctx) - if resp != nil { - result.OData = resp.OData - result.HttpResponse = resp.Response - } - if err != nil { - return - } - - var values struct { - Values *[]MonitoringTagRules `json:"value"` - } - if err = resp.Unmarshal(&values); err != nil { - return - } - - result.Model = values.Values - - return -} - -// SubAccountTagRulesListComplete retrieves all the results into a single object -func (c TagRulesClient) SubAccountTagRulesListComplete(ctx context.Context, id AccountId) (SubAccountTagRulesListCompleteResult, error) { - return c.SubAccountTagRulesListCompleteMatchingPredicate(ctx, id, MonitoringTagRulesOperationPredicate{}) -} - -// SubAccountTagRulesListCompleteMatchingPredicate retrieves all the results and then applies the predicate -func (c TagRulesClient) SubAccountTagRulesListCompleteMatchingPredicate(ctx context.Context, id AccountId, predicate MonitoringTagRulesOperationPredicate) (result SubAccountTagRulesListCompleteResult, err error) { - items := make([]MonitoringTagRules, 0) - - resp, err := c.SubAccountTagRulesList(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 = SubAccountTagRulesListCompleteResult{ - LatestHttpResponse: resp.HttpResponse, - Items: items, - } - return -} diff --git a/resource-manager/logz/2020-10-01/tagrules/model_filteringtag.go b/resource-manager/logz/2020-10-01/tagrules/model_filteringtag.go deleted file mode 100644 index 13b1c7f0b87..00000000000 --- a/resource-manager/logz/2020-10-01/tagrules/model_filteringtag.go +++ /dev/null @@ -1,10 +0,0 @@ -package tagrules - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type FilteringTag struct { - Action *TagAction `json:"action,omitempty"` - Name *string `json:"name,omitempty"` - Value *string `json:"value,omitempty"` -} diff --git a/resource-manager/logz/2020-10-01/tagrules/model_logrules.go b/resource-manager/logz/2020-10-01/tagrules/model_logrules.go deleted file mode 100644 index 376b3049d14..00000000000 --- a/resource-manager/logz/2020-10-01/tagrules/model_logrules.go +++ /dev/null @@ -1,11 +0,0 @@ -package tagrules - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type LogRules struct { - FilteringTags *[]FilteringTag `json:"filteringTags,omitempty"` - SendAadLogs *bool `json:"sendAadLogs,omitempty"` - SendActivityLogs *bool `json:"sendActivityLogs,omitempty"` - SendSubscriptionLogs *bool `json:"sendSubscriptionLogs,omitempty"` -} diff --git a/resource-manager/logz/2020-10-01/tagrules/model_monitoringtagrules.go b/resource-manager/logz/2020-10-01/tagrules/model_monitoringtagrules.go deleted file mode 100644 index d30479db23b..00000000000 --- a/resource-manager/logz/2020-10-01/tagrules/model_monitoringtagrules.go +++ /dev/null @@ -1,16 +0,0 @@ -package tagrules - -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 MonitoringTagRules struct { - Id *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Properties *MonitoringTagRulesProperties `json:"properties,omitempty"` - SystemData *systemdata.SystemData `json:"systemData,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/resource-manager/logz/2020-10-01/tagrules/model_monitoringtagrulesproperties.go b/resource-manager/logz/2020-10-01/tagrules/model_monitoringtagrulesproperties.go deleted file mode 100644 index 46e51999784..00000000000 --- a/resource-manager/logz/2020-10-01/tagrules/model_monitoringtagrulesproperties.go +++ /dev/null @@ -1,14 +0,0 @@ -package tagrules - -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 MonitoringTagRulesProperties struct { - LogRules *LogRules `json:"logRules,omitempty"` - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` - SystemData *systemdata.SystemData `json:"systemData,omitempty"` -} diff --git a/resource-manager/logz/2020-10-01/vmhost/README.md b/resource-manager/logz/2020-10-01/vmhost/README.md deleted file mode 100644 index e2600254e78..00000000000 --- a/resource-manager/logz/2020-10-01/vmhost/README.md +++ /dev/null @@ -1,130 +0,0 @@ - -## `github.com/hashicorp/go-azure-sdk/resource-manager/logz/2020-10-01/vmhost` Documentation - -The `vmhost` SDK allows for interaction with Azure Resource Manager `logz` (API Version `2020-10-01`). - -This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). - -### Import Path - -```go -import "github.com/hashicorp/go-azure-sdk/resource-manager/logz/2020-10-01/vmhost" -``` - - -### Client Initialization - -```go -client := vmhost.NewVMHostClientWithBaseURI("https://management.azure.com") -client.Client.Authorizer = authorizer -``` - - -### Example Usage: `VMHostClient.MonitorListVMHostUpdate` - -```go -ctx := context.TODO() -id := vmhost.NewMonitorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName") - -payload := vmhost.VMHostUpdateRequest{ - // ... -} - - -// alternatively `client.MonitorListVMHostUpdate(ctx, id, payload)` can be used to do batched pagination -items, err := client.MonitorListVMHostUpdateComplete(ctx, id, payload) -if err != nil { - // handle the error -} -for _, item := range items { - // do something -} -``` - - -### Example Usage: `VMHostClient.MonitorListVMHosts` - -```go -ctx := context.TODO() -id := vmhost.NewMonitorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName") - -// alternatively `client.MonitorListVMHosts(ctx, id)` can be used to do batched pagination -items, err := client.MonitorListVMHostsComplete(ctx, id) -if err != nil { - // handle the error -} -for _, item := range items { - // do something -} -``` - - -### Example Usage: `VMHostClient.MonitorVMHostPayload` - -```go -ctx := context.TODO() -id := vmhost.NewMonitorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName") - -read, err := client.MonitorVMHostPayload(ctx, id) -if err != nil { - // handle the error -} -if model := read.Model; model != nil { - // do something with the model/response object -} -``` - - -### Example Usage: `VMHostClient.SubAccountListVMHostUpdate` - -```go -ctx := context.TODO() -id := vmhost.NewAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName", "accountName") - -payload := vmhost.VMHostUpdateRequest{ - // ... -} - - -// alternatively `client.SubAccountListVMHostUpdate(ctx, id, payload)` can be used to do batched pagination -items, err := client.SubAccountListVMHostUpdateComplete(ctx, id, payload) -if err != nil { - // handle the error -} -for _, item := range items { - // do something -} -``` - - -### Example Usage: `VMHostClient.SubAccountListVMHosts` - -```go -ctx := context.TODO() -id := vmhost.NewAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName", "accountName") - -// alternatively `client.SubAccountListVMHosts(ctx, id)` can be used to do batched pagination -items, err := client.SubAccountListVMHostsComplete(ctx, id) -if err != nil { - // handle the error -} -for _, item := range items { - // do something -} -``` - - -### Example Usage: `VMHostClient.SubAccountVMHostPayload` - -```go -ctx := context.TODO() -id := vmhost.NewAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName", "accountName") - -read, err := client.SubAccountVMHostPayload(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/logz/2020-10-01/vmhost/constants.go b/resource-manager/logz/2020-10-01/vmhost/constants.go deleted file mode 100644 index 3d89e42cd2f..00000000000 --- a/resource-manager/logz/2020-10-01/vmhost/constants.go +++ /dev/null @@ -1,51 +0,0 @@ -package vmhost - -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 VMHostUpdateStates string - -const ( - VMHostUpdateStatesDelete VMHostUpdateStates = "Delete" - VMHostUpdateStatesInstall VMHostUpdateStates = "Install" -) - -func PossibleValuesForVMHostUpdateStates() []string { - return []string{ - string(VMHostUpdateStatesDelete), - string(VMHostUpdateStatesInstall), - } -} - -func (s *VMHostUpdateStates) UnmarshalJSON(bytes []byte) error { - var decoded string - if err := json.Unmarshal(bytes, &decoded); err != nil { - return fmt.Errorf("unmarshaling: %+v", err) - } - out, err := parseVMHostUpdateStates(decoded) - if err != nil { - return fmt.Errorf("parsing %q: %+v", decoded, err) - } - *s = *out - return nil -} - -func parseVMHostUpdateStates(input string) (*VMHostUpdateStates, error) { - vals := map[string]VMHostUpdateStates{ - "delete": VMHostUpdateStatesDelete, - "install": VMHostUpdateStatesInstall, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := VMHostUpdateStates(input) - return &out, nil -} diff --git a/resource-manager/logz/2020-10-01/vmhost/id_account.go b/resource-manager/logz/2020-10-01/vmhost/id_account.go deleted file mode 100644 index 3fe8bdcc52a..00000000000 --- a/resource-manager/logz/2020-10-01/vmhost/id_account.go +++ /dev/null @@ -1,139 +0,0 @@ -package vmhost - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -func init() { - recaser.RegisterResourceId(&AccountId{}) -} - -var _ resourceids.ResourceId = &AccountId{} - -// AccountId is a struct representing the Resource ID for a Account -type AccountId struct { - SubscriptionId string - ResourceGroupName string - MonitorName string - AccountName string -} - -// NewAccountID returns a new AccountId struct -func NewAccountID(subscriptionId string, resourceGroupName string, monitorName string, accountName string) AccountId { - return AccountId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - MonitorName: monitorName, - AccountName: accountName, - } -} - -// ParseAccountID parses 'input' into a AccountId -func ParseAccountID(input string) (*AccountId, error) { - parser := resourceids.NewParserFromResourceIdType(&AccountId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := AccountId{} - if err = id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -// ParseAccountIDInsensitively parses 'input' case-insensitively into a AccountId -// note: this method should only be used for API response data and not user input -func ParseAccountIDInsensitively(input string) (*AccountId, error) { - parser := resourceids.NewParserFromResourceIdType(&AccountId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := AccountId{} - if err = id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -func (id *AccountId) FromParseResult(input resourceids.ParseResult) error { - var ok bool - - if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) - } - - if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) - } - - if id.MonitorName, ok = input.Parsed["monitorName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "monitorName", input) - } - - if id.AccountName, ok = input.Parsed["accountName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "accountName", input) - } - - return nil -} - -// ValidateAccountID checks that 'input' can be parsed as a Account ID -func ValidateAccountID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParseAccountID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Account ID -func (id AccountId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Logz/monitors/%s/accounts/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.MonitorName, id.AccountName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Account ID -func (id AccountId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftLogz", "Microsoft.Logz", "Microsoft.Logz"), - resourceids.StaticSegment("staticMonitors", "monitors", "monitors"), - resourceids.UserSpecifiedSegment("monitorName", "monitorName"), - resourceids.StaticSegment("staticAccounts", "accounts", "accounts"), - resourceids.UserSpecifiedSegment("accountName", "accountName"), - } -} - -// String returns a human-readable description of this Account ID -func (id AccountId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Monitor Name: %q", id.MonitorName), - fmt.Sprintf("Account Name: %q", id.AccountName), - } - return fmt.Sprintf("Account (%s)", strings.Join(components, "\n")) -} diff --git a/resource-manager/logz/2020-10-01/vmhost/id_account_test.go b/resource-manager/logz/2020-10-01/vmhost/id_account_test.go deleted file mode 100644 index f2653f3ae62..00000000000 --- a/resource-manager/logz/2020-10-01/vmhost/id_account_test.go +++ /dev/null @@ -1,327 +0,0 @@ -package vmhost - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -var _ resourceids.ResourceId = &AccountId{} - -func TestNewAccountID(t *testing.T) { - id := NewAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName", "accountName") - - if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { - t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") - } - - if id.ResourceGroupName != "example-resource-group" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") - } - - if id.MonitorName != "monitorName" { - t.Fatalf("Expected %q but got %q for Segment 'MonitorName'", id.MonitorName, "monitorName") - } - - if id.AccountName != "accountName" { - t.Fatalf("Expected %q but got %q for Segment 'AccountName'", id.AccountName, "accountName") - } -} - -func TestFormatAccountID(t *testing.T) { - actual := NewAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName", "accountName").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/accounts/accountName" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseAccountID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *AccountId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/accounts", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/accounts/accountName", - Expected: &AccountId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - MonitorName: "monitorName", - AccountName: "accountName", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/accounts/accountName/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseAccountID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.MonitorName != v.Expected.MonitorName { - t.Fatalf("Expected %q but got %q for MonitorName", v.Expected.MonitorName, actual.MonitorName) - } - - if actual.AccountName != v.Expected.AccountName { - t.Fatalf("Expected %q but got %q for AccountName", v.Expected.AccountName, actual.AccountName) - } - - } -} - -func TestParseAccountIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *AccountId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ/mOnItOrS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ/mOnItOrS/mOnItOrNaMe", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/accounts", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ/mOnItOrS/mOnItOrNaMe/aCcOuNtS", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/accounts/accountName", - Expected: &AccountId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - MonitorName: "monitorName", - AccountName: "accountName", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/accounts/accountName/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ/mOnItOrS/mOnItOrNaMe/aCcOuNtS/aCcOuNtNaMe", - Expected: &AccountId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - MonitorName: "mOnItOrNaMe", - AccountName: "aCcOuNtNaMe", - }, - }, - { - // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ/mOnItOrS/mOnItOrNaMe/aCcOuNtS/aCcOuNtNaMe/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseAccountIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.MonitorName != v.Expected.MonitorName { - t.Fatalf("Expected %q but got %q for MonitorName", v.Expected.MonitorName, actual.MonitorName) - } - - if actual.AccountName != v.Expected.AccountName { - t.Fatalf("Expected %q but got %q for AccountName", v.Expected.AccountName, actual.AccountName) - } - - } -} - -func TestSegmentsForAccountId(t *testing.T) { - segments := AccountId{}.Segments() - if len(segments) == 0 { - t.Fatalf("AccountId has no segments") - } - - uniqueNames := make(map[string]struct{}, 0) - for _, segment := range segments { - uniqueNames[segment.Name] = struct{}{} - } - if len(uniqueNames) != len(segments) { - t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) - } -} diff --git a/resource-manager/logz/2020-10-01/vmhost/id_monitor.go b/resource-manager/logz/2020-10-01/vmhost/id_monitor.go deleted file mode 100644 index dd10e3d45a4..00000000000 --- a/resource-manager/logz/2020-10-01/vmhost/id_monitor.go +++ /dev/null @@ -1,130 +0,0 @@ -package vmhost - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -func init() { - recaser.RegisterResourceId(&MonitorId{}) -} - -var _ resourceids.ResourceId = &MonitorId{} - -// MonitorId is a struct representing the Resource ID for a Monitor -type MonitorId struct { - SubscriptionId string - ResourceGroupName string - MonitorName string -} - -// NewMonitorID returns a new MonitorId struct -func NewMonitorID(subscriptionId string, resourceGroupName string, monitorName string) MonitorId { - return MonitorId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - MonitorName: monitorName, - } -} - -// ParseMonitorID parses 'input' into a MonitorId -func ParseMonitorID(input string) (*MonitorId, error) { - parser := resourceids.NewParserFromResourceIdType(&MonitorId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := MonitorId{} - if err = id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -// ParseMonitorIDInsensitively parses 'input' case-insensitively into a MonitorId -// note: this method should only be used for API response data and not user input -func ParseMonitorIDInsensitively(input string) (*MonitorId, error) { - parser := resourceids.NewParserFromResourceIdType(&MonitorId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := MonitorId{} - if err = id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -func (id *MonitorId) FromParseResult(input resourceids.ParseResult) error { - var ok bool - - if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) - } - - if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) - } - - if id.MonitorName, ok = input.Parsed["monitorName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "monitorName", input) - } - - return nil -} - -// ValidateMonitorID checks that 'input' can be parsed as a Monitor ID -func ValidateMonitorID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParseMonitorID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Monitor ID -func (id MonitorId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Logz/monitors/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.MonitorName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Monitor ID -func (id MonitorId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftLogz", "Microsoft.Logz", "Microsoft.Logz"), - resourceids.StaticSegment("staticMonitors", "monitors", "monitors"), - resourceids.UserSpecifiedSegment("monitorName", "monitorName"), - } -} - -// String returns a human-readable description of this Monitor ID -func (id MonitorId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Monitor Name: %q", id.MonitorName), - } - return fmt.Sprintf("Monitor (%s)", strings.Join(components, "\n")) -} diff --git a/resource-manager/logz/2020-10-01/vmhost/id_monitor_test.go b/resource-manager/logz/2020-10-01/vmhost/id_monitor_test.go deleted file mode 100644 index ebcfa273bfa..00000000000 --- a/resource-manager/logz/2020-10-01/vmhost/id_monitor_test.go +++ /dev/null @@ -1,282 +0,0 @@ -package vmhost - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -var _ resourceids.ResourceId = &MonitorId{} - -func TestNewMonitorID(t *testing.T) { - id := NewMonitorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName") - - if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { - t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") - } - - if id.ResourceGroupName != "example-resource-group" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") - } - - if id.MonitorName != "monitorName" { - t.Fatalf("Expected %q but got %q for Segment 'MonitorName'", id.MonitorName, "monitorName") - } -} - -func TestFormatMonitorID(t *testing.T) { - actual := NewMonitorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseMonitorID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *MonitorId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName", - Expected: &MonitorId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - MonitorName: "monitorName", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseMonitorID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.MonitorName != v.Expected.MonitorName { - t.Fatalf("Expected %q but got %q for MonitorName", v.Expected.MonitorName, actual.MonitorName) - } - - } -} - -func TestParseMonitorIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *MonitorId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ/mOnItOrS", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName", - Expected: &MonitorId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - MonitorName: "monitorName", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ/mOnItOrS/mOnItOrNaMe", - Expected: &MonitorId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - MonitorName: "mOnItOrNaMe", - }, - }, - { - // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ/mOnItOrS/mOnItOrNaMe/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseMonitorIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.MonitorName != v.Expected.MonitorName { - t.Fatalf("Expected %q but got %q for MonitorName", v.Expected.MonitorName, actual.MonitorName) - } - - } -} - -func TestSegmentsForMonitorId(t *testing.T) { - segments := MonitorId{}.Segments() - if len(segments) == 0 { - t.Fatalf("MonitorId has no segments") - } - - uniqueNames := make(map[string]struct{}, 0) - for _, segment := range segments { - uniqueNames[segment.Name] = struct{}{} - } - if len(uniqueNames) != len(segments) { - t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) - } -} diff --git a/resource-manager/logz/2020-10-01/vmhost/method_monitorlistvmhosts.go b/resource-manager/logz/2020-10-01/vmhost/method_monitorlistvmhosts.go deleted file mode 100644 index 5249acb4894..00000000000 --- a/resource-manager/logz/2020-10-01/vmhost/method_monitorlistvmhosts.go +++ /dev/null @@ -1,105 +0,0 @@ -package vmhost - -import ( - "context" - "fmt" - "net/http" - - "github.com/hashicorp/go-azure-sdk/sdk/client" - "github.com/hashicorp/go-azure-sdk/sdk/odata" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type MonitorListVMHostsOperationResponse struct { - HttpResponse *http.Response - OData *odata.OData - Model *[]VMResources -} - -type MonitorListVMHostsCompleteResult struct { - LatestHttpResponse *http.Response - Items []VMResources -} - -type MonitorListVMHostsCustomPager struct { - NextLink *odata.Link `json:"nextLink"` -} - -func (p *MonitorListVMHostsCustomPager) NextPageLink() *odata.Link { - defer func() { - p.NextLink = nil - }() - - return p.NextLink -} - -// MonitorListVMHosts ... -func (c VMHostClient) MonitorListVMHosts(ctx context.Context, id MonitorId) (result MonitorListVMHostsOperationResponse, err error) { - opts := client.RequestOptions{ - ContentType: "application/json; charset=utf-8", - ExpectedStatusCodes: []int{ - http.StatusOK, - }, - HttpMethod: http.MethodPost, - Pager: &MonitorListVMHostsCustomPager{}, - Path: fmt.Sprintf("%s/listVMHosts", id.ID()), - } - - req, err := c.Client.NewRequest(ctx, opts) - if err != nil { - return - } - - var resp *client.Response - resp, err = req.ExecutePaged(ctx) - if resp != nil { - result.OData = resp.OData - result.HttpResponse = resp.Response - } - if err != nil { - return - } - - var values struct { - Values *[]VMResources `json:"value"` - } - if err = resp.Unmarshal(&values); err != nil { - return - } - - result.Model = values.Values - - return -} - -// MonitorListVMHostsComplete retrieves all the results into a single object -func (c VMHostClient) MonitorListVMHostsComplete(ctx context.Context, id MonitorId) (MonitorListVMHostsCompleteResult, error) { - return c.MonitorListVMHostsCompleteMatchingPredicate(ctx, id, VMResourcesOperationPredicate{}) -} - -// MonitorListVMHostsCompleteMatchingPredicate retrieves all the results and then applies the predicate -func (c VMHostClient) MonitorListVMHostsCompleteMatchingPredicate(ctx context.Context, id MonitorId, predicate VMResourcesOperationPredicate) (result MonitorListVMHostsCompleteResult, err error) { - items := make([]VMResources, 0) - - resp, err := c.MonitorListVMHosts(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 = MonitorListVMHostsCompleteResult{ - LatestHttpResponse: resp.HttpResponse, - Items: items, - } - return -} diff --git a/resource-manager/logz/2020-10-01/vmhost/method_monitorlistvmhostupdate.go b/resource-manager/logz/2020-10-01/vmhost/method_monitorlistvmhostupdate.go deleted file mode 100644 index 8904f568244..00000000000 --- a/resource-manager/logz/2020-10-01/vmhost/method_monitorlistvmhostupdate.go +++ /dev/null @@ -1,105 +0,0 @@ -package vmhost - -import ( - "context" - "fmt" - "net/http" - - "github.com/hashicorp/go-azure-sdk/sdk/client" - "github.com/hashicorp/go-azure-sdk/sdk/odata" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type MonitorListVMHostUpdateOperationResponse struct { - HttpResponse *http.Response - OData *odata.OData - Model *[]VMResources -} - -type MonitorListVMHostUpdateCompleteResult struct { - LatestHttpResponse *http.Response - Items []VMResources -} - -type MonitorListVMHostUpdateCustomPager struct { - NextLink *odata.Link `json:"nextLink"` -} - -func (p *MonitorListVMHostUpdateCustomPager) NextPageLink() *odata.Link { - defer func() { - p.NextLink = nil - }() - - return p.NextLink -} - -// MonitorListVMHostUpdate ... -func (c VMHostClient) MonitorListVMHostUpdate(ctx context.Context, id MonitorId, input VMHostUpdateRequest) (result MonitorListVMHostUpdateOperationResponse, err error) { - opts := client.RequestOptions{ - ContentType: "application/json; charset=utf-8", - ExpectedStatusCodes: []int{ - http.StatusOK, - }, - HttpMethod: http.MethodPost, - Pager: &MonitorListVMHostUpdateCustomPager{}, - Path: fmt.Sprintf("%s/vmHostUpdate", id.ID()), - } - - req, err := c.Client.NewRequest(ctx, opts) - if err != nil { - return - } - - var resp *client.Response - resp, err = req.ExecutePaged(ctx) - if resp != nil { - result.OData = resp.OData - result.HttpResponse = resp.Response - } - if err != nil { - return - } - - var values struct { - Values *[]VMResources `json:"value"` - } - if err = resp.Unmarshal(&values); err != nil { - return - } - - result.Model = values.Values - - return -} - -// MonitorListVMHostUpdateComplete retrieves all the results into a single object -func (c VMHostClient) MonitorListVMHostUpdateComplete(ctx context.Context, id MonitorId, input VMHostUpdateRequest) (MonitorListVMHostUpdateCompleteResult, error) { - return c.MonitorListVMHostUpdateCompleteMatchingPredicate(ctx, id, input, VMResourcesOperationPredicate{}) -} - -// MonitorListVMHostUpdateCompleteMatchingPredicate retrieves all the results and then applies the predicate -func (c VMHostClient) MonitorListVMHostUpdateCompleteMatchingPredicate(ctx context.Context, id MonitorId, input VMHostUpdateRequest, predicate VMResourcesOperationPredicate) (result MonitorListVMHostUpdateCompleteResult, err error) { - items := make([]VMResources, 0) - - resp, err := c.MonitorListVMHostUpdate(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 = MonitorListVMHostUpdateCompleteResult{ - LatestHttpResponse: resp.HttpResponse, - Items: items, - } - return -} diff --git a/resource-manager/logz/2020-10-01/vmhost/method_subaccountlistvmhostupdate.go b/resource-manager/logz/2020-10-01/vmhost/method_subaccountlistvmhostupdate.go deleted file mode 100644 index 2cd6b1962fe..00000000000 --- a/resource-manager/logz/2020-10-01/vmhost/method_subaccountlistvmhostupdate.go +++ /dev/null @@ -1,105 +0,0 @@ -package vmhost - -import ( - "context" - "fmt" - "net/http" - - "github.com/hashicorp/go-azure-sdk/sdk/client" - "github.com/hashicorp/go-azure-sdk/sdk/odata" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type SubAccountListVMHostUpdateOperationResponse struct { - HttpResponse *http.Response - OData *odata.OData - Model *[]VMResources -} - -type SubAccountListVMHostUpdateCompleteResult struct { - LatestHttpResponse *http.Response - Items []VMResources -} - -type SubAccountListVMHostUpdateCustomPager struct { - NextLink *odata.Link `json:"nextLink"` -} - -func (p *SubAccountListVMHostUpdateCustomPager) NextPageLink() *odata.Link { - defer func() { - p.NextLink = nil - }() - - return p.NextLink -} - -// SubAccountListVMHostUpdate ... -func (c VMHostClient) SubAccountListVMHostUpdate(ctx context.Context, id AccountId, input VMHostUpdateRequest) (result SubAccountListVMHostUpdateOperationResponse, err error) { - opts := client.RequestOptions{ - ContentType: "application/json; charset=utf-8", - ExpectedStatusCodes: []int{ - http.StatusOK, - }, - HttpMethod: http.MethodPost, - Pager: &SubAccountListVMHostUpdateCustomPager{}, - Path: fmt.Sprintf("%s/vmHostUpdate", id.ID()), - } - - req, err := c.Client.NewRequest(ctx, opts) - if err != nil { - return - } - - var resp *client.Response - resp, err = req.ExecutePaged(ctx) - if resp != nil { - result.OData = resp.OData - result.HttpResponse = resp.Response - } - if err != nil { - return - } - - var values struct { - Values *[]VMResources `json:"value"` - } - if err = resp.Unmarshal(&values); err != nil { - return - } - - result.Model = values.Values - - return -} - -// SubAccountListVMHostUpdateComplete retrieves all the results into a single object -func (c VMHostClient) SubAccountListVMHostUpdateComplete(ctx context.Context, id AccountId, input VMHostUpdateRequest) (SubAccountListVMHostUpdateCompleteResult, error) { - return c.SubAccountListVMHostUpdateCompleteMatchingPredicate(ctx, id, input, VMResourcesOperationPredicate{}) -} - -// SubAccountListVMHostUpdateCompleteMatchingPredicate retrieves all the results and then applies the predicate -func (c VMHostClient) SubAccountListVMHostUpdateCompleteMatchingPredicate(ctx context.Context, id AccountId, input VMHostUpdateRequest, predicate VMResourcesOperationPredicate) (result SubAccountListVMHostUpdateCompleteResult, err error) { - items := make([]VMResources, 0) - - resp, err := c.SubAccountListVMHostUpdate(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 = SubAccountListVMHostUpdateCompleteResult{ - LatestHttpResponse: resp.HttpResponse, - Items: items, - } - return -} diff --git a/resource-manager/logz/2020-10-01/vmhost/method_subaccountvmhostpayload.go b/resource-manager/logz/2020-10-01/vmhost/method_subaccountvmhostpayload.go deleted file mode 100644 index d96691ee294..00000000000 --- a/resource-manager/logz/2020-10-01/vmhost/method_subaccountvmhostpayload.go +++ /dev/null @@ -1,54 +0,0 @@ -package vmhost - -import ( - "context" - "fmt" - "net/http" - - "github.com/hashicorp/go-azure-sdk/sdk/client" - "github.com/hashicorp/go-azure-sdk/sdk/odata" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type SubAccountVMHostPayloadOperationResponse struct { - HttpResponse *http.Response - OData *odata.OData - Model *VMExtensionPayload -} - -// SubAccountVMHostPayload ... -func (c VMHostClient) SubAccountVMHostPayload(ctx context.Context, id AccountId) (result SubAccountVMHostPayloadOperationResponse, err error) { - opts := client.RequestOptions{ - ContentType: "application/json; charset=utf-8", - ExpectedStatusCodes: []int{ - http.StatusOK, - }, - HttpMethod: http.MethodPost, - Path: fmt.Sprintf("%s/vmHostPayload", id.ID()), - } - - req, err := c.Client.NewRequest(ctx, opts) - if err != nil { - return - } - - var resp *client.Response - resp, err = req.Execute(ctx) - if resp != nil { - result.OData = resp.OData - result.HttpResponse = resp.Response - } - if err != nil { - return - } - - var model VMExtensionPayload - result.Model = &model - if err = resp.Unmarshal(result.Model); err != nil { - return - } - - return -} diff --git a/resource-manager/logz/2020-10-01/vmhost/model_vmextensionpayload.go b/resource-manager/logz/2020-10-01/vmhost/model_vmextensionpayload.go deleted file mode 100644 index e3da86566a0..00000000000 --- a/resource-manager/logz/2020-10-01/vmhost/model_vmextensionpayload.go +++ /dev/null @@ -1,9 +0,0 @@ -package vmhost - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type VMExtensionPayload struct { - ApiKey *string `json:"apiKey,omitempty"` - Region *string `json:"region,omitempty"` -} diff --git a/resource-manager/logz/2020-10-01/vmhost/model_vmhostupdaterequest.go b/resource-manager/logz/2020-10-01/vmhost/model_vmhostupdaterequest.go deleted file mode 100644 index 0a38de6bbc5..00000000000 --- a/resource-manager/logz/2020-10-01/vmhost/model_vmhostupdaterequest.go +++ /dev/null @@ -1,9 +0,0 @@ -package vmhost - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type VMHostUpdateRequest struct { - State *VMHostUpdateStates `json:"state,omitempty"` - VMResourceIds *[]VMResources `json:"vmResourceIds,omitempty"` -} diff --git a/resource-manager/logz/2020-10-01/vmhost/model_vmresources.go b/resource-manager/logz/2020-10-01/vmhost/model_vmresources.go deleted file mode 100644 index 53438a53e9b..00000000000 --- a/resource-manager/logz/2020-10-01/vmhost/model_vmresources.go +++ /dev/null @@ -1,9 +0,0 @@ -package vmhost - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type VMResources struct { - AgentVersion *string `json:"agentVersion,omitempty"` - Id *string `json:"id,omitempty"` -} diff --git a/resource-manager/logz/2020-10-01/vmhost/predicates.go b/resource-manager/logz/2020-10-01/vmhost/predicates.go deleted file mode 100644 index 1d53ebc8265..00000000000 --- a/resource-manager/logz/2020-10-01/vmhost/predicates.go +++ /dev/null @@ -1,22 +0,0 @@ -package vmhost - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type VMResourcesOperationPredicate struct { - AgentVersion *string - Id *string -} - -func (p VMResourcesOperationPredicate) Matches(input VMResources) bool { - - if p.AgentVersion != nil && (input.AgentVersion == nil || *p.AgentVersion != *input.AgentVersion) { - return false - } - - if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { - return false - } - - return true -} diff --git a/resource-manager/machinelearningservices/2024-10-01/onlinedeployment/model_kubernetesonlinedeployment.go b/resource-manager/machinelearningservices/2024-10-01/onlinedeployment/model_kubernetesonlinedeployment.go index d3b5f152beb..7eea9a4f98c 100644 --- a/resource-manager/machinelearningservices/2024-10-01/onlinedeployment/model_kubernetesonlinedeployment.go +++ b/resource-manager/machinelearningservices/2024-10-01/onlinedeployment/model_kubernetesonlinedeployment.go @@ -32,6 +32,7 @@ type KubernetesOnlineDeployment struct { ReadinessProbe *ProbeSettings `json:"readinessProbe,omitempty"` RequestSettings *OnlineRequestSettings `json:"requestSettings,omitempty"` ScaleSettings OnlineScaleSettings `json:"scaleSettings"` + StartupProbe *ProbeSettings `json:"startupProbe,omitempty"` } func (s KubernetesOnlineDeployment) OnlineDeployment() BaseOnlineDeploymentImpl { @@ -53,6 +54,7 @@ func (s KubernetesOnlineDeployment) OnlineDeployment() BaseOnlineDeploymentImpl ReadinessProbe: s.ReadinessProbe, RequestSettings: s.RequestSettings, ScaleSettings: s.ScaleSettings, + StartupProbe: s.StartupProbe, } } @@ -102,6 +104,7 @@ func (s *KubernetesOnlineDeployment) UnmarshalJSON(bytes []byte) error { ProvisioningState *DeploymentProvisioningState `json:"provisioningState,omitempty"` ReadinessProbe *ProbeSettings `json:"readinessProbe,omitempty"` RequestSettings *OnlineRequestSettings `json:"requestSettings,omitempty"` + StartupProbe *ProbeSettings `json:"startupProbe,omitempty"` } if err := json.Unmarshal(bytes, &decoded); err != nil { return fmt.Errorf("unmarshaling: %+v", err) @@ -124,6 +127,7 @@ func (s *KubernetesOnlineDeployment) UnmarshalJSON(bytes []byte) error { s.ProvisioningState = decoded.ProvisioningState s.ReadinessProbe = decoded.ReadinessProbe s.RequestSettings = decoded.RequestSettings + s.StartupProbe = decoded.StartupProbe var temp map[string]json.RawMessage if err := json.Unmarshal(bytes, &temp); err != nil { diff --git a/resource-manager/machinelearningservices/2024-10-01/onlinedeployment/model_managedonlinedeployment.go b/resource-manager/machinelearningservices/2024-10-01/onlinedeployment/model_managedonlinedeployment.go index a927a47bd34..d9c6b56fdf5 100644 --- a/resource-manager/machinelearningservices/2024-10-01/onlinedeployment/model_managedonlinedeployment.go +++ b/resource-manager/machinelearningservices/2024-10-01/onlinedeployment/model_managedonlinedeployment.go @@ -31,6 +31,7 @@ type ManagedOnlineDeployment struct { ReadinessProbe *ProbeSettings `json:"readinessProbe,omitempty"` RequestSettings *OnlineRequestSettings `json:"requestSettings,omitempty"` ScaleSettings OnlineScaleSettings `json:"scaleSettings"` + StartupProbe *ProbeSettings `json:"startupProbe,omitempty"` } func (s ManagedOnlineDeployment) OnlineDeployment() BaseOnlineDeploymentImpl { @@ -52,6 +53,7 @@ func (s ManagedOnlineDeployment) OnlineDeployment() BaseOnlineDeploymentImpl { ReadinessProbe: s.ReadinessProbe, RequestSettings: s.RequestSettings, ScaleSettings: s.ScaleSettings, + StartupProbe: s.StartupProbe, } } @@ -100,6 +102,7 @@ func (s *ManagedOnlineDeployment) UnmarshalJSON(bytes []byte) error { ProvisioningState *DeploymentProvisioningState `json:"provisioningState,omitempty"` ReadinessProbe *ProbeSettings `json:"readinessProbe,omitempty"` RequestSettings *OnlineRequestSettings `json:"requestSettings,omitempty"` + StartupProbe *ProbeSettings `json:"startupProbe,omitempty"` } if err := json.Unmarshal(bytes, &decoded); err != nil { return fmt.Errorf("unmarshaling: %+v", err) @@ -121,6 +124,7 @@ func (s *ManagedOnlineDeployment) UnmarshalJSON(bytes []byte) error { s.ProvisioningState = decoded.ProvisioningState s.ReadinessProbe = decoded.ReadinessProbe s.RequestSettings = decoded.RequestSettings + s.StartupProbe = decoded.StartupProbe var temp map[string]json.RawMessage if err := json.Unmarshal(bytes, &temp); err != nil { diff --git a/resource-manager/machinelearningservices/2024-10-01/onlinedeployment/model_onlinedeployment.go b/resource-manager/machinelearningservices/2024-10-01/onlinedeployment/model_onlinedeployment.go index 4647db3b9cf..8e9e2000a28 100644 --- a/resource-manager/machinelearningservices/2024-10-01/onlinedeployment/model_onlinedeployment.go +++ b/resource-manager/machinelearningservices/2024-10-01/onlinedeployment/model_onlinedeployment.go @@ -33,6 +33,7 @@ type BaseOnlineDeploymentImpl struct { ReadinessProbe *ProbeSettings `json:"readinessProbe,omitempty"` RequestSettings *OnlineRequestSettings `json:"requestSettings,omitempty"` ScaleSettings OnlineScaleSettings `json:"scaleSettings"` + StartupProbe *ProbeSettings `json:"startupProbe,omitempty"` } func (s BaseOnlineDeploymentImpl) OnlineDeployment() BaseOnlineDeploymentImpl { @@ -74,6 +75,7 @@ func (s *BaseOnlineDeploymentImpl) UnmarshalJSON(bytes []byte) error { ProvisioningState *DeploymentProvisioningState `json:"provisioningState,omitempty"` ReadinessProbe *ProbeSettings `json:"readinessProbe,omitempty"` RequestSettings *OnlineRequestSettings `json:"requestSettings,omitempty"` + StartupProbe *ProbeSettings `json:"startupProbe,omitempty"` } if err := json.Unmarshal(bytes, &decoded); err != nil { return fmt.Errorf("unmarshaling: %+v", err) @@ -95,6 +97,7 @@ func (s *BaseOnlineDeploymentImpl) UnmarshalJSON(bytes []byte) error { s.ProvisioningState = decoded.ProvisioningState s.ReadinessProbe = decoded.ReadinessProbe s.RequestSettings = decoded.RequestSettings + s.StartupProbe = decoded.StartupProbe var temp map[string]json.RawMessage if err := json.Unmarshal(bytes, &temp); err != nil { diff --git a/resource-manager/mixedreality/2025-01-01/client.go b/resource-manager/mixedreality/2025-01-01/client.go new file mode 100644 index 00000000000..6f93ed2fc50 --- /dev/null +++ b/resource-manager/mixedreality/2025-01-01/client.go @@ -0,0 +1,46 @@ +package v2025_01_01 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/resource-manager/mixedreality/2025-01-01/key" + "github.com/hashicorp/go-azure-sdk/resource-manager/mixedreality/2025-01-01/proxy" + "github.com/hashicorp/go-azure-sdk/resource-manager/mixedreality/2025-01-01/resource" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + Key *key.KeyClient + Proxy *proxy.ProxyClient + Resource *resource.ResourceClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + keyClient, err := key.NewKeyClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Key client: %+v", err) + } + configureFunc(keyClient.Client) + + proxyClient, err := proxy.NewProxyClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Proxy client: %+v", err) + } + configureFunc(proxyClient.Client) + + resourceClient, err := resource.NewResourceClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Resource client: %+v", err) + } + configureFunc(resourceClient.Client) + + return &Client{ + Key: keyClient, + Proxy: proxyClient, + Resource: resourceClient, + }, nil +} diff --git a/resource-manager/mixedreality/2025-01-01/key/README.md b/resource-manager/mixedreality/2025-01-01/key/README.md new file mode 100644 index 00000000000..f82cc637e61 --- /dev/null +++ b/resource-manager/mixedreality/2025-01-01/key/README.md @@ -0,0 +1,57 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/mixedreality/2025-01-01/key` Documentation + +The `key` SDK allows for interaction with Azure Resource Manager `mixedreality` (API Version `2025-01-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/mixedreality/2025-01-01/key" +``` + + +### Client Initialization + +```go +client := key.NewKeyClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `KeyClient.RemoteRenderingAccountsListKeys` + +```go +ctx := context.TODO() +id := key.NewRemoteRenderingAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "remoteRenderingAccountName") + +read, err := client.RemoteRenderingAccountsListKeys(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `KeyClient.RemoteRenderingAccountsRegenerateKeys` + +```go +ctx := context.TODO() +id := key.NewRemoteRenderingAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "remoteRenderingAccountName") + +payload := key.AccountKeyRegenerateRequest{ + // ... +} + + +read, err := client.RemoteRenderingAccountsRegenerateKeys(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/logz/2020-10-01/vmhost/client.go b/resource-manager/mixedreality/2025-01-01/key/client.go similarity index 57% rename from resource-manager/logz/2020-10-01/vmhost/client.go rename to resource-manager/mixedreality/2025-01-01/key/client.go index a84b784e309..3c29cfe2291 100644 --- a/resource-manager/logz/2020-10-01/vmhost/client.go +++ b/resource-manager/mixedreality/2025-01-01/key/client.go @@ -1,4 +1,4 @@ -package vmhost +package key import ( "fmt" @@ -10,17 +10,17 @@ import ( // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. -type VMHostClient struct { +type KeyClient struct { Client *resourcemanager.Client } -func NewVMHostClientWithBaseURI(sdkApi sdkEnv.Api) (*VMHostClient, error) { - client, err := resourcemanager.NewClient(sdkApi, "vmhost", defaultApiVersion) +func NewKeyClientWithBaseURI(sdkApi sdkEnv.Api) (*KeyClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "key", defaultApiVersion) if err != nil { - return nil, fmt.Errorf("instantiating VMHostClient: %+v", err) + return nil, fmt.Errorf("instantiating KeyClient: %+v", err) } - return &VMHostClient{ + return &KeyClient{ Client: client, }, nil } diff --git a/resource-manager/mixedreality/2025-01-01/key/constants.go b/resource-manager/mixedreality/2025-01-01/key/constants.go new file mode 100644 index 00000000000..4dc132d61a1 --- /dev/null +++ b/resource-manager/mixedreality/2025-01-01/key/constants.go @@ -0,0 +1,18 @@ +package key + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Serial int64 + +const ( + SerialPrimary Serial = 1 + SerialSecondary Serial = 2 +) + +func PossibleValuesForSerial() []int64 { + return []int64{ + int64(SerialPrimary), + int64(SerialSecondary), + } +} diff --git a/resource-manager/mixedreality/2025-01-01/key/id_remoterenderingaccount.go b/resource-manager/mixedreality/2025-01-01/key/id_remoterenderingaccount.go new file mode 100644 index 00000000000..e9f8cd8d3d7 --- /dev/null +++ b/resource-manager/mixedreality/2025-01-01/key/id_remoterenderingaccount.go @@ -0,0 +1,130 @@ +package key + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RemoteRenderingAccountId{}) +} + +var _ resourceids.ResourceId = &RemoteRenderingAccountId{} + +// RemoteRenderingAccountId is a struct representing the Resource ID for a Remote Rendering Account +type RemoteRenderingAccountId struct { + SubscriptionId string + ResourceGroupName string + RemoteRenderingAccountName string +} + +// NewRemoteRenderingAccountID returns a new RemoteRenderingAccountId struct +func NewRemoteRenderingAccountID(subscriptionId string, resourceGroupName string, remoteRenderingAccountName string) RemoteRenderingAccountId { + return RemoteRenderingAccountId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + RemoteRenderingAccountName: remoteRenderingAccountName, + } +} + +// ParseRemoteRenderingAccountID parses 'input' into a RemoteRenderingAccountId +func ParseRemoteRenderingAccountID(input string) (*RemoteRenderingAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&RemoteRenderingAccountId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RemoteRenderingAccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRemoteRenderingAccountIDInsensitively parses 'input' case-insensitively into a RemoteRenderingAccountId +// note: this method should only be used for API response data and not user input +func ParseRemoteRenderingAccountIDInsensitively(input string) (*RemoteRenderingAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&RemoteRenderingAccountId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RemoteRenderingAccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RemoteRenderingAccountId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.RemoteRenderingAccountName, ok = input.Parsed["remoteRenderingAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "remoteRenderingAccountName", input) + } + + return nil +} + +// ValidateRemoteRenderingAccountID checks that 'input' can be parsed as a Remote Rendering Account ID +func ValidateRemoteRenderingAccountID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRemoteRenderingAccountID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Remote Rendering Account ID +func (id RemoteRenderingAccountId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MixedReality/remoteRenderingAccounts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.RemoteRenderingAccountName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Remote Rendering Account ID +func (id RemoteRenderingAccountId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMixedReality", "Microsoft.MixedReality", "Microsoft.MixedReality"), + resourceids.StaticSegment("staticRemoteRenderingAccounts", "remoteRenderingAccounts", "remoteRenderingAccounts"), + resourceids.UserSpecifiedSegment("remoteRenderingAccountName", "remoteRenderingAccountName"), + } +} + +// String returns a human-readable description of this Remote Rendering Account ID +func (id RemoteRenderingAccountId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Remote Rendering Account Name: %q", id.RemoteRenderingAccountName), + } + return fmt.Sprintf("Remote Rendering Account (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/logz/2020-10-01/monitors/id_monitor_test.go b/resource-manager/mixedreality/2025-01-01/key/id_remoterenderingaccount_test.go similarity index 62% rename from resource-manager/logz/2020-10-01/monitors/id_monitor_test.go rename to resource-manager/mixedreality/2025-01-01/key/id_remoterenderingaccount_test.go index 5eec572ac1c..8a5b61d9e4c 100644 --- a/resource-manager/logz/2020-10-01/monitors/id_monitor_test.go +++ b/resource-manager/mixedreality/2025-01-01/key/id_remoterenderingaccount_test.go @@ -1,4 +1,4 @@ -package monitors +package key import ( "testing" @@ -9,10 +9,10 @@ import ( // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. -var _ resourceids.ResourceId = &MonitorId{} +var _ resourceids.ResourceId = &RemoteRenderingAccountId{} -func TestNewMonitorID(t *testing.T) { - id := NewMonitorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName") +func TestNewRemoteRenderingAccountID(t *testing.T) { + id := NewRemoteRenderingAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "remoteRenderingAccountName") if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") @@ -22,24 +22,24 @@ func TestNewMonitorID(t *testing.T) { t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") } - if id.MonitorName != "monitorName" { - t.Fatalf("Expected %q but got %q for Segment 'MonitorName'", id.MonitorName, "monitorName") + if id.RemoteRenderingAccountName != "remoteRenderingAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'RemoteRenderingAccountName'", id.RemoteRenderingAccountName, "remoteRenderingAccountName") } } -func TestFormatMonitorID(t *testing.T) { - actual := NewMonitorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName" +func TestFormatRemoteRenderingAccountID(t *testing.T) { + actual := NewRemoteRenderingAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "remoteRenderingAccountName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MixedReality/remoteRenderingAccounts/remoteRenderingAccountName" if actual != expected { t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) } } -func TestParseMonitorID(t *testing.T) { +func TestParseRemoteRenderingAccountID(t *testing.T) { testData := []struct { Input string Error bool - Expected *MonitorId + Expected *RemoteRenderingAccountId }{ { // Incomplete URI @@ -73,33 +73,33 @@ func TestParseMonitorID(t *testing.T) { }, { // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MixedReality", Error: true, }, { // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MixedReality/remoteRenderingAccounts", Error: true, }, { // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName", - Expected: &MonitorId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - MonitorName: "monitorName", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MixedReality/remoteRenderingAccounts/remoteRenderingAccountName", + Expected: &RemoteRenderingAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RemoteRenderingAccountName: "remoteRenderingAccountName", }, }, { // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/extra", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MixedReality/remoteRenderingAccounts/remoteRenderingAccountName/extra", Error: true, }, } for _, v := range testData { t.Logf("[DEBUG] Testing %q", v.Input) - actual, err := ParseMonitorID(v.Input) + actual, err := ParseRemoteRenderingAccountID(v.Input) if err != nil { if v.Error { continue @@ -119,18 +119,18 @@ func TestParseMonitorID(t *testing.T) { t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) } - if actual.MonitorName != v.Expected.MonitorName { - t.Fatalf("Expected %q but got %q for MonitorName", v.Expected.MonitorName, actual.MonitorName) + if actual.RemoteRenderingAccountName != v.Expected.RemoteRenderingAccountName { + t.Fatalf("Expected %q but got %q for RemoteRenderingAccountName", v.Expected.RemoteRenderingAccountName, actual.RemoteRenderingAccountName) } } } -func TestParseMonitorIDInsensitively(t *testing.T) { +func TestParseRemoteRenderingAccountIDInsensitively(t *testing.T) { testData := []struct { Input string Error bool - Expected *MonitorId + Expected *RemoteRenderingAccountId }{ { // Incomplete URI @@ -189,57 +189,57 @@ func TestParseMonitorIDInsensitively(t *testing.T) { }, { // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MixedReality", Error: true, }, { // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ", + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mIxEdReAlItY", Error: true, }, { // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MixedReality/remoteRenderingAccounts", Error: true, }, { // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ/mOnItOrS", + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mIxEdReAlItY/rEmOtErEnDeRiNgAcCoUnTs", Error: true, }, { // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName", - Expected: &MonitorId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - MonitorName: "monitorName", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MixedReality/remoteRenderingAccounts/remoteRenderingAccountName", + Expected: &RemoteRenderingAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RemoteRenderingAccountName: "remoteRenderingAccountName", }, }, { // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/extra", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MixedReality/remoteRenderingAccounts/remoteRenderingAccountName/extra", Error: true, }, { // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ/mOnItOrS/mOnItOrNaMe", - Expected: &MonitorId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - MonitorName: "mOnItOrNaMe", + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mIxEdReAlItY/rEmOtErEnDeRiNgAcCoUnTs/rEmOtErEnDeRiNgAcCoUnTnAmE", + Expected: &RemoteRenderingAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + RemoteRenderingAccountName: "rEmOtErEnDeRiNgAcCoUnTnAmE", }, }, { // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ/mOnItOrS/mOnItOrNaMe/extra", + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mIxEdReAlItY/rEmOtErEnDeRiNgAcCoUnTs/rEmOtErEnDeRiNgAcCoUnTnAmE/extra", Error: true, }, } for _, v := range testData { t.Logf("[DEBUG] Testing %q", v.Input) - actual, err := ParseMonitorIDInsensitively(v.Input) + actual, err := ParseRemoteRenderingAccountIDInsensitively(v.Input) if err != nil { if v.Error { continue @@ -259,17 +259,17 @@ func TestParseMonitorIDInsensitively(t *testing.T) { t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) } - if actual.MonitorName != v.Expected.MonitorName { - t.Fatalf("Expected %q but got %q for MonitorName", v.Expected.MonitorName, actual.MonitorName) + if actual.RemoteRenderingAccountName != v.Expected.RemoteRenderingAccountName { + t.Fatalf("Expected %q but got %q for RemoteRenderingAccountName", v.Expected.RemoteRenderingAccountName, actual.RemoteRenderingAccountName) } } } -func TestSegmentsForMonitorId(t *testing.T) { - segments := MonitorId{}.Segments() +func TestSegmentsForRemoteRenderingAccountId(t *testing.T) { + segments := RemoteRenderingAccountId{}.Segments() if len(segments) == 0 { - t.Fatalf("MonitorId has no segments") + t.Fatalf("RemoteRenderingAccountId has no segments") } uniqueNames := make(map[string]struct{}, 0) diff --git a/resource-manager/logz/2020-10-01/vmhost/method_monitorvmhostpayload.go b/resource-manager/mixedreality/2025-01-01/key/method_remoterenderingaccountslistkeys.go similarity index 69% rename from resource-manager/logz/2020-10-01/vmhost/method_monitorvmhostpayload.go rename to resource-manager/mixedreality/2025-01-01/key/method_remoterenderingaccountslistkeys.go index e9bf717e8bf..6fc308963e4 100644 --- a/resource-manager/logz/2020-10-01/vmhost/method_monitorvmhostpayload.go +++ b/resource-manager/mixedreality/2025-01-01/key/method_remoterenderingaccountslistkeys.go @@ -1,4 +1,4 @@ -package vmhost +package key import ( "context" @@ -12,21 +12,21 @@ import ( // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. -type MonitorVMHostPayloadOperationResponse struct { +type RemoteRenderingAccountsListKeysOperationResponse struct { HttpResponse *http.Response OData *odata.OData - Model *VMExtensionPayload + Model *AccountKeys } -// MonitorVMHostPayload ... -func (c VMHostClient) MonitorVMHostPayload(ctx context.Context, id MonitorId) (result MonitorVMHostPayloadOperationResponse, err error) { +// RemoteRenderingAccountsListKeys ... +func (c KeyClient) RemoteRenderingAccountsListKeys(ctx context.Context, id RemoteRenderingAccountId) (result RemoteRenderingAccountsListKeysOperationResponse, err error) { opts := client.RequestOptions{ ContentType: "application/json; charset=utf-8", ExpectedStatusCodes: []int{ http.StatusOK, }, HttpMethod: http.MethodPost, - Path: fmt.Sprintf("%s/vmHostPayload", id.ID()), + Path: fmt.Sprintf("%s/listKeys", id.ID()), } req, err := c.Client.NewRequest(ctx, opts) @@ -44,7 +44,7 @@ func (c VMHostClient) MonitorVMHostPayload(ctx context.Context, id MonitorId) (r return } - var model VMExtensionPayload + var model AccountKeys result.Model = &model if err = resp.Unmarshal(result.Model); err != nil { return diff --git a/resource-manager/mixedreality/2025-01-01/key/method_remoterenderingaccountsregeneratekeys.go b/resource-manager/mixedreality/2025-01-01/key/method_remoterenderingaccountsregeneratekeys.go new file mode 100644 index 00000000000..f8d284d7099 --- /dev/null +++ b/resource-manager/mixedreality/2025-01-01/key/method_remoterenderingaccountsregeneratekeys.go @@ -0,0 +1,58 @@ +package key + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemoteRenderingAccountsRegenerateKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AccountKeys +} + +// RemoteRenderingAccountsRegenerateKeys ... +func (c KeyClient) RemoteRenderingAccountsRegenerateKeys(ctx context.Context, id RemoteRenderingAccountId, input AccountKeyRegenerateRequest) (result RemoteRenderingAccountsRegenerateKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/regenerateKeys", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AccountKeys + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/logz/2020-10-01/monitors/model_userrolerequest.go b/resource-manager/mixedreality/2025-01-01/key/model_accountkeyregeneraterequest.go similarity index 61% rename from resource-manager/logz/2020-10-01/monitors/model_userrolerequest.go rename to resource-manager/mixedreality/2025-01-01/key/model_accountkeyregeneraterequest.go index 7b1a0c898bf..a16d03f1419 100644 --- a/resource-manager/logz/2020-10-01/monitors/model_userrolerequest.go +++ b/resource-manager/mixedreality/2025-01-01/key/model_accountkeyregeneraterequest.go @@ -1,8 +1,8 @@ -package monitors +package key // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. -type UserRoleRequest struct { - EmailAddress *string `json:"emailAddress,omitempty"` +type AccountKeyRegenerateRequest struct { + Serial *Serial `json:"serial,omitempty"` } diff --git a/resource-manager/mixedreality/2025-01-01/key/model_accountkeys.go b/resource-manager/mixedreality/2025-01-01/key/model_accountkeys.go new file mode 100644 index 00000000000..30dec438536 --- /dev/null +++ b/resource-manager/mixedreality/2025-01-01/key/model_accountkeys.go @@ -0,0 +1,9 @@ +package key + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AccountKeys struct { + PrimaryKey *string `json:"primaryKey,omitempty"` + SecondaryKey *string `json:"secondaryKey,omitempty"` +} diff --git a/resource-manager/logz/2020-10-01/vmhost/version.go b/resource-manager/mixedreality/2025-01-01/key/version.go similarity index 64% rename from resource-manager/logz/2020-10-01/vmhost/version.go rename to resource-manager/mixedreality/2025-01-01/key/version.go index e871abd0fb0..db79882de2c 100644 --- a/resource-manager/logz/2020-10-01/vmhost/version.go +++ b/resource-manager/mixedreality/2025-01-01/key/version.go @@ -1,10 +1,10 @@ -package vmhost +package key // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. -const defaultApiVersion = "2020-10-01" +const defaultApiVersion = "2025-01-01" func userAgent() string { - return "hashicorp/go-azure-sdk/vmhost/2020-10-01" + return "hashicorp/go-azure-sdk/key/2025-01-01" } diff --git a/resource-manager/mixedreality/2025-01-01/proxy/README.md b/resource-manager/mixedreality/2025-01-01/proxy/README.md new file mode 100644 index 00000000000..e44b6c62b0a --- /dev/null +++ b/resource-manager/mixedreality/2025-01-01/proxy/README.md @@ -0,0 +1,59 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/mixedreality/2025-01-01/proxy` Documentation + +The `proxy` SDK allows for interaction with Azure Resource Manager `mixedreality` (API Version `2025-01-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/mixedreality/2025-01-01/proxy" +``` + + +### Client Initialization + +```go +client := proxy.NewProxyClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ProxyClient.CheckNameAvailabilityLocal` + +```go +ctx := context.TODO() +id := proxy.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +payload := proxy.CheckNameAvailabilityRequest{ + // ... +} + + +read, err := client.CheckNameAvailabilityLocal(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ProxyClient.RemoteRenderingAccountsListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.RemoteRenderingAccountsListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.RemoteRenderingAccountsListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/logz/2020-10-01/monitors/client.go b/resource-manager/mixedreality/2025-01-01/proxy/client.go similarity index 56% rename from resource-manager/logz/2020-10-01/monitors/client.go rename to resource-manager/mixedreality/2025-01-01/proxy/client.go index da8f22135b8..daaef6e0be4 100644 --- a/resource-manager/logz/2020-10-01/monitors/client.go +++ b/resource-manager/mixedreality/2025-01-01/proxy/client.go @@ -1,4 +1,4 @@ -package monitors +package proxy import ( "fmt" @@ -10,17 +10,17 @@ import ( // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. -type MonitorsClient struct { +type ProxyClient struct { Client *resourcemanager.Client } -func NewMonitorsClientWithBaseURI(sdkApi sdkEnv.Api) (*MonitorsClient, error) { - client, err := resourcemanager.NewClient(sdkApi, "monitors", defaultApiVersion) +func NewProxyClientWithBaseURI(sdkApi sdkEnv.Api) (*ProxyClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "proxy", defaultApiVersion) if err != nil { - return nil, fmt.Errorf("instantiating MonitorsClient: %+v", err) + return nil, fmt.Errorf("instantiating ProxyClient: %+v", err) } - return &MonitorsClient{ + return &ProxyClient{ Client: client, }, nil } diff --git a/resource-manager/mixedreality/2025-01-01/proxy/constants.go b/resource-manager/mixedreality/2025-01-01/proxy/constants.go new file mode 100644 index 00000000000..99e9fd6d941 --- /dev/null +++ b/resource-manager/mixedreality/2025-01-01/proxy/constants.go @@ -0,0 +1,98 @@ +package proxy + +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 NameUnavailableReason string + +const ( + NameUnavailableReasonAlreadyExists NameUnavailableReason = "AlreadyExists" + NameUnavailableReasonInvalid NameUnavailableReason = "Invalid" +) + +func PossibleValuesForNameUnavailableReason() []string { + return []string{ + string(NameUnavailableReasonAlreadyExists), + string(NameUnavailableReasonInvalid), + } +} + +func (s *NameUnavailableReason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNameUnavailableReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNameUnavailableReason(input string) (*NameUnavailableReason, error) { + vals := map[string]NameUnavailableReason{ + "alreadyexists": NameUnavailableReasonAlreadyExists, + "invalid": NameUnavailableReasonInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NameUnavailableReason(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/mixedreality/2025-01-01/proxy/id_location.go b/resource-manager/mixedreality/2025-01-01/proxy/id_location.go new file mode 100644 index 00000000000..66ee4faa862 --- /dev/null +++ b/resource-manager/mixedreality/2025-01-01/proxy/id_location.go @@ -0,0 +1,121 @@ +package proxy + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&LocationId{}) +} + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + SubscriptionId string + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(subscriptionId string, locationName string) LocationId { + return LocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.MixedReality/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Location ID +func (id LocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMixedReality", "Microsoft.MixedReality", "Microsoft.MixedReality"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + } +} + +// String returns a human-readable description of this Location ID +func (id LocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/mixedreality/2025-01-01/proxy/id_location_test.go b/resource-manager/mixedreality/2025-01-01/proxy/id_location_test.go new file mode 100644 index 00000000000..b8f94aa21f4 --- /dev/null +++ b/resource-manager/mixedreality/2025-01-01/proxy/id_location_test.go @@ -0,0 +1,237 @@ +package proxy + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &LocationId{} + +func TestNewLocationID(t *testing.T) { + id := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.LocationName != "locationName" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationName") + } +} + +func TestFormatLocationID(t *testing.T) { + actual := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.MixedReality/locations/locationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.MixedReality", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.MixedReality/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.MixedReality/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.MixedReality/locations/locationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.MixedReality", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.mIxEdReAlItY", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.MixedReality/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.mIxEdReAlItY/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.MixedReality/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.MixedReality/locations/locationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.mIxEdReAlItY/lOcAtIoNs/lOcAtIoNnAmE", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.mIxEdReAlItY/lOcAtIoNs/lOcAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForLocationId(t *testing.T) { + segments := LocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/mixedreality/2025-01-01/proxy/method_checknameavailabilitylocal.go b/resource-manager/mixedreality/2025-01-01/proxy/method_checknameavailabilitylocal.go new file mode 100644 index 00000000000..6b96e01a34e --- /dev/null +++ b/resource-manager/mixedreality/2025-01-01/proxy/method_checknameavailabilitylocal.go @@ -0,0 +1,58 @@ +package proxy + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailabilityLocalOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CheckNameAvailabilityResponse +} + +// CheckNameAvailabilityLocal ... +func (c ProxyClient) CheckNameAvailabilityLocal(ctx context.Context, id LocationId, input CheckNameAvailabilityRequest) (result CheckNameAvailabilityLocalOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/checkNameAvailability", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model CheckNameAvailabilityResponse + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/mixedreality/2025-01-01/proxy/method_remoterenderingaccountslistbysubscription.go b/resource-manager/mixedreality/2025-01-01/proxy/method_remoterenderingaccountslistbysubscription.go new file mode 100644 index 00000000000..ced116976a6 --- /dev/null +++ b/resource-manager/mixedreality/2025-01-01/proxy/method_remoterenderingaccountslistbysubscription.go @@ -0,0 +1,106 @@ +package proxy + +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 RemoteRenderingAccountsListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RemoteRenderingAccount +} + +type RemoteRenderingAccountsListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []RemoteRenderingAccount +} + +type RemoteRenderingAccountsListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *RemoteRenderingAccountsListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// RemoteRenderingAccountsListBySubscription ... +func (c ProxyClient) RemoteRenderingAccountsListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result RemoteRenderingAccountsListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &RemoteRenderingAccountsListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.MixedReality/remoteRenderingAccounts", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]RemoteRenderingAccount `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// RemoteRenderingAccountsListBySubscriptionComplete retrieves all the results into a single object +func (c ProxyClient) RemoteRenderingAccountsListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (RemoteRenderingAccountsListBySubscriptionCompleteResult, error) { + return c.RemoteRenderingAccountsListBySubscriptionCompleteMatchingPredicate(ctx, id, RemoteRenderingAccountOperationPredicate{}) +} + +// RemoteRenderingAccountsListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ProxyClient) RemoteRenderingAccountsListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate RemoteRenderingAccountOperationPredicate) (result RemoteRenderingAccountsListBySubscriptionCompleteResult, err error) { + items := make([]RemoteRenderingAccount, 0) + + resp, err := c.RemoteRenderingAccountsListBySubscription(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 = RemoteRenderingAccountsListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/logz/2020-10-01/monitors/model_monitorupdateproperties.go b/resource-manager/mixedreality/2025-01-01/proxy/model_checknameavailabilityrequest.go similarity index 55% rename from resource-manager/logz/2020-10-01/monitors/model_monitorupdateproperties.go rename to resource-manager/mixedreality/2025-01-01/proxy/model_checknameavailabilityrequest.go index bfd77a7ece3..b34ef86abe3 100644 --- a/resource-manager/logz/2020-10-01/monitors/model_monitorupdateproperties.go +++ b/resource-manager/mixedreality/2025-01-01/proxy/model_checknameavailabilityrequest.go @@ -1,8 +1,9 @@ -package monitors +package proxy // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. -type MonitorUpdateProperties struct { - MonitoringStatus *MonitoringStatus `json:"monitoringStatus,omitempty"` +type CheckNameAvailabilityRequest struct { + Name string `json:"name"` + Type string `json:"type"` } diff --git a/resource-manager/mixedreality/2025-01-01/proxy/model_checknameavailabilityresponse.go b/resource-manager/mixedreality/2025-01-01/proxy/model_checknameavailabilityresponse.go new file mode 100644 index 00000000000..70286c7568c --- /dev/null +++ b/resource-manager/mixedreality/2025-01-01/proxy/model_checknameavailabilityresponse.go @@ -0,0 +1,10 @@ +package proxy + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailabilityResponse struct { + Message *string `json:"message,omitempty"` + NameAvailable bool `json:"nameAvailable"` + Reason *NameUnavailableReason `json:"reason,omitempty"` +} diff --git a/resource-manager/mixedreality/2025-01-01/proxy/model_mixedrealityaccountproperties.go b/resource-manager/mixedreality/2025-01-01/proxy/model_mixedrealityaccountproperties.go new file mode 100644 index 00000000000..cfd4f9c3667 --- /dev/null +++ b/resource-manager/mixedreality/2025-01-01/proxy/model_mixedrealityaccountproperties.go @@ -0,0 +1,10 @@ +package proxy + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MixedRealityAccountProperties struct { + AccountDomain *string `json:"accountDomain,omitempty"` + AccountId *string `json:"accountId,omitempty"` + StorageAccountName *string `json:"storageAccountName,omitempty"` +} diff --git a/resource-manager/mixedreality/2025-01-01/proxy/model_remoterenderingaccount.go b/resource-manager/mixedreality/2025-01-01/proxy/model_remoterenderingaccount.go new file mode 100644 index 00000000000..69a58208232 --- /dev/null +++ b/resource-manager/mixedreality/2025-01-01/proxy/model_remoterenderingaccount.go @@ -0,0 +1,23 @@ +package proxy + +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 RemoteRenderingAccount struct { + Id *string `json:"id,omitempty"` + Identity *identity.SystemAssigned `json:"identity,omitempty"` + Kind *Sku `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Plan *identity.SystemAssigned `json:"plan,omitempty"` + Properties *MixedRealityAccountProperties `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/mixedreality/2025-01-01/proxy/model_sku.go b/resource-manager/mixedreality/2025-01-01/proxy/model_sku.go new file mode 100644 index 00000000000..808f70e8e4f --- /dev/null +++ b/resource-manager/mixedreality/2025-01-01/proxy/model_sku.go @@ -0,0 +1,12 @@ +package proxy + +// 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/mixedreality/2025-01-01/proxy/predicates.go b/resource-manager/mixedreality/2025-01-01/proxy/predicates.go new file mode 100644 index 00000000000..991fea90eda --- /dev/null +++ b/resource-manager/mixedreality/2025-01-01/proxy/predicates.go @@ -0,0 +1,32 @@ +package proxy + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemoteRenderingAccountOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p RemoteRenderingAccountOperationPredicate) Matches(input RemoteRenderingAccount) 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/logz/2020-10-01/monitors/version.go b/resource-manager/mixedreality/2025-01-01/proxy/version.go similarity index 63% rename from resource-manager/logz/2020-10-01/monitors/version.go rename to resource-manager/mixedreality/2025-01-01/proxy/version.go index ee2f682b80a..ac203c9eca3 100644 --- a/resource-manager/logz/2020-10-01/monitors/version.go +++ b/resource-manager/mixedreality/2025-01-01/proxy/version.go @@ -1,10 +1,10 @@ -package monitors +package proxy // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. -const defaultApiVersion = "2020-10-01" +const defaultApiVersion = "2025-01-01" func userAgent() string { - return "hashicorp/go-azure-sdk/monitors/2020-10-01" + return "hashicorp/go-azure-sdk/proxy/2025-01-01" } diff --git a/resource-manager/mixedreality/2025-01-01/resource/README.md b/resource-manager/mixedreality/2025-01-01/resource/README.md new file mode 100644 index 00000000000..e92eb2becac --- /dev/null +++ b/resource-manager/mixedreality/2025-01-01/resource/README.md @@ -0,0 +1,129 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/mixedreality/2025-01-01/resource` Documentation + +The `resource` SDK allows for interaction with Azure Resource Manager `mixedreality` (API Version `2025-01-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/mixedreality/2025-01-01/resource" +``` + + +### Client Initialization + +```go +client := resource.NewResourceClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ResourceClient.RemoteRenderingAccountsCreate` + +```go +ctx := context.TODO() +id := resource.NewRemoteRenderingAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "remoteRenderingAccountName") + +payload := resource.RemoteRenderingAccount{ + // ... +} + + +read, err := client.RemoteRenderingAccountsCreate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceClient.RemoteRenderingAccountsDelete` + +```go +ctx := context.TODO() +id := resource.NewRemoteRenderingAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "remoteRenderingAccountName") + +read, err := client.RemoteRenderingAccountsDelete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceClient.RemoteRenderingAccountsGet` + +```go +ctx := context.TODO() +id := resource.NewRemoteRenderingAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "remoteRenderingAccountName") + +read, err := client.RemoteRenderingAccountsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceClient.RemoteRenderingAccountsListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.RemoteRenderingAccountsListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.RemoteRenderingAccountsListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ResourceClient.RemoteRenderingAccountsListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.RemoteRenderingAccountsListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.RemoteRenderingAccountsListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ResourceClient.RemoteRenderingAccountsUpdate` + +```go +ctx := context.TODO() +id := resource.NewRemoteRenderingAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "remoteRenderingAccountName") + +payload := resource.RemoteRenderingAccount{ + // ... +} + + +read, err := client.RemoteRenderingAccountsUpdate(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/logz/2020-10-01/tagrules/client.go b/resource-manager/mixedreality/2025-01-01/resource/client.go similarity index 61% rename from resource-manager/logz/2020-10-01/tagrules/client.go rename to resource-manager/mixedreality/2025-01-01/resource/client.go index 1353e3786ef..672e189b06e 100644 --- a/resource-manager/logz/2020-10-01/tagrules/client.go +++ b/resource-manager/mixedreality/2025-01-01/resource/client.go @@ -1,4 +1,4 @@ -package tagrules +package resource import ( "fmt" @@ -10,17 +10,17 @@ import ( // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. -type TagRulesClient struct { +type ResourceClient struct { Client *resourcemanager.Client } -func NewTagRulesClientWithBaseURI(sdkApi sdkEnv.Api) (*TagRulesClient, error) { - client, err := resourcemanager.NewClient(sdkApi, "tagrules", defaultApiVersion) +func NewResourceClientWithBaseURI(sdkApi sdkEnv.Api) (*ResourceClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "resource", defaultApiVersion) if err != nil { - return nil, fmt.Errorf("instantiating TagRulesClient: %+v", err) + return nil, fmt.Errorf("instantiating ResourceClient: %+v", err) } - return &TagRulesClient{ + return &ResourceClient{ Client: client, }, nil } diff --git a/resource-manager/mixedreality/2025-01-01/resource/constants.go b/resource-manager/mixedreality/2025-01-01/resource/constants.go new file mode 100644 index 00000000000..43e22f34c40 --- /dev/null +++ b/resource-manager/mixedreality/2025-01-01/resource/constants.go @@ -0,0 +1,57 @@ +package resource + +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 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/mixedreality/2025-01-01/resource/id_remoterenderingaccount.go b/resource-manager/mixedreality/2025-01-01/resource/id_remoterenderingaccount.go new file mode 100644 index 00000000000..7573ded1718 --- /dev/null +++ b/resource-manager/mixedreality/2025-01-01/resource/id_remoterenderingaccount.go @@ -0,0 +1,130 @@ +package resource + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RemoteRenderingAccountId{}) +} + +var _ resourceids.ResourceId = &RemoteRenderingAccountId{} + +// RemoteRenderingAccountId is a struct representing the Resource ID for a Remote Rendering Account +type RemoteRenderingAccountId struct { + SubscriptionId string + ResourceGroupName string + RemoteRenderingAccountName string +} + +// NewRemoteRenderingAccountID returns a new RemoteRenderingAccountId struct +func NewRemoteRenderingAccountID(subscriptionId string, resourceGroupName string, remoteRenderingAccountName string) RemoteRenderingAccountId { + return RemoteRenderingAccountId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + RemoteRenderingAccountName: remoteRenderingAccountName, + } +} + +// ParseRemoteRenderingAccountID parses 'input' into a RemoteRenderingAccountId +func ParseRemoteRenderingAccountID(input string) (*RemoteRenderingAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&RemoteRenderingAccountId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RemoteRenderingAccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRemoteRenderingAccountIDInsensitively parses 'input' case-insensitively into a RemoteRenderingAccountId +// note: this method should only be used for API response data and not user input +func ParseRemoteRenderingAccountIDInsensitively(input string) (*RemoteRenderingAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&RemoteRenderingAccountId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RemoteRenderingAccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RemoteRenderingAccountId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.RemoteRenderingAccountName, ok = input.Parsed["remoteRenderingAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "remoteRenderingAccountName", input) + } + + return nil +} + +// ValidateRemoteRenderingAccountID checks that 'input' can be parsed as a Remote Rendering Account ID +func ValidateRemoteRenderingAccountID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRemoteRenderingAccountID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Remote Rendering Account ID +func (id RemoteRenderingAccountId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MixedReality/remoteRenderingAccounts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.RemoteRenderingAccountName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Remote Rendering Account ID +func (id RemoteRenderingAccountId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMixedReality", "Microsoft.MixedReality", "Microsoft.MixedReality"), + resourceids.StaticSegment("staticRemoteRenderingAccounts", "remoteRenderingAccounts", "remoteRenderingAccounts"), + resourceids.UserSpecifiedSegment("remoteRenderingAccountName", "remoteRenderingAccountName"), + } +} + +// String returns a human-readable description of this Remote Rendering Account ID +func (id RemoteRenderingAccountId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Remote Rendering Account Name: %q", id.RemoteRenderingAccountName), + } + return fmt.Sprintf("Remote Rendering Account (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/logz/2020-10-01/singlesignon/id_monitor_test.go b/resource-manager/mixedreality/2025-01-01/resource/id_remoterenderingaccount_test.go similarity index 62% rename from resource-manager/logz/2020-10-01/singlesignon/id_monitor_test.go rename to resource-manager/mixedreality/2025-01-01/resource/id_remoterenderingaccount_test.go index 3a92bc0cb18..dde33490d8e 100644 --- a/resource-manager/logz/2020-10-01/singlesignon/id_monitor_test.go +++ b/resource-manager/mixedreality/2025-01-01/resource/id_remoterenderingaccount_test.go @@ -1,4 +1,4 @@ -package singlesignon +package resource import ( "testing" @@ -9,10 +9,10 @@ import ( // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. -var _ resourceids.ResourceId = &MonitorId{} +var _ resourceids.ResourceId = &RemoteRenderingAccountId{} -func TestNewMonitorID(t *testing.T) { - id := NewMonitorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName") +func TestNewRemoteRenderingAccountID(t *testing.T) { + id := NewRemoteRenderingAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "remoteRenderingAccountName") if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") @@ -22,24 +22,24 @@ func TestNewMonitorID(t *testing.T) { t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") } - if id.MonitorName != "monitorName" { - t.Fatalf("Expected %q but got %q for Segment 'MonitorName'", id.MonitorName, "monitorName") + if id.RemoteRenderingAccountName != "remoteRenderingAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'RemoteRenderingAccountName'", id.RemoteRenderingAccountName, "remoteRenderingAccountName") } } -func TestFormatMonitorID(t *testing.T) { - actual := NewMonitorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName" +func TestFormatRemoteRenderingAccountID(t *testing.T) { + actual := NewRemoteRenderingAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "remoteRenderingAccountName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MixedReality/remoteRenderingAccounts/remoteRenderingAccountName" if actual != expected { t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) } } -func TestParseMonitorID(t *testing.T) { +func TestParseRemoteRenderingAccountID(t *testing.T) { testData := []struct { Input string Error bool - Expected *MonitorId + Expected *RemoteRenderingAccountId }{ { // Incomplete URI @@ -73,33 +73,33 @@ func TestParseMonitorID(t *testing.T) { }, { // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MixedReality", Error: true, }, { // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MixedReality/remoteRenderingAccounts", Error: true, }, { // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName", - Expected: &MonitorId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - MonitorName: "monitorName", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MixedReality/remoteRenderingAccounts/remoteRenderingAccountName", + Expected: &RemoteRenderingAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RemoteRenderingAccountName: "remoteRenderingAccountName", }, }, { // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/extra", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MixedReality/remoteRenderingAccounts/remoteRenderingAccountName/extra", Error: true, }, } for _, v := range testData { t.Logf("[DEBUG] Testing %q", v.Input) - actual, err := ParseMonitorID(v.Input) + actual, err := ParseRemoteRenderingAccountID(v.Input) if err != nil { if v.Error { continue @@ -119,18 +119,18 @@ func TestParseMonitorID(t *testing.T) { t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) } - if actual.MonitorName != v.Expected.MonitorName { - t.Fatalf("Expected %q but got %q for MonitorName", v.Expected.MonitorName, actual.MonitorName) + if actual.RemoteRenderingAccountName != v.Expected.RemoteRenderingAccountName { + t.Fatalf("Expected %q but got %q for RemoteRenderingAccountName", v.Expected.RemoteRenderingAccountName, actual.RemoteRenderingAccountName) } } } -func TestParseMonitorIDInsensitively(t *testing.T) { +func TestParseRemoteRenderingAccountIDInsensitively(t *testing.T) { testData := []struct { Input string Error bool - Expected *MonitorId + Expected *RemoteRenderingAccountId }{ { // Incomplete URI @@ -189,57 +189,57 @@ func TestParseMonitorIDInsensitively(t *testing.T) { }, { // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MixedReality", Error: true, }, { // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ", + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mIxEdReAlItY", Error: true, }, { // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MixedReality/remoteRenderingAccounts", Error: true, }, { // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ/mOnItOrS", + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mIxEdReAlItY/rEmOtErEnDeRiNgAcCoUnTs", Error: true, }, { // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName", - Expected: &MonitorId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - MonitorName: "monitorName", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MixedReality/remoteRenderingAccounts/remoteRenderingAccountName", + Expected: &RemoteRenderingAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RemoteRenderingAccountName: "remoteRenderingAccountName", }, }, { // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/extra", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MixedReality/remoteRenderingAccounts/remoteRenderingAccountName/extra", Error: true, }, { // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ/mOnItOrS/mOnItOrNaMe", - Expected: &MonitorId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - MonitorName: "mOnItOrNaMe", + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mIxEdReAlItY/rEmOtErEnDeRiNgAcCoUnTs/rEmOtErEnDeRiNgAcCoUnTnAmE", + Expected: &RemoteRenderingAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + RemoteRenderingAccountName: "rEmOtErEnDeRiNgAcCoUnTnAmE", }, }, { // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ/mOnItOrS/mOnItOrNaMe/extra", + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mIxEdReAlItY/rEmOtErEnDeRiNgAcCoUnTs/rEmOtErEnDeRiNgAcCoUnTnAmE/extra", Error: true, }, } for _, v := range testData { t.Logf("[DEBUG] Testing %q", v.Input) - actual, err := ParseMonitorIDInsensitively(v.Input) + actual, err := ParseRemoteRenderingAccountIDInsensitively(v.Input) if err != nil { if v.Error { continue @@ -259,17 +259,17 @@ func TestParseMonitorIDInsensitively(t *testing.T) { t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) } - if actual.MonitorName != v.Expected.MonitorName { - t.Fatalf("Expected %q but got %q for MonitorName", v.Expected.MonitorName, actual.MonitorName) + if actual.RemoteRenderingAccountName != v.Expected.RemoteRenderingAccountName { + t.Fatalf("Expected %q but got %q for RemoteRenderingAccountName", v.Expected.RemoteRenderingAccountName, actual.RemoteRenderingAccountName) } } } -func TestSegmentsForMonitorId(t *testing.T) { - segments := MonitorId{}.Segments() +func TestSegmentsForRemoteRenderingAccountId(t *testing.T) { + segments := RemoteRenderingAccountId{}.Segments() if len(segments) == 0 { - t.Fatalf("MonitorId has no segments") + t.Fatalf("RemoteRenderingAccountId has no segments") } uniqueNames := make(map[string]struct{}, 0) diff --git a/resource-manager/mixedreality/2025-01-01/resource/method_remoterenderingaccountscreate.go b/resource-manager/mixedreality/2025-01-01/resource/method_remoterenderingaccountscreate.go new file mode 100644 index 00000000000..570a9c1a924 --- /dev/null +++ b/resource-manager/mixedreality/2025-01-01/resource/method_remoterenderingaccountscreate.go @@ -0,0 +1,58 @@ +package resource + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemoteRenderingAccountsCreateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RemoteRenderingAccount +} + +// RemoteRenderingAccountsCreate ... +func (c ResourceClient) RemoteRenderingAccountsCreate(ctx context.Context, id RemoteRenderingAccountId, input RemoteRenderingAccount) (result RemoteRenderingAccountsCreateOperationResponse, 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 RemoteRenderingAccount + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/mixedreality/2025-01-01/resource/method_remoterenderingaccountsdelete.go b/resource-manager/mixedreality/2025-01-01/resource/method_remoterenderingaccountsdelete.go new file mode 100644 index 00000000000..d92a1ed8507 --- /dev/null +++ b/resource-manager/mixedreality/2025-01-01/resource/method_remoterenderingaccountsdelete.go @@ -0,0 +1,47 @@ +package resource + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemoteRenderingAccountsDeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// RemoteRenderingAccountsDelete ... +func (c ResourceClient) RemoteRenderingAccountsDelete(ctx context.Context, id RemoteRenderingAccountId) (result RemoteRenderingAccountsDeleteOperationResponse, 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/mixedreality/2025-01-01/resource/method_remoterenderingaccountsget.go b/resource-manager/mixedreality/2025-01-01/resource/method_remoterenderingaccountsget.go new file mode 100644 index 00000000000..d60c553dd77 --- /dev/null +++ b/resource-manager/mixedreality/2025-01-01/resource/method_remoterenderingaccountsget.go @@ -0,0 +1,53 @@ +package resource + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemoteRenderingAccountsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RemoteRenderingAccount +} + +// RemoteRenderingAccountsGet ... +func (c ResourceClient) RemoteRenderingAccountsGet(ctx context.Context, id RemoteRenderingAccountId) (result RemoteRenderingAccountsGetOperationResponse, 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 RemoteRenderingAccount + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/mixedreality/2025-01-01/resource/method_remoterenderingaccountslistbyresourcegroup.go b/resource-manager/mixedreality/2025-01-01/resource/method_remoterenderingaccountslistbyresourcegroup.go new file mode 100644 index 00000000000..3a0baec90fa --- /dev/null +++ b/resource-manager/mixedreality/2025-01-01/resource/method_remoterenderingaccountslistbyresourcegroup.go @@ -0,0 +1,106 @@ +package resource + +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 RemoteRenderingAccountsListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RemoteRenderingAccount +} + +type RemoteRenderingAccountsListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []RemoteRenderingAccount +} + +type RemoteRenderingAccountsListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *RemoteRenderingAccountsListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// RemoteRenderingAccountsListByResourceGroup ... +func (c ResourceClient) RemoteRenderingAccountsListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result RemoteRenderingAccountsListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &RemoteRenderingAccountsListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.MixedReality/remoteRenderingAccounts", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]RemoteRenderingAccount `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// RemoteRenderingAccountsListByResourceGroupComplete retrieves all the results into a single object +func (c ResourceClient) RemoteRenderingAccountsListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (RemoteRenderingAccountsListByResourceGroupCompleteResult, error) { + return c.RemoteRenderingAccountsListByResourceGroupCompleteMatchingPredicate(ctx, id, RemoteRenderingAccountOperationPredicate{}) +} + +// RemoteRenderingAccountsListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceClient) RemoteRenderingAccountsListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate RemoteRenderingAccountOperationPredicate) (result RemoteRenderingAccountsListByResourceGroupCompleteResult, err error) { + items := make([]RemoteRenderingAccount, 0) + + resp, err := c.RemoteRenderingAccountsListByResourceGroup(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 = RemoteRenderingAccountsListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/mixedreality/2025-01-01/resource/method_remoterenderingaccountslistbysubscription.go b/resource-manager/mixedreality/2025-01-01/resource/method_remoterenderingaccountslistbysubscription.go new file mode 100644 index 00000000000..05a16e1bcc4 --- /dev/null +++ b/resource-manager/mixedreality/2025-01-01/resource/method_remoterenderingaccountslistbysubscription.go @@ -0,0 +1,106 @@ +package resource + +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 RemoteRenderingAccountsListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RemoteRenderingAccount +} + +type RemoteRenderingAccountsListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []RemoteRenderingAccount +} + +type RemoteRenderingAccountsListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *RemoteRenderingAccountsListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// RemoteRenderingAccountsListBySubscription ... +func (c ResourceClient) RemoteRenderingAccountsListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result RemoteRenderingAccountsListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &RemoteRenderingAccountsListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.MixedReality/remoteRenderingAccounts", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]RemoteRenderingAccount `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// RemoteRenderingAccountsListBySubscriptionComplete retrieves all the results into a single object +func (c ResourceClient) RemoteRenderingAccountsListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (RemoteRenderingAccountsListBySubscriptionCompleteResult, error) { + return c.RemoteRenderingAccountsListBySubscriptionCompleteMatchingPredicate(ctx, id, RemoteRenderingAccountOperationPredicate{}) +} + +// RemoteRenderingAccountsListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceClient) RemoteRenderingAccountsListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate RemoteRenderingAccountOperationPredicate) (result RemoteRenderingAccountsListBySubscriptionCompleteResult, err error) { + items := make([]RemoteRenderingAccount, 0) + + resp, err := c.RemoteRenderingAccountsListBySubscription(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 = RemoteRenderingAccountsListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/mixedreality/2025-01-01/resource/method_remoterenderingaccountsupdate.go b/resource-manager/mixedreality/2025-01-01/resource/method_remoterenderingaccountsupdate.go new file mode 100644 index 00000000000..a690cc24266 --- /dev/null +++ b/resource-manager/mixedreality/2025-01-01/resource/method_remoterenderingaccountsupdate.go @@ -0,0 +1,57 @@ +package resource + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemoteRenderingAccountsUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RemoteRenderingAccount +} + +// RemoteRenderingAccountsUpdate ... +func (c ResourceClient) RemoteRenderingAccountsUpdate(ctx context.Context, id RemoteRenderingAccountId, input RemoteRenderingAccount) (result RemoteRenderingAccountsUpdateOperationResponse, 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 RemoteRenderingAccount + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/mixedreality/2025-01-01/resource/model_mixedrealityaccountproperties.go b/resource-manager/mixedreality/2025-01-01/resource/model_mixedrealityaccountproperties.go new file mode 100644 index 00000000000..38d0a1ed639 --- /dev/null +++ b/resource-manager/mixedreality/2025-01-01/resource/model_mixedrealityaccountproperties.go @@ -0,0 +1,10 @@ +package resource + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MixedRealityAccountProperties struct { + AccountDomain *string `json:"accountDomain,omitempty"` + AccountId *string `json:"accountId,omitempty"` + StorageAccountName *string `json:"storageAccountName,omitempty"` +} diff --git a/resource-manager/mixedreality/2025-01-01/resource/model_remoterenderingaccount.go b/resource-manager/mixedreality/2025-01-01/resource/model_remoterenderingaccount.go new file mode 100644 index 00000000000..976e458637d --- /dev/null +++ b/resource-manager/mixedreality/2025-01-01/resource/model_remoterenderingaccount.go @@ -0,0 +1,23 @@ +package resource + +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 RemoteRenderingAccount struct { + Id *string `json:"id,omitempty"` + Identity *identity.SystemAssigned `json:"identity,omitempty"` + Kind *Sku `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Plan *identity.SystemAssigned `json:"plan,omitempty"` + Properties *MixedRealityAccountProperties `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/mixedreality/2025-01-01/resource/model_sku.go b/resource-manager/mixedreality/2025-01-01/resource/model_sku.go new file mode 100644 index 00000000000..182c316eff9 --- /dev/null +++ b/resource-manager/mixedreality/2025-01-01/resource/model_sku.go @@ -0,0 +1,12 @@ +package resource + +// 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/mixedreality/2025-01-01/resource/predicates.go b/resource-manager/mixedreality/2025-01-01/resource/predicates.go new file mode 100644 index 00000000000..a2d799f7e32 --- /dev/null +++ b/resource-manager/mixedreality/2025-01-01/resource/predicates.go @@ -0,0 +1,32 @@ +package resource + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemoteRenderingAccountOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p RemoteRenderingAccountOperationPredicate) Matches(input RemoteRenderingAccount) 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/logz/2020-10-01/tagrules/version.go b/resource-manager/mixedreality/2025-01-01/resource/version.go similarity index 63% rename from resource-manager/logz/2020-10-01/tagrules/version.go rename to resource-manager/mixedreality/2025-01-01/resource/version.go index 9dab22f6b6f..ca3a07c877c 100644 --- a/resource-manager/logz/2020-10-01/tagrules/version.go +++ b/resource-manager/mixedreality/2025-01-01/resource/version.go @@ -1,10 +1,10 @@ -package tagrules +package resource // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. -const defaultApiVersion = "2020-10-01" +const defaultApiVersion = "2025-01-01" func userAgent() string { - return "hashicorp/go-azure-sdk/tagrules/2020-10-01" + return "hashicorp/go-azure-sdk/resource/2025-01-01" } diff --git a/resource-manager/network/2024-05-01/networkmanageractiveconfigurations/constants.go b/resource-manager/network/2024-05-01/networkmanageractiveconfigurations/constants.go index c9291fb2fab..793caeabedc 100644 --- a/resource-manager/network/2024-05-01/networkmanageractiveconfigurations/constants.go +++ b/resource-manager/network/2024-05-01/networkmanageractiveconfigurations/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, diff --git a/resource-manager/network/2024-05-01/networkmanageractiveconnectivityconfigurations/constants.go b/resource-manager/network/2024-05-01/networkmanageractiveconnectivityconfigurations/constants.go index 642ecd4a0bd..6f3a6c4f554 100644 --- a/resource-manager/network/2024-05-01/networkmanageractiveconnectivityconfigurations/constants.go +++ b/resource-manager/network/2024-05-01/networkmanageractiveconnectivityconfigurations/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/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, diff --git a/resource-manager/postgresql/2024-08-01/replicas/model_server.go b/resource-manager/postgresql/2024-08-01/replicas/model_server.go index af7f86d28e5..097dc475576 100644 --- a/resource-manager/postgresql/2024-08-01/replicas/model_server.go +++ b/resource-manager/postgresql/2024-08-01/replicas/model_server.go @@ -9,13 +9,13 @@ import ( // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type Server struct { - Id *string `json:"id,omitempty"` - Identity *identity.SystemOrUserAssignedMap `json:"identity,omitempty"` - Location string `json:"location"` - Name *string `json:"name,omitempty"` - Properties *ServerProperties `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"` + Id *string `json:"id,omitempty"` + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *ServerProperties `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/postgresql/2024-08-01/servers/model_server.go b/resource-manager/postgresql/2024-08-01/servers/model_server.go index 46a350e7d2b..0a9c2edfbb6 100644 --- a/resource-manager/postgresql/2024-08-01/servers/model_server.go +++ b/resource-manager/postgresql/2024-08-01/servers/model_server.go @@ -9,13 +9,13 @@ import ( // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type Server struct { - Id *string `json:"id,omitempty"` - Identity *identity.SystemOrUserAssignedMap `json:"identity,omitempty"` - Location string `json:"location"` - Name *string `json:"name,omitempty"` - Properties *ServerProperties `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"` + Id *string `json:"id,omitempty"` + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *ServerProperties `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/postgresql/2024-08-01/servers/model_serverforupdate.go b/resource-manager/postgresql/2024-08-01/servers/model_serverforupdate.go index 6ca8fde6b85..f45b84f8737 100644 --- a/resource-manager/postgresql/2024-08-01/servers/model_serverforupdate.go +++ b/resource-manager/postgresql/2024-08-01/servers/model_serverforupdate.go @@ -8,8 +8,8 @@ import ( // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type ServerForUpdate struct { - Identity *identity.SystemOrUserAssignedMap `json:"identity,omitempty"` - Properties *ServerPropertiesForUpdate `json:"properties,omitempty"` - Sku *Sku `json:"sku,omitempty"` - Tags *map[string]string `json:"tags,omitempty"` + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Properties *ServerPropertiesForUpdate `json:"properties,omitempty"` + Sku *Sku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` } diff --git a/resource-manager/resources/2025-03-01/client.go b/resource-manager/resources/2025-03-01/client.go new file mode 100644 index 00000000000..10c026567b4 --- /dev/null +++ b/resource-manager/resources/2025-03-01/client.go @@ -0,0 +1,73 @@ +package v2025_03_01 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/resource-manager/resources/2025-03-01/policyassignments" + "github.com/hashicorp/go-azure-sdk/resource-manager/resources/2025-03-01/policydefinitions" + "github.com/hashicorp/go-azure-sdk/resource-manager/resources/2025-03-01/policydefinitionversions" + "github.com/hashicorp/go-azure-sdk/resource-manager/resources/2025-03-01/policysetdefinitions" + "github.com/hashicorp/go-azure-sdk/resource-manager/resources/2025-03-01/policysetdefinitionversions" + "github.com/hashicorp/go-azure-sdk/resource-manager/resources/2025-03-01/policytokens" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + PolicyAssignments *policyassignments.PolicyAssignmentsClient + PolicyDefinitionVersions *policydefinitionversions.PolicyDefinitionVersionsClient + PolicyDefinitions *policydefinitions.PolicyDefinitionsClient + PolicySetDefinitionVersions *policysetdefinitionversions.PolicySetDefinitionVersionsClient + PolicySetDefinitions *policysetdefinitions.PolicySetDefinitionsClient + PolicyTokens *policytokens.PolicyTokensClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + policyAssignmentsClient, err := policyassignments.NewPolicyAssignmentsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building PolicyAssignments client: %+v", err) + } + configureFunc(policyAssignmentsClient.Client) + + policyDefinitionVersionsClient, err := policydefinitionversions.NewPolicyDefinitionVersionsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building PolicyDefinitionVersions client: %+v", err) + } + configureFunc(policyDefinitionVersionsClient.Client) + + policyDefinitionsClient, err := policydefinitions.NewPolicyDefinitionsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building PolicyDefinitions client: %+v", err) + } + configureFunc(policyDefinitionsClient.Client) + + policySetDefinitionVersionsClient, err := policysetdefinitionversions.NewPolicySetDefinitionVersionsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building PolicySetDefinitionVersions client: %+v", err) + } + configureFunc(policySetDefinitionVersionsClient.Client) + + policySetDefinitionsClient, err := policysetdefinitions.NewPolicySetDefinitionsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building PolicySetDefinitions client: %+v", err) + } + configureFunc(policySetDefinitionsClient.Client) + + policyTokensClient, err := policytokens.NewPolicyTokensClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building PolicyTokens client: %+v", err) + } + configureFunc(policyTokensClient.Client) + + return &Client{ + PolicyAssignments: policyAssignmentsClient, + PolicyDefinitionVersions: policyDefinitionVersionsClient, + PolicyDefinitions: policyDefinitionsClient, + PolicySetDefinitionVersions: policySetDefinitionVersionsClient, + PolicySetDefinitions: policySetDefinitionsClient, + PolicyTokens: policyTokensClient, + }, nil +} diff --git a/resource-manager/resources/2025-03-01/policyassignments/README.md b/resource-manager/resources/2025-03-01/policyassignments/README.md new file mode 100644 index 00000000000..892b49119d5 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policyassignments/README.md @@ -0,0 +1,237 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/resources/2025-03-01/policyassignments` Documentation + +The `policyassignments` SDK allows for interaction with Azure Resource Manager `resources` (API Version `2025-03-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/resources/2025-03-01/policyassignments" +``` + + +### Client Initialization + +```go +client := policyassignments.NewPolicyAssignmentsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PolicyAssignmentsClient.Create` + +```go +ctx := context.TODO() +id := policyassignments.NewScopedPolicyAssignmentID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", "policyAssignmentName") + +payload := policyassignments.PolicyAssignment{ + // ... +} + + +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: `PolicyAssignmentsClient.CreateById` + +```go +ctx := context.TODO() +id := policyassignments.NewPolicyAssignmentIdID("policyAssignmentId") + +payload := policyassignments.PolicyAssignment{ + // ... +} + + +read, err := client.CreateById(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PolicyAssignmentsClient.Delete` + +```go +ctx := context.TODO() +id := policyassignments.NewScopedPolicyAssignmentID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", "policyAssignmentName") + +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: `PolicyAssignmentsClient.DeleteById` + +```go +ctx := context.TODO() +id := policyassignments.NewPolicyAssignmentIdID("policyAssignmentId") + +read, err := client.DeleteById(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PolicyAssignmentsClient.Get` + +```go +ctx := context.TODO() +id := policyassignments.NewScopedPolicyAssignmentID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", "policyAssignmentName") + +read, err := client.Get(ctx, id, policyassignments.DefaultGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PolicyAssignmentsClient.GetById` + +```go +ctx := context.TODO() +id := policyassignments.NewPolicyAssignmentIdID("policyAssignmentId") + +read, err := client.GetById(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PolicyAssignmentsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id, policyassignments.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, policyassignments.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PolicyAssignmentsClient.ListForManagementGroup` + +```go +ctx := context.TODO() +id := commonids.NewManagementGroupID("groupId") + +// alternatively `client.ListForManagementGroup(ctx, id, policyassignments.DefaultListForManagementGroupOperationOptions())` can be used to do batched pagination +items, err := client.ListForManagementGroupComplete(ctx, id, policyassignments.DefaultListForManagementGroupOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PolicyAssignmentsClient.ListForResource` + +```go +ctx := context.TODO() +id := commonids.NewScopeID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group") + +// alternatively `client.ListForResource(ctx, id, policyassignments.DefaultListForResourceOperationOptions())` can be used to do batched pagination +items, err := client.ListForResourceComplete(ctx, id, policyassignments.DefaultListForResourceOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PolicyAssignmentsClient.ListForResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListForResourceGroup(ctx, id, policyassignments.DefaultListForResourceGroupOperationOptions())` can be used to do batched pagination +items, err := client.ListForResourceGroupComplete(ctx, id, policyassignments.DefaultListForResourceGroupOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PolicyAssignmentsClient.Update` + +```go +ctx := context.TODO() +id := policyassignments.NewScopedPolicyAssignmentID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", "policyAssignmentName") + +payload := policyassignments.PolicyAssignmentUpdate{ + // ... +} + + +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: `PolicyAssignmentsClient.UpdateById` + +```go +ctx := context.TODO() +id := policyassignments.NewPolicyAssignmentIdID("policyAssignmentId") + +payload := policyassignments.PolicyAssignmentUpdate{ + // ... +} + + +read, err := client.UpdateById(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/logz/2020-10-01/subaccount/client.go b/resource-manager/resources/2025-03-01/policyassignments/client.go similarity index 51% rename from resource-manager/logz/2020-10-01/subaccount/client.go rename to resource-manager/resources/2025-03-01/policyassignments/client.go index ac3d0c57052..402c2f10e04 100644 --- a/resource-manager/logz/2020-10-01/subaccount/client.go +++ b/resource-manager/resources/2025-03-01/policyassignments/client.go @@ -1,4 +1,4 @@ -package subaccount +package policyassignments import ( "fmt" @@ -10,17 +10,17 @@ import ( // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. -type SubAccountClient struct { +type PolicyAssignmentsClient struct { Client *resourcemanager.Client } -func NewSubAccountClientWithBaseURI(sdkApi sdkEnv.Api) (*SubAccountClient, error) { - client, err := resourcemanager.NewClient(sdkApi, "subaccount", defaultApiVersion) +func NewPolicyAssignmentsClientWithBaseURI(sdkApi sdkEnv.Api) (*PolicyAssignmentsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "policyassignments", defaultApiVersion) if err != nil { - return nil, fmt.Errorf("instantiating SubAccountClient: %+v", err) + return nil, fmt.Errorf("instantiating PolicyAssignmentsClient: %+v", err) } - return &SubAccountClient{ + return &PolicyAssignmentsClient{ Client: client, }, nil } diff --git a/resource-manager/resources/2025-03-01/policyassignments/constants.go b/resource-manager/resources/2025-03-01/policyassignments/constants.go new file mode 100644 index 00000000000..590323908da --- /dev/null +++ b/resource-manager/resources/2025-03-01/policyassignments/constants.go @@ -0,0 +1,189 @@ +package policyassignments + +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 AssignmentType string + +const ( + AssignmentTypeCustom AssignmentType = "Custom" + AssignmentTypeNotSpecified AssignmentType = "NotSpecified" + AssignmentTypeSystem AssignmentType = "System" + AssignmentTypeSystemHidden AssignmentType = "SystemHidden" +) + +func PossibleValuesForAssignmentType() []string { + return []string{ + string(AssignmentTypeCustom), + string(AssignmentTypeNotSpecified), + string(AssignmentTypeSystem), + string(AssignmentTypeSystemHidden), + } +} + +func (s *AssignmentType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAssignmentType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAssignmentType(input string) (*AssignmentType, error) { + vals := map[string]AssignmentType{ + "custom": AssignmentTypeCustom, + "notspecified": AssignmentTypeNotSpecified, + "system": AssignmentTypeSystem, + "systemhidden": AssignmentTypeSystemHidden, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AssignmentType(input) + return &out, nil +} + +type EnforcementMode string + +const ( + EnforcementModeDefault EnforcementMode = "Default" + EnforcementModeDoNotEnforce EnforcementMode = "DoNotEnforce" + EnforcementModeEnroll EnforcementMode = "Enroll" +) + +func PossibleValuesForEnforcementMode() []string { + return []string{ + string(EnforcementModeDefault), + string(EnforcementModeDoNotEnforce), + string(EnforcementModeEnroll), + } +} + +func (s *EnforcementMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEnforcementMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEnforcementMode(input string) (*EnforcementMode, error) { + vals := map[string]EnforcementMode{ + "default": EnforcementModeDefault, + "donotenforce": EnforcementModeDoNotEnforce, + "enroll": EnforcementModeEnroll, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EnforcementMode(input) + return &out, nil +} + +type OverrideKind string + +const ( + OverrideKindDefinitionVersion OverrideKind = "definitionVersion" + OverrideKindPolicyEffect OverrideKind = "policyEffect" +) + +func PossibleValuesForOverrideKind() []string { + return []string{ + string(OverrideKindDefinitionVersion), + string(OverrideKindPolicyEffect), + } +} + +func (s *OverrideKind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOverrideKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOverrideKind(input string) (*OverrideKind, error) { + vals := map[string]OverrideKind{ + "definitionversion": OverrideKindDefinitionVersion, + "policyeffect": OverrideKindPolicyEffect, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OverrideKind(input) + return &out, nil +} + +type SelectorKind string + +const ( + SelectorKindPolicyDefinitionReferenceId SelectorKind = "policyDefinitionReferenceId" + SelectorKindResourceLocation SelectorKind = "resourceLocation" + SelectorKindResourceType SelectorKind = "resourceType" + SelectorKindResourceWithoutLocation SelectorKind = "resourceWithoutLocation" +) + +func PossibleValuesForSelectorKind() []string { + return []string{ + string(SelectorKindPolicyDefinitionReferenceId), + string(SelectorKindResourceLocation), + string(SelectorKindResourceType), + string(SelectorKindResourceWithoutLocation), + } +} + +func (s *SelectorKind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSelectorKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSelectorKind(input string) (*SelectorKind, error) { + vals := map[string]SelectorKind{ + "policydefinitionreferenceid": SelectorKindPolicyDefinitionReferenceId, + "resourcelocation": SelectorKindResourceLocation, + "resourcetype": SelectorKindResourceType, + "resourcewithoutlocation": SelectorKindResourceWithoutLocation, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SelectorKind(input) + return &out, nil +} diff --git a/resource-manager/resources/2025-03-01/policyassignments/id_policyassignmentid.go b/resource-manager/resources/2025-03-01/policyassignments/id_policyassignmentid.go new file mode 100644 index 00000000000..9f1973f1f74 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policyassignments/id_policyassignmentid.go @@ -0,0 +1,109 @@ +package policyassignments + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PolicyAssignmentIdId{}) +} + +var _ resourceids.ResourceId = &PolicyAssignmentIdId{} + +// PolicyAssignmentIdId is a struct representing the Resource ID for a Policy Assignment Id +type PolicyAssignmentIdId struct { + PolicyAssignmentId string +} + +// NewPolicyAssignmentIdID returns a new PolicyAssignmentIdId struct +func NewPolicyAssignmentIdID(policyAssignmentId string) PolicyAssignmentIdId { + return PolicyAssignmentIdId{ + PolicyAssignmentId: policyAssignmentId, + } +} + +// ParsePolicyAssignmentIdID parses 'input' into a PolicyAssignmentIdId +func ParsePolicyAssignmentIdID(input string) (*PolicyAssignmentIdId, error) { + parser := resourceids.NewParserFromResourceIdType(&PolicyAssignmentIdId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PolicyAssignmentIdId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePolicyAssignmentIdIDInsensitively parses 'input' case-insensitively into a PolicyAssignmentIdId +// note: this method should only be used for API response data and not user input +func ParsePolicyAssignmentIdIDInsensitively(input string) (*PolicyAssignmentIdId, error) { + parser := resourceids.NewParserFromResourceIdType(&PolicyAssignmentIdId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PolicyAssignmentIdId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PolicyAssignmentIdId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.PolicyAssignmentId, ok = input.Parsed["policyAssignmentId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "policyAssignmentId", input) + } + + return nil +} + +// ValidatePolicyAssignmentIdID checks that 'input' can be parsed as a Policy Assignment Id ID +func ValidatePolicyAssignmentIdID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParsePolicyAssignmentIdID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Policy Assignment Id ID +func (id PolicyAssignmentIdId) ID() string { + fmtString := "/%s" + return fmt.Sprintf(fmtString, id.PolicyAssignmentId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Policy Assignment Id ID +func (id PolicyAssignmentIdId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.UserSpecifiedSegment("policyAssignmentId", "policyAssignmentId"), + } +} + +// String returns a human-readable description of this Policy Assignment Id ID +func (id PolicyAssignmentIdId) String() string { + components := []string{ + fmt.Sprintf("Policy Assignment: %q", id.PolicyAssignmentId), + } + return fmt.Sprintf("Policy Assignment Id (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/resources/2025-03-01/policyassignments/id_policyassignmentid_test.go b/resource-manager/resources/2025-03-01/policyassignments/id_policyassignmentid_test.go new file mode 100644 index 00000000000..a0042f45c6c --- /dev/null +++ b/resource-manager/resources/2025-03-01/policyassignments/id_policyassignmentid_test.go @@ -0,0 +1,147 @@ +package policyassignments + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PolicyAssignmentIdId{} + +func TestNewPolicyAssignmentIdID(t *testing.T) { + id := NewPolicyAssignmentIdID("policyAssignmentId") + + if id.PolicyAssignmentId != "policyAssignmentId" { + t.Fatalf("Expected %q but got %q for Segment 'PolicyAssignmentId'", id.PolicyAssignmentId, "policyAssignmentId") + } +} + +func TestFormatPolicyAssignmentIdID(t *testing.T) { + actual := NewPolicyAssignmentIdID("policyAssignmentId").ID() + expected := "/policyAssignmentId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePolicyAssignmentIdID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PolicyAssignmentIdId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Valid URI + Input: "/policyAssignmentId", + Expected: &PolicyAssignmentIdId{ + PolicyAssignmentId: "policyAssignmentId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/policyAssignmentId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePolicyAssignmentIdID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.PolicyAssignmentId != v.Expected.PolicyAssignmentId { + t.Fatalf("Expected %q but got %q for PolicyAssignmentId", v.Expected.PolicyAssignmentId, actual.PolicyAssignmentId) + } + + } +} + +func TestParsePolicyAssignmentIdIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PolicyAssignmentIdId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Valid URI + Input: "/policyAssignmentId", + Expected: &PolicyAssignmentIdId{ + PolicyAssignmentId: "policyAssignmentId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/policyAssignmentId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/pOlIcYaSsIgNmEnTiD", + Expected: &PolicyAssignmentIdId{ + PolicyAssignmentId: "pOlIcYaSsIgNmEnTiD", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/pOlIcYaSsIgNmEnTiD/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePolicyAssignmentIdIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.PolicyAssignmentId != v.Expected.PolicyAssignmentId { + t.Fatalf("Expected %q but got %q for PolicyAssignmentId", v.Expected.PolicyAssignmentId, actual.PolicyAssignmentId) + } + + } +} + +func TestSegmentsForPolicyAssignmentIdId(t *testing.T) { + segments := PolicyAssignmentIdId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PolicyAssignmentIdId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/resources/2025-03-01/policyassignments/id_scopedpolicyassignment.go b/resource-manager/resources/2025-03-01/policyassignments/id_scopedpolicyassignment.go new file mode 100644 index 00000000000..1f8f559c69b --- /dev/null +++ b/resource-manager/resources/2025-03-01/policyassignments/id_scopedpolicyassignment.go @@ -0,0 +1,120 @@ +package policyassignments + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ScopedPolicyAssignmentId{}) +} + +var _ resourceids.ResourceId = &ScopedPolicyAssignmentId{} + +// ScopedPolicyAssignmentId is a struct representing the Resource ID for a Scoped Policy Assignment +type ScopedPolicyAssignmentId struct { + Scope string + PolicyAssignmentName string +} + +// NewScopedPolicyAssignmentID returns a new ScopedPolicyAssignmentId struct +func NewScopedPolicyAssignmentID(scope string, policyAssignmentName string) ScopedPolicyAssignmentId { + return ScopedPolicyAssignmentId{ + Scope: scope, + PolicyAssignmentName: policyAssignmentName, + } +} + +// ParseScopedPolicyAssignmentID parses 'input' into a ScopedPolicyAssignmentId +func ParseScopedPolicyAssignmentID(input string) (*ScopedPolicyAssignmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&ScopedPolicyAssignmentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ScopedPolicyAssignmentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseScopedPolicyAssignmentIDInsensitively parses 'input' case-insensitively into a ScopedPolicyAssignmentId +// note: this method should only be used for API response data and not user input +func ParseScopedPolicyAssignmentIDInsensitively(input string) (*ScopedPolicyAssignmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&ScopedPolicyAssignmentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ScopedPolicyAssignmentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ScopedPolicyAssignmentId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.Scope, ok = input.Parsed["scope"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "scope", input) + } + + if id.PolicyAssignmentName, ok = input.Parsed["policyAssignmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "policyAssignmentName", input) + } + + return nil +} + +// ValidateScopedPolicyAssignmentID checks that 'input' can be parsed as a Scoped Policy Assignment ID +func ValidateScopedPolicyAssignmentID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseScopedPolicyAssignmentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Scoped Policy Assignment ID +func (id ScopedPolicyAssignmentId) ID() string { + fmtString := "/%s/providers/Microsoft.Authorization/policyAssignments/%s" + return fmt.Sprintf(fmtString, strings.TrimPrefix(id.Scope, "/"), id.PolicyAssignmentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Scoped Policy Assignment ID +func (id ScopedPolicyAssignmentId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.ScopeSegment("scope", "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftAuthorization", "Microsoft.Authorization", "Microsoft.Authorization"), + resourceids.StaticSegment("staticPolicyAssignments", "policyAssignments", "policyAssignments"), + resourceids.UserSpecifiedSegment("policyAssignmentName", "policyAssignmentName"), + } +} + +// String returns a human-readable description of this Scoped Policy Assignment ID +func (id ScopedPolicyAssignmentId) String() string { + components := []string{ + fmt.Sprintf("Scope: %q", id.Scope), + fmt.Sprintf("Policy Assignment Name: %q", id.PolicyAssignmentName), + } + return fmt.Sprintf("Scoped Policy Assignment (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/resources/2025-03-01/policyassignments/id_scopedpolicyassignment_test.go b/resource-manager/resources/2025-03-01/policyassignments/id_scopedpolicyassignment_test.go new file mode 100644 index 00000000000..c41d0c9b3fe --- /dev/null +++ b/resource-manager/resources/2025-03-01/policyassignments/id_scopedpolicyassignment_test.go @@ -0,0 +1,222 @@ +package policyassignments + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ScopedPolicyAssignmentId{} + +func TestNewScopedPolicyAssignmentID(t *testing.T) { + id := NewScopedPolicyAssignmentID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", "policyAssignmentName") + + if id.Scope != "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'Scope'", id.Scope, "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group") + } + + if id.PolicyAssignmentName != "policyAssignmentName" { + t.Fatalf("Expected %q but got %q for Segment 'PolicyAssignmentName'", id.PolicyAssignmentName, "policyAssignmentName") + } +} + +func TestFormatScopedPolicyAssignmentID(t *testing.T) { + actual := NewScopedPolicyAssignmentID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", "policyAssignmentName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseScopedPolicyAssignmentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ScopedPolicyAssignmentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers/Microsoft.Authorization/policyAssignments", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName", + Expected: &ScopedPolicyAssignmentId{ + Scope: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", + PolicyAssignmentName: "policyAssignmentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseScopedPolicyAssignmentID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.Scope != v.Expected.Scope { + t.Fatalf("Expected %q but got %q for Scope", v.Expected.Scope, actual.Scope) + } + + if actual.PolicyAssignmentName != v.Expected.PolicyAssignmentName { + t.Fatalf("Expected %q but got %q for PolicyAssignmentName", v.Expected.PolicyAssignmentName, actual.PolicyAssignmentName) + } + + } +} + +func TestParseScopedPolicyAssignmentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ScopedPolicyAssignmentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/sOmE-ReSoUrCe-gRoUp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/sOmE-ReSoUrCe-gRoUp/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/sOmE-ReSoUrCe-gRoUp/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers/Microsoft.Authorization/policyAssignments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/sOmE-ReSoUrCe-gRoUp/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYaSsIgNmEnTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName", + Expected: &ScopedPolicyAssignmentId{ + Scope: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", + PolicyAssignmentName: "policyAssignmentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/sOmE-ReSoUrCe-gRoUp/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYaSsIgNmEnTs/pOlIcYaSsIgNmEnTnAmE", + Expected: &ScopedPolicyAssignmentId{ + Scope: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/sOmE-ReSoUrCe-gRoUp", + PolicyAssignmentName: "pOlIcYaSsIgNmEnTnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/sOmE-ReSoUrCe-gRoUp/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYaSsIgNmEnTs/pOlIcYaSsIgNmEnTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseScopedPolicyAssignmentIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.Scope != v.Expected.Scope { + t.Fatalf("Expected %q but got %q for Scope", v.Expected.Scope, actual.Scope) + } + + if actual.PolicyAssignmentName != v.Expected.PolicyAssignmentName { + t.Fatalf("Expected %q but got %q for PolicyAssignmentName", v.Expected.PolicyAssignmentName, actual.PolicyAssignmentName) + } + + } +} + +func TestSegmentsForScopedPolicyAssignmentId(t *testing.T) { + segments := ScopedPolicyAssignmentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ScopedPolicyAssignmentId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/resources/2025-03-01/policyassignments/method_create.go b/resource-manager/resources/2025-03-01/policyassignments/method_create.go new file mode 100644 index 00000000000..38593afb7f2 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policyassignments/method_create.go @@ -0,0 +1,57 @@ +package policyassignments + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *PolicyAssignment +} + +// Create ... +func (c PolicyAssignmentsClient) Create(ctx context.Context, id ScopedPolicyAssignmentId, input PolicyAssignment) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PolicyAssignment + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/resources/2025-03-01/policyassignments/method_createbyid.go b/resource-manager/resources/2025-03-01/policyassignments/method_createbyid.go new file mode 100644 index 00000000000..a2a99e106f7 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policyassignments/method_createbyid.go @@ -0,0 +1,57 @@ +package policyassignments + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateByIdOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicyAssignment +} + +// CreateById ... +func (c PolicyAssignmentsClient) CreateById(ctx context.Context, id PolicyAssignmentIdId, input PolicyAssignment) (result CreateByIdOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PolicyAssignment + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/resources/2025-03-01/policyassignments/method_delete.go b/resource-manager/resources/2025-03-01/policyassignments/method_delete.go new file mode 100644 index 00000000000..27d5cdb250c --- /dev/null +++ b/resource-manager/resources/2025-03-01/policyassignments/method_delete.go @@ -0,0 +1,54 @@ +package policyassignments + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 + Model *PolicyAssignment +} + +// Delete ... +func (c PolicyAssignmentsClient) Delete(ctx context.Context, id ScopedPolicyAssignmentId) (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 + } + + var model PolicyAssignment + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/resources/2025-03-01/policyassignments/method_deletebyid.go b/resource-manager/resources/2025-03-01/policyassignments/method_deletebyid.go new file mode 100644 index 00000000000..336b50d1923 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policyassignments/method_deletebyid.go @@ -0,0 +1,54 @@ +package policyassignments + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteByIdOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicyAssignment +} + +// DeleteById ... +func (c PolicyAssignmentsClient) DeleteById(ctx context.Context, id PolicyAssignmentIdId) (result DeleteByIdOperationResponse, 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 + } + + var model PolicyAssignment + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/resources/2025-03-01/policyassignments/method_get.go b/resource-manager/resources/2025-03-01/policyassignments/method_get.go new file mode 100644 index 00000000000..200de70f626 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policyassignments/method_get.go @@ -0,0 +1,83 @@ +package policyassignments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *PolicyAssignment +} + +type GetOperationOptions struct { + Expand *string +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + return &out +} + +// Get ... +func (c PolicyAssignmentsClient) Get(ctx context.Context, id ScopedPolicyAssignmentId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 + } + + var model PolicyAssignment + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/resources/2025-03-01/policyassignments/method_getbyid.go b/resource-manager/resources/2025-03-01/policyassignments/method_getbyid.go new file mode 100644 index 00000000000..bafd322c39f --- /dev/null +++ b/resource-manager/resources/2025-03-01/policyassignments/method_getbyid.go @@ -0,0 +1,53 @@ +package policyassignments + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetByIdOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicyAssignment +} + +// GetById ... +func (c PolicyAssignmentsClient) GetById(ctx context.Context, id PolicyAssignmentIdId) (result GetByIdOperationResponse, 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 PolicyAssignment + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/resources/2025-03-01/policyassignments/method_list.go b/resource-manager/resources/2025-03-01/policyassignments/method_list.go new file mode 100644 index 00000000000..1bf05bf2214 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policyassignments/method_list.go @@ -0,0 +1,143 @@ +package policyassignments + +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 *[]PolicyAssignment +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []PolicyAssignment +} + +type ListOperationOptions struct { + Expand *string + Filter *string + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +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 PolicyAssignmentsClient) 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.Authorization/policyAssignments", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PolicyAssignment `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 PolicyAssignmentsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, PolicyAssignmentOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PolicyAssignmentsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions, predicate PolicyAssignmentOperationPredicate) (result ListCompleteResult, err error) { + items := make([]PolicyAssignment, 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/resources/2025-03-01/policyassignments/method_listformanagementgroup.go b/resource-manager/resources/2025-03-01/policyassignments/method_listformanagementgroup.go new file mode 100644 index 00000000000..eb58defe86a --- /dev/null +++ b/resource-manager/resources/2025-03-01/policyassignments/method_listformanagementgroup.go @@ -0,0 +1,143 @@ +package policyassignments + +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 ListForManagementGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PolicyAssignment +} + +type ListForManagementGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []PolicyAssignment +} + +type ListForManagementGroupOperationOptions struct { + Expand *string + Filter *string + Top *int64 +} + +func DefaultListForManagementGroupOperationOptions() ListForManagementGroupOperationOptions { + return ListForManagementGroupOperationOptions{} +} + +func (o ListForManagementGroupOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListForManagementGroupOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListForManagementGroupOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListForManagementGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListForManagementGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListForManagementGroup ... +func (c PolicyAssignmentsClient) ListForManagementGroup(ctx context.Context, id commonids.ManagementGroupId, options ListForManagementGroupOperationOptions) (result ListForManagementGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListForManagementGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Authorization/policyAssignments", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PolicyAssignment `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListForManagementGroupComplete retrieves all the results into a single object +func (c PolicyAssignmentsClient) ListForManagementGroupComplete(ctx context.Context, id commonids.ManagementGroupId, options ListForManagementGroupOperationOptions) (ListForManagementGroupCompleteResult, error) { + return c.ListForManagementGroupCompleteMatchingPredicate(ctx, id, options, PolicyAssignmentOperationPredicate{}) +} + +// ListForManagementGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PolicyAssignmentsClient) ListForManagementGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ManagementGroupId, options ListForManagementGroupOperationOptions, predicate PolicyAssignmentOperationPredicate) (result ListForManagementGroupCompleteResult, err error) { + items := make([]PolicyAssignment, 0) + + resp, err := c.ListForManagementGroup(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 = ListForManagementGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/resources/2025-03-01/policyassignments/method_listforresource.go b/resource-manager/resources/2025-03-01/policyassignments/method_listforresource.go new file mode 100644 index 00000000000..f938a1d7810 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policyassignments/method_listforresource.go @@ -0,0 +1,143 @@ +package policyassignments + +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 ListForResourceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PolicyAssignment +} + +type ListForResourceCompleteResult struct { + LatestHttpResponse *http.Response + Items []PolicyAssignment +} + +type ListForResourceOperationOptions struct { + Expand *string + Filter *string + Top *int64 +} + +func DefaultListForResourceOperationOptions() ListForResourceOperationOptions { + return ListForResourceOperationOptions{} +} + +func (o ListForResourceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListForResourceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListForResourceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListForResourceCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListForResourceCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListForResource ... +func (c PolicyAssignmentsClient) ListForResource(ctx context.Context, id commonids.ScopeId, options ListForResourceOperationOptions) (result ListForResourceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListForResourceCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Authorization/policyAssignments", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PolicyAssignment `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListForResourceComplete retrieves all the results into a single object +func (c PolicyAssignmentsClient) ListForResourceComplete(ctx context.Context, id commonids.ScopeId, options ListForResourceOperationOptions) (ListForResourceCompleteResult, error) { + return c.ListForResourceCompleteMatchingPredicate(ctx, id, options, PolicyAssignmentOperationPredicate{}) +} + +// ListForResourceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PolicyAssignmentsClient) ListForResourceCompleteMatchingPredicate(ctx context.Context, id commonids.ScopeId, options ListForResourceOperationOptions, predicate PolicyAssignmentOperationPredicate) (result ListForResourceCompleteResult, err error) { + items := make([]PolicyAssignment, 0) + + resp, err := c.ListForResource(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 = ListForResourceCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/resources/2025-03-01/policyassignments/method_listforresourcegroup.go b/resource-manager/resources/2025-03-01/policyassignments/method_listforresourcegroup.go new file mode 100644 index 00000000000..e8d4e7997c3 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policyassignments/method_listforresourcegroup.go @@ -0,0 +1,143 @@ +package policyassignments + +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 ListForResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PolicyAssignment +} + +type ListForResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []PolicyAssignment +} + +type ListForResourceGroupOperationOptions struct { + Expand *string + Filter *string + Top *int64 +} + +func DefaultListForResourceGroupOperationOptions() ListForResourceGroupOperationOptions { + return ListForResourceGroupOperationOptions{} +} + +func (o ListForResourceGroupOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListForResourceGroupOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListForResourceGroupOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListForResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListForResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListForResourceGroup ... +func (c PolicyAssignmentsClient) ListForResourceGroup(ctx context.Context, id commonids.ResourceGroupId, options ListForResourceGroupOperationOptions) (result ListForResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListForResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Authorization/policyAssignments", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PolicyAssignment `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListForResourceGroupComplete retrieves all the results into a single object +func (c PolicyAssignmentsClient) ListForResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId, options ListForResourceGroupOperationOptions) (ListForResourceGroupCompleteResult, error) { + return c.ListForResourceGroupCompleteMatchingPredicate(ctx, id, options, PolicyAssignmentOperationPredicate{}) +} + +// ListForResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PolicyAssignmentsClient) ListForResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, options ListForResourceGroupOperationOptions, predicate PolicyAssignmentOperationPredicate) (result ListForResourceGroupCompleteResult, err error) { + items := make([]PolicyAssignment, 0) + + resp, err := c.ListForResourceGroup(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 = ListForResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/logz/2020-10-01/subaccount/method_update.go b/resource-manager/resources/2025-03-01/policyassignments/method_update.go similarity index 79% rename from resource-manager/logz/2020-10-01/subaccount/method_update.go rename to resource-manager/resources/2025-03-01/policyassignments/method_update.go index 311bc71ead9..1f53d65281e 100644 --- a/resource-manager/logz/2020-10-01/subaccount/method_update.go +++ b/resource-manager/resources/2025-03-01/policyassignments/method_update.go @@ -1,4 +1,4 @@ -package subaccount +package policyassignments import ( "context" @@ -14,11 +14,11 @@ import ( type UpdateOperationResponse struct { HttpResponse *http.Response OData *odata.OData - Model *LogzMonitorResource + Model *PolicyAssignment } // Update ... -func (c SubAccountClient) Update(ctx context.Context, id AccountId, input LogzMonitorResourceUpdateParameters) (result UpdateOperationResponse, err error) { +func (c PolicyAssignmentsClient) Update(ctx context.Context, id ScopedPolicyAssignmentId, input PolicyAssignmentUpdate) (result UpdateOperationResponse, err error) { opts := client.RequestOptions{ ContentType: "application/json; charset=utf-8", ExpectedStatusCodes: []int{ @@ -47,7 +47,7 @@ func (c SubAccountClient) Update(ctx context.Context, id AccountId, input LogzMo return } - var model LogzMonitorResource + var model PolicyAssignment result.Model = &model if err = resp.Unmarshal(result.Model); err != nil { return diff --git a/resource-manager/resources/2025-03-01/policyassignments/method_updatebyid.go b/resource-manager/resources/2025-03-01/policyassignments/method_updatebyid.go new file mode 100644 index 00000000000..99e8c69a457 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policyassignments/method_updatebyid.go @@ -0,0 +1,57 @@ +package policyassignments + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateByIdOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicyAssignment +} + +// UpdateById ... +func (c PolicyAssignmentsClient) UpdateById(ctx context.Context, id PolicyAssignmentIdId, input PolicyAssignmentUpdate) (result UpdateByIdOperationResponse, 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 PolicyAssignment + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/resources/2025-03-01/policyassignments/model_noncompliancemessage.go b/resource-manager/resources/2025-03-01/policyassignments/model_noncompliancemessage.go new file mode 100644 index 00000000000..1a110b58070 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policyassignments/model_noncompliancemessage.go @@ -0,0 +1,9 @@ +package policyassignments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NonComplianceMessage struct { + Message string `json:"message"` + PolicyDefinitionReferenceId *string `json:"policyDefinitionReferenceId,omitempty"` +} diff --git a/resource-manager/resources/2025-03-01/policyassignments/model_override.go b/resource-manager/resources/2025-03-01/policyassignments/model_override.go new file mode 100644 index 00000000000..d189ffc2881 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policyassignments/model_override.go @@ -0,0 +1,10 @@ +package policyassignments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Override struct { + Kind *OverrideKind `json:"kind,omitempty"` + Selectors *[]Selector `json:"selectors,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/logz/2020-10-01/subaccount/model_monitorupdateproperties.go b/resource-manager/resources/2025-03-01/policyassignments/model_parametervaluesvalue.go similarity index 55% rename from resource-manager/logz/2020-10-01/subaccount/model_monitorupdateproperties.go rename to resource-manager/resources/2025-03-01/policyassignments/model_parametervaluesvalue.go index 2672ca66ba5..6c83cf1cdaa 100644 --- a/resource-manager/logz/2020-10-01/subaccount/model_monitorupdateproperties.go +++ b/resource-manager/resources/2025-03-01/policyassignments/model_parametervaluesvalue.go @@ -1,8 +1,8 @@ -package subaccount +package policyassignments // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. -type MonitorUpdateProperties struct { - MonitoringStatus *MonitoringStatus `json:"monitoringStatus,omitempty"` +type ParameterValuesValue struct { + Value *interface{} `json:"value,omitempty"` } diff --git a/resource-manager/resources/2025-03-01/policyassignments/model_policyassignment.go b/resource-manager/resources/2025-03-01/policyassignments/model_policyassignment.go new file mode 100644 index 00000000000..abe79336cd7 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policyassignments/model_policyassignment.go @@ -0,0 +1,19 @@ +package policyassignments + +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 PolicyAssignment struct { + Id *string `json:"id,omitempty"` + Identity *identity.SystemOrUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PolicyAssignmentProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/resources/2025-03-01/policyassignments/model_policyassignmentproperties.go b/resource-manager/resources/2025-03-01/policyassignments/model_policyassignmentproperties.go new file mode 100644 index 00000000000..062110e7cab --- /dev/null +++ b/resource-manager/resources/2025-03-01/policyassignments/model_policyassignmentproperties.go @@ -0,0 +1,23 @@ +package policyassignments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PolicyAssignmentProperties struct { + AssignmentType *AssignmentType `json:"assignmentType,omitempty"` + DefinitionVersion *string `json:"definitionVersion,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + EffectiveDefinitionVersion *string `json:"effectiveDefinitionVersion,omitempty"` + EnforcementMode *EnforcementMode `json:"enforcementMode,omitempty"` + InstanceId *string `json:"instanceId,omitempty"` + LatestDefinitionVersion *string `json:"latestDefinitionVersion,omitempty"` + Metadata *interface{} `json:"metadata,omitempty"` + NonComplianceMessages *[]NonComplianceMessage `json:"nonComplianceMessages,omitempty"` + NotScopes *[]string `json:"notScopes,omitempty"` + Overrides *[]Override `json:"overrides,omitempty"` + Parameters *map[string]ParameterValuesValue `json:"parameters,omitempty"` + PolicyDefinitionId *string `json:"policyDefinitionId,omitempty"` + ResourceSelectors *[]ResourceSelector `json:"resourceSelectors,omitempty"` + Scope *string `json:"scope,omitempty"` +} diff --git a/resource-manager/resources/2025-03-01/policyassignments/model_policyassignmentupdate.go b/resource-manager/resources/2025-03-01/policyassignments/model_policyassignmentupdate.go new file mode 100644 index 00000000000..46e84124dde --- /dev/null +++ b/resource-manager/resources/2025-03-01/policyassignments/model_policyassignmentupdate.go @@ -0,0 +1,14 @@ +package policyassignments + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PolicyAssignmentUpdate struct { + Identity *identity.SystemOrUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Properties *PolicyAssignmentUpdateProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/resources/2025-03-01/policyassignments/model_policyassignmentupdateproperties.go b/resource-manager/resources/2025-03-01/policyassignments/model_policyassignmentupdateproperties.go new file mode 100644 index 00000000000..e122904bc8c --- /dev/null +++ b/resource-manager/resources/2025-03-01/policyassignments/model_policyassignmentupdateproperties.go @@ -0,0 +1,9 @@ +package policyassignments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PolicyAssignmentUpdateProperties struct { + Overrides *[]Override `json:"overrides,omitempty"` + ResourceSelectors *[]ResourceSelector `json:"resourceSelectors,omitempty"` +} diff --git a/resource-manager/resources/2025-03-01/policyassignments/model_resourceselector.go b/resource-manager/resources/2025-03-01/policyassignments/model_resourceselector.go new file mode 100644 index 00000000000..128a6ba0295 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policyassignments/model_resourceselector.go @@ -0,0 +1,9 @@ +package policyassignments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceSelector struct { + Name *string `json:"name,omitempty"` + Selectors *[]Selector `json:"selectors,omitempty"` +} diff --git a/resource-manager/resources/2025-03-01/policyassignments/model_selector.go b/resource-manager/resources/2025-03-01/policyassignments/model_selector.go new file mode 100644 index 00000000000..918246f2a8a --- /dev/null +++ b/resource-manager/resources/2025-03-01/policyassignments/model_selector.go @@ -0,0 +1,10 @@ +package policyassignments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Selector struct { + In *[]string `json:"in,omitempty"` + Kind *SelectorKind `json:"kind,omitempty"` + NotIn *[]string `json:"notIn,omitempty"` +} diff --git a/resource-manager/resources/2025-03-01/policyassignments/predicates.go b/resource-manager/resources/2025-03-01/policyassignments/predicates.go new file mode 100644 index 00000000000..93f39469c95 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policyassignments/predicates.go @@ -0,0 +1,32 @@ +package policyassignments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PolicyAssignmentOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p PolicyAssignmentOperationPredicate) Matches(input PolicyAssignment) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/logz/2020-10-01/subaccount/version.go b/resource-manager/resources/2025-03-01/policyassignments/version.go similarity index 59% rename from resource-manager/logz/2020-10-01/subaccount/version.go rename to resource-manager/resources/2025-03-01/policyassignments/version.go index 665cebb59e4..fd0d1fcc181 100644 --- a/resource-manager/logz/2020-10-01/subaccount/version.go +++ b/resource-manager/resources/2025-03-01/policyassignments/version.go @@ -1,10 +1,10 @@ -package subaccount +package policyassignments // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. -const defaultApiVersion = "2020-10-01" +const defaultApiVersion = "2025-03-01" func userAgent() string { - return "hashicorp/go-azure-sdk/subaccount/2020-10-01" + return "hashicorp/go-azure-sdk/policyassignments/2025-03-01" } diff --git a/resource-manager/resources/2025-03-01/policydefinitions/README.md b/resource-manager/resources/2025-03-01/policydefinitions/README.md new file mode 100644 index 00000000000..2007c80c19f --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitions/README.md @@ -0,0 +1,194 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/resources/2025-03-01/policydefinitions` Documentation + +The `policydefinitions` SDK allows for interaction with Azure Resource Manager `resources` (API Version `2025-03-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/resources/2025-03-01/policydefinitions" +``` + + +### Client Initialization + +```go +client := policydefinitions.NewPolicyDefinitionsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PolicyDefinitionsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := policydefinitions.NewProviderPolicyDefinitionID("12345678-1234-9876-4563-123456789012", "policyDefinitionName") + +payload := policydefinitions.PolicyDefinition{ + // ... +} + + +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: `PolicyDefinitionsClient.CreateOrUpdateAtManagementGroup` + +```go +ctx := context.TODO() +id := policydefinitions.NewProviders2PolicyDefinitionID("managementGroupName", "policyDefinitionName") + +payload := policydefinitions.PolicyDefinition{ + // ... +} + + +read, err := client.CreateOrUpdateAtManagementGroup(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PolicyDefinitionsClient.Delete` + +```go +ctx := context.TODO() +id := policydefinitions.NewProviderPolicyDefinitionID("12345678-1234-9876-4563-123456789012", "policyDefinitionName") + +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: `PolicyDefinitionsClient.DeleteAtManagementGroup` + +```go +ctx := context.TODO() +id := policydefinitions.NewProviders2PolicyDefinitionID("managementGroupName", "policyDefinitionName") + +read, err := client.DeleteAtManagementGroup(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PolicyDefinitionsClient.Get` + +```go +ctx := context.TODO() +id := policydefinitions.NewProviderPolicyDefinitionID("12345678-1234-9876-4563-123456789012", "policyDefinitionName") + +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: `PolicyDefinitionsClient.GetAtManagementGroup` + +```go +ctx := context.TODO() +id := policydefinitions.NewProviders2PolicyDefinitionID("managementGroupName", "policyDefinitionName") + +read, err := client.GetAtManagementGroup(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PolicyDefinitionsClient.GetBuiltIn` + +```go +ctx := context.TODO() +id := policydefinitions.NewPolicyDefinitionID("policyDefinitionName") + +read, err := client.GetBuiltIn(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PolicyDefinitionsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id, policydefinitions.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, policydefinitions.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PolicyDefinitionsClient.ListBuiltIn` + +```go +ctx := context.TODO() + + +// alternatively `client.ListBuiltIn(ctx, policydefinitions.DefaultListBuiltInOperationOptions())` can be used to do batched pagination +items, err := client.ListBuiltInComplete(ctx, policydefinitions.DefaultListBuiltInOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PolicyDefinitionsClient.ListByManagementGroup` + +```go +ctx := context.TODO() +id := commonids.NewManagementGroupID("groupId") + +// alternatively `client.ListByManagementGroup(ctx, id, policydefinitions.DefaultListByManagementGroupOperationOptions())` can be used to do batched pagination +items, err := client.ListByManagementGroupComplete(ctx, id, policydefinitions.DefaultListByManagementGroupOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/resources/2025-03-01/policydefinitions/client.go b/resource-manager/resources/2025-03-01/policydefinitions/client.go new file mode 100644 index 00000000000..db6c48e0517 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitions/client.go @@ -0,0 +1,26 @@ +package policydefinitions + +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 PolicyDefinitionsClient struct { + Client *resourcemanager.Client +} + +func NewPolicyDefinitionsClientWithBaseURI(sdkApi sdkEnv.Api) (*PolicyDefinitionsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "policydefinitions", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PolicyDefinitionsClient: %+v", err) + } + + return &PolicyDefinitionsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/resources/2025-03-01/policydefinitions/constants.go b/resource-manager/resources/2025-03-01/policydefinitions/constants.go new file mode 100644 index 00000000000..f1261554600 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitions/constants.go @@ -0,0 +1,113 @@ +package policydefinitions + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ParameterType string + +const ( + ParameterTypeArray ParameterType = "Array" + ParameterTypeBoolean ParameterType = "Boolean" + ParameterTypeDateTime ParameterType = "DateTime" + ParameterTypeFloat ParameterType = "Float" + ParameterTypeInteger ParameterType = "Integer" + ParameterTypeObject ParameterType = "Object" + ParameterTypeString ParameterType = "String" +) + +func PossibleValuesForParameterType() []string { + return []string{ + string(ParameterTypeArray), + string(ParameterTypeBoolean), + string(ParameterTypeDateTime), + string(ParameterTypeFloat), + string(ParameterTypeInteger), + string(ParameterTypeObject), + string(ParameterTypeString), + } +} + +func (s *ParameterType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseParameterType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseParameterType(input string) (*ParameterType, error) { + vals := map[string]ParameterType{ + "array": ParameterTypeArray, + "boolean": ParameterTypeBoolean, + "datetime": ParameterTypeDateTime, + "float": ParameterTypeFloat, + "integer": ParameterTypeInteger, + "object": ParameterTypeObject, + "string": ParameterTypeString, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ParameterType(input) + return &out, nil +} + +type PolicyType string + +const ( + PolicyTypeBuiltIn PolicyType = "BuiltIn" + PolicyTypeCustom PolicyType = "Custom" + PolicyTypeNotSpecified PolicyType = "NotSpecified" + PolicyTypeStatic PolicyType = "Static" +) + +func PossibleValuesForPolicyType() []string { + return []string{ + string(PolicyTypeBuiltIn), + string(PolicyTypeCustom), + string(PolicyTypeNotSpecified), + string(PolicyTypeStatic), + } +} + +func (s *PolicyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePolicyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePolicyType(input string) (*PolicyType, error) { + vals := map[string]PolicyType{ + "builtin": PolicyTypeBuiltIn, + "custom": PolicyTypeCustom, + "notspecified": PolicyTypeNotSpecified, + "static": PolicyTypeStatic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PolicyType(input) + return &out, nil +} diff --git a/resource-manager/resources/2025-03-01/policydefinitions/id_policydefinition.go b/resource-manager/resources/2025-03-01/policydefinitions/id_policydefinition.go new file mode 100644 index 00000000000..eb235a023aa --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitions/id_policydefinition.go @@ -0,0 +1,112 @@ +package policydefinitions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PolicyDefinitionId{}) +} + +var _ resourceids.ResourceId = &PolicyDefinitionId{} + +// PolicyDefinitionId is a struct representing the Resource ID for a Policy Definition +type PolicyDefinitionId struct { + PolicyDefinitionName string +} + +// NewPolicyDefinitionID returns a new PolicyDefinitionId struct +func NewPolicyDefinitionID(policyDefinitionName string) PolicyDefinitionId { + return PolicyDefinitionId{ + PolicyDefinitionName: policyDefinitionName, + } +} + +// ParsePolicyDefinitionID parses 'input' into a PolicyDefinitionId +func ParsePolicyDefinitionID(input string) (*PolicyDefinitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PolicyDefinitionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PolicyDefinitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePolicyDefinitionIDInsensitively parses 'input' case-insensitively into a PolicyDefinitionId +// note: this method should only be used for API response data and not user input +func ParsePolicyDefinitionIDInsensitively(input string) (*PolicyDefinitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PolicyDefinitionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PolicyDefinitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PolicyDefinitionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.PolicyDefinitionName, ok = input.Parsed["policyDefinitionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "policyDefinitionName", input) + } + + return nil +} + +// ValidatePolicyDefinitionID checks that 'input' can be parsed as a Policy Definition ID +func ValidatePolicyDefinitionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParsePolicyDefinitionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Policy Definition ID +func (id PolicyDefinitionId) ID() string { + fmtString := "/providers/Microsoft.Authorization/policyDefinitions/%s" + return fmt.Sprintf(fmtString, id.PolicyDefinitionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Policy Definition ID +func (id PolicyDefinitionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftAuthorization", "Microsoft.Authorization", "Microsoft.Authorization"), + resourceids.StaticSegment("staticPolicyDefinitions", "policyDefinitions", "policyDefinitions"), + resourceids.UserSpecifiedSegment("policyDefinitionName", "policyDefinitionName"), + } +} + +// String returns a human-readable description of this Policy Definition ID +func (id PolicyDefinitionId) String() string { + components := []string{ + fmt.Sprintf("Policy Definition Name: %q", id.PolicyDefinitionName), + } + return fmt.Sprintf("Policy Definition (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/resources/2025-03-01/policydefinitions/id_policydefinition_test.go b/resource-manager/resources/2025-03-01/policydefinitions/id_policydefinition_test.go new file mode 100644 index 00000000000..42b541e06b9 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitions/id_policydefinition_test.go @@ -0,0 +1,192 @@ +package policydefinitions + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PolicyDefinitionId{} + +func TestNewPolicyDefinitionID(t *testing.T) { + id := NewPolicyDefinitionID("policyDefinitionName") + + if id.PolicyDefinitionName != "policyDefinitionName" { + t.Fatalf("Expected %q but got %q for Segment 'PolicyDefinitionName'", id.PolicyDefinitionName, "policyDefinitionName") + } +} + +func TestFormatPolicyDefinitionID(t *testing.T) { + actual := NewPolicyDefinitionID("policyDefinitionName").ID() + expected := "/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePolicyDefinitionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PolicyDefinitionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Authorization/policyDefinitions", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName", + Expected: &PolicyDefinitionId{ + PolicyDefinitionName: "policyDefinitionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePolicyDefinitionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.PolicyDefinitionName != v.Expected.PolicyDefinitionName { + t.Fatalf("Expected %q but got %q for PolicyDefinitionName", v.Expected.PolicyDefinitionName, actual.PolicyDefinitionName) + } + + } +} + +func TestParsePolicyDefinitionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PolicyDefinitionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Authorization/policyDefinitions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYdEfInItIoNs", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName", + Expected: &PolicyDefinitionId{ + PolicyDefinitionName: "policyDefinitionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYdEfInItIoNs/pOlIcYdEfInItIoNnAmE", + Expected: &PolicyDefinitionId{ + PolicyDefinitionName: "pOlIcYdEfInItIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYdEfInItIoNs/pOlIcYdEfInItIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePolicyDefinitionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.PolicyDefinitionName != v.Expected.PolicyDefinitionName { + t.Fatalf("Expected %q but got %q for PolicyDefinitionName", v.Expected.PolicyDefinitionName, actual.PolicyDefinitionName) + } + + } +} + +func TestSegmentsForPolicyDefinitionId(t *testing.T) { + segments := PolicyDefinitionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PolicyDefinitionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/resources/2025-03-01/policydefinitions/id_providerpolicydefinition.go b/resource-manager/resources/2025-03-01/policydefinitions/id_providerpolicydefinition.go new file mode 100644 index 00000000000..00a5aa0de7c --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitions/id_providerpolicydefinition.go @@ -0,0 +1,121 @@ +package policydefinitions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ProviderPolicyDefinitionId{}) +} + +var _ resourceids.ResourceId = &ProviderPolicyDefinitionId{} + +// ProviderPolicyDefinitionId is a struct representing the Resource ID for a Provider Policy Definition +type ProviderPolicyDefinitionId struct { + SubscriptionId string + PolicyDefinitionName string +} + +// NewProviderPolicyDefinitionID returns a new ProviderPolicyDefinitionId struct +func NewProviderPolicyDefinitionID(subscriptionId string, policyDefinitionName string) ProviderPolicyDefinitionId { + return ProviderPolicyDefinitionId{ + SubscriptionId: subscriptionId, + PolicyDefinitionName: policyDefinitionName, + } +} + +// ParseProviderPolicyDefinitionID parses 'input' into a ProviderPolicyDefinitionId +func ParseProviderPolicyDefinitionID(input string) (*ProviderPolicyDefinitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderPolicyDefinitionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderPolicyDefinitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProviderPolicyDefinitionIDInsensitively parses 'input' case-insensitively into a ProviderPolicyDefinitionId +// note: this method should only be used for API response data and not user input +func ParseProviderPolicyDefinitionIDInsensitively(input string) (*ProviderPolicyDefinitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderPolicyDefinitionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderPolicyDefinitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProviderPolicyDefinitionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.PolicyDefinitionName, ok = input.Parsed["policyDefinitionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "policyDefinitionName", input) + } + + return nil +} + +// ValidateProviderPolicyDefinitionID checks that 'input' can be parsed as a Provider Policy Definition ID +func ValidateProviderPolicyDefinitionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseProviderPolicyDefinitionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Provider Policy Definition ID +func (id ProviderPolicyDefinitionId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Authorization/policyDefinitions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.PolicyDefinitionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Provider Policy Definition ID +func (id ProviderPolicyDefinitionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftAuthorization", "Microsoft.Authorization", "Microsoft.Authorization"), + resourceids.StaticSegment("staticPolicyDefinitions", "policyDefinitions", "policyDefinitions"), + resourceids.UserSpecifiedSegment("policyDefinitionName", "policyDefinitionName"), + } +} + +// String returns a human-readable description of this Provider Policy Definition ID +func (id ProviderPolicyDefinitionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Policy Definition Name: %q", id.PolicyDefinitionName), + } + return fmt.Sprintf("Provider Policy Definition (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/resources/2025-03-01/policydefinitions/id_providerpolicydefinition_test.go b/resource-manager/resources/2025-03-01/policydefinitions/id_providerpolicydefinition_test.go new file mode 100644 index 00000000000..c86fe310910 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitions/id_providerpolicydefinition_test.go @@ -0,0 +1,237 @@ +package policydefinitions + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ProviderPolicyDefinitionId{} + +func TestNewProviderPolicyDefinitionID(t *testing.T) { + id := NewProviderPolicyDefinitionID("12345678-1234-9876-4563-123456789012", "policyDefinitionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.PolicyDefinitionName != "policyDefinitionName" { + t.Fatalf("Expected %q but got %q for Segment 'PolicyDefinitionName'", id.PolicyDefinitionName, "policyDefinitionName") + } +} + +func TestFormatProviderPolicyDefinitionID(t *testing.T) { + actual := NewProviderPolicyDefinitionID("12345678-1234-9876-4563-123456789012", "policyDefinitionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProviderPolicyDefinitionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderPolicyDefinitionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName", + Expected: &ProviderPolicyDefinitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicyDefinitionName: "policyDefinitionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderPolicyDefinitionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.PolicyDefinitionName != v.Expected.PolicyDefinitionName { + t.Fatalf("Expected %q but got %q for PolicyDefinitionName", v.Expected.PolicyDefinitionName, actual.PolicyDefinitionName) + } + + } +} + +func TestParseProviderPolicyDefinitionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderPolicyDefinitionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYdEfInItIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName", + Expected: &ProviderPolicyDefinitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicyDefinitionName: "policyDefinitionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYdEfInItIoNs/pOlIcYdEfInItIoNnAmE", + Expected: &ProviderPolicyDefinitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicyDefinitionName: "pOlIcYdEfInItIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYdEfInItIoNs/pOlIcYdEfInItIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderPolicyDefinitionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.PolicyDefinitionName != v.Expected.PolicyDefinitionName { + t.Fatalf("Expected %q but got %q for PolicyDefinitionName", v.Expected.PolicyDefinitionName, actual.PolicyDefinitionName) + } + + } +} + +func TestSegmentsForProviderPolicyDefinitionId(t *testing.T) { + segments := ProviderPolicyDefinitionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProviderPolicyDefinitionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/resources/2025-03-01/policydefinitions/id_providers2policydefinition.go b/resource-manager/resources/2025-03-01/policydefinitions/id_providers2policydefinition.go new file mode 100644 index 00000000000..065060a04a2 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitions/id_providers2policydefinition.go @@ -0,0 +1,123 @@ +package policydefinitions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&Providers2PolicyDefinitionId{}) +} + +var _ resourceids.ResourceId = &Providers2PolicyDefinitionId{} + +// Providers2PolicyDefinitionId is a struct representing the Resource ID for a Providers 2 Policy Definition +type Providers2PolicyDefinitionId struct { + ManagementGroupName string + PolicyDefinitionName string +} + +// NewProviders2PolicyDefinitionID returns a new Providers2PolicyDefinitionId struct +func NewProviders2PolicyDefinitionID(managementGroupName string, policyDefinitionName string) Providers2PolicyDefinitionId { + return Providers2PolicyDefinitionId{ + ManagementGroupName: managementGroupName, + PolicyDefinitionName: policyDefinitionName, + } +} + +// ParseProviders2PolicyDefinitionID parses 'input' into a Providers2PolicyDefinitionId +func ParseProviders2PolicyDefinitionID(input string) (*Providers2PolicyDefinitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&Providers2PolicyDefinitionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := Providers2PolicyDefinitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProviders2PolicyDefinitionIDInsensitively parses 'input' case-insensitively into a Providers2PolicyDefinitionId +// note: this method should only be used for API response data and not user input +func ParseProviders2PolicyDefinitionIDInsensitively(input string) (*Providers2PolicyDefinitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&Providers2PolicyDefinitionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := Providers2PolicyDefinitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *Providers2PolicyDefinitionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.ManagementGroupName, ok = input.Parsed["managementGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managementGroupName", input) + } + + if id.PolicyDefinitionName, ok = input.Parsed["policyDefinitionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "policyDefinitionName", input) + } + + return nil +} + +// ValidateProviders2PolicyDefinitionID checks that 'input' can be parsed as a Providers 2 Policy Definition ID +func ValidateProviders2PolicyDefinitionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseProviders2PolicyDefinitionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Providers 2 Policy Definition ID +func (id Providers2PolicyDefinitionId) ID() string { + fmtString := "/providers/Microsoft.Management/managementGroups/%s/providers/Microsoft.Authorization/policyDefinitions/%s" + return fmt.Sprintf(fmtString, id.ManagementGroupName, id.PolicyDefinitionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Providers 2 Policy Definition ID +func (id Providers2PolicyDefinitionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftManagement", "Microsoft.Management", "Microsoft.Management"), + resourceids.StaticSegment("staticManagementGroups", "managementGroups", "managementGroups"), + resourceids.UserSpecifiedSegment("managementGroupName", "managementGroupName"), + resourceids.StaticSegment("staticProviders2", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftAuthorization", "Microsoft.Authorization", "Microsoft.Authorization"), + resourceids.StaticSegment("staticPolicyDefinitions", "policyDefinitions", "policyDefinitions"), + resourceids.UserSpecifiedSegment("policyDefinitionName", "policyDefinitionName"), + } +} + +// String returns a human-readable description of this Providers 2 Policy Definition ID +func (id Providers2PolicyDefinitionId) String() string { + components := []string{ + fmt.Sprintf("Management Group Name: %q", id.ManagementGroupName), + fmt.Sprintf("Policy Definition Name: %q", id.PolicyDefinitionName), + } + return fmt.Sprintf("Providers 2 Policy Definition (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/resources/2025-03-01/policydefinitions/id_providers2policydefinition_test.go b/resource-manager/resources/2025-03-01/policydefinitions/id_providers2policydefinition_test.go new file mode 100644 index 00000000000..e4a03ec570d --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitions/id_providers2policydefinition_test.go @@ -0,0 +1,267 @@ +package policydefinitions + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &Providers2PolicyDefinitionId{} + +func TestNewProviders2PolicyDefinitionID(t *testing.T) { + id := NewProviders2PolicyDefinitionID("managementGroupName", "policyDefinitionName") + + if id.ManagementGroupName != "managementGroupName" { + t.Fatalf("Expected %q but got %q for Segment 'ManagementGroupName'", id.ManagementGroupName, "managementGroupName") + } + + if id.PolicyDefinitionName != "policyDefinitionName" { + t.Fatalf("Expected %q but got %q for Segment 'PolicyDefinitionName'", id.PolicyDefinitionName, "policyDefinitionName") + } +} + +func TestFormatProviders2PolicyDefinitionID(t *testing.T) { + actual := NewProviders2PolicyDefinitionID("managementGroupName", "policyDefinitionName").ID() + expected := "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProviders2PolicyDefinitionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *Providers2PolicyDefinitionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policyDefinitions", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName", + Expected: &Providers2PolicyDefinitionId{ + ManagementGroupName: "managementGroupName", + PolicyDefinitionName: "policyDefinitionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviders2PolicyDefinitionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.ManagementGroupName != v.Expected.ManagementGroupName { + t.Fatalf("Expected %q but got %q for ManagementGroupName", v.Expected.ManagementGroupName, actual.ManagementGroupName) + } + + if actual.PolicyDefinitionName != v.Expected.PolicyDefinitionName { + t.Fatalf("Expected %q but got %q for PolicyDefinitionName", v.Expected.PolicyDefinitionName, actual.PolicyDefinitionName) + } + + } +} + +func TestParseProviders2PolicyDefinitionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *Providers2PolicyDefinitionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpNaMe/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpNaMe/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policyDefinitions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpNaMe/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYdEfInItIoNs", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName", + Expected: &Providers2PolicyDefinitionId{ + ManagementGroupName: "managementGroupName", + PolicyDefinitionName: "policyDefinitionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpNaMe/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYdEfInItIoNs/pOlIcYdEfInItIoNnAmE", + Expected: &Providers2PolicyDefinitionId{ + ManagementGroupName: "mAnAgEmEnTgRoUpNaMe", + PolicyDefinitionName: "pOlIcYdEfInItIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpNaMe/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYdEfInItIoNs/pOlIcYdEfInItIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviders2PolicyDefinitionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.ManagementGroupName != v.Expected.ManagementGroupName { + t.Fatalf("Expected %q but got %q for ManagementGroupName", v.Expected.ManagementGroupName, actual.ManagementGroupName) + } + + if actual.PolicyDefinitionName != v.Expected.PolicyDefinitionName { + t.Fatalf("Expected %q but got %q for PolicyDefinitionName", v.Expected.PolicyDefinitionName, actual.PolicyDefinitionName) + } + + } +} + +func TestSegmentsForProviders2PolicyDefinitionId(t *testing.T) { + segments := Providers2PolicyDefinitionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("Providers2PolicyDefinitionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/logz/2020-10-01/tagrules/method_createorupdate.go b/resource-manager/resources/2025-03-01/policydefinitions/method_createorupdate.go similarity index 77% rename from resource-manager/logz/2020-10-01/tagrules/method_createorupdate.go rename to resource-manager/resources/2025-03-01/policydefinitions/method_createorupdate.go index 146b940122a..a18035927d2 100644 --- a/resource-manager/logz/2020-10-01/tagrules/method_createorupdate.go +++ b/resource-manager/resources/2025-03-01/policydefinitions/method_createorupdate.go @@ -1,4 +1,4 @@ -package tagrules +package policydefinitions import ( "context" @@ -14,15 +14,15 @@ import ( type CreateOrUpdateOperationResponse struct { HttpResponse *http.Response OData *odata.OData - Model *MonitoringTagRules + Model *PolicyDefinition } // CreateOrUpdate ... -func (c TagRulesClient) CreateOrUpdate(ctx context.Context, id TagRuleId, input MonitoringTagRules) (result CreateOrUpdateOperationResponse, err error) { +func (c PolicyDefinitionsClient) CreateOrUpdate(ctx context.Context, id ProviderPolicyDefinitionId, input PolicyDefinition) (result CreateOrUpdateOperationResponse, err error) { opts := client.RequestOptions{ ContentType: "application/json; charset=utf-8", ExpectedStatusCodes: []int{ - http.StatusOK, + http.StatusCreated, }, HttpMethod: http.MethodPut, Path: id.ID(), @@ -47,7 +47,7 @@ func (c TagRulesClient) CreateOrUpdate(ctx context.Context, id TagRuleId, input return } - var model MonitoringTagRules + var model PolicyDefinition result.Model = &model if err = resp.Unmarshal(result.Model); err != nil { return diff --git a/resource-manager/resources/2025-03-01/policydefinitions/method_createorupdateatmanagementgroup.go b/resource-manager/resources/2025-03-01/policydefinitions/method_createorupdateatmanagementgroup.go new file mode 100644 index 00000000000..1456d046b56 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitions/method_createorupdateatmanagementgroup.go @@ -0,0 +1,57 @@ +package policydefinitions + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateAtManagementGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicyDefinition +} + +// CreateOrUpdateAtManagementGroup ... +func (c PolicyDefinitionsClient) CreateOrUpdateAtManagementGroup(ctx context.Context, id Providers2PolicyDefinitionId, input PolicyDefinition) (result CreateOrUpdateAtManagementGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PolicyDefinition + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/logz/2020-10-01/tagrules/method_delete.go b/resource-manager/resources/2025-03-01/policydefinitions/method_delete.go similarity index 84% rename from resource-manager/logz/2020-10-01/tagrules/method_delete.go rename to resource-manager/resources/2025-03-01/policydefinitions/method_delete.go index 4dc23872c56..51b385668fe 100644 --- a/resource-manager/logz/2020-10-01/tagrules/method_delete.go +++ b/resource-manager/resources/2025-03-01/policydefinitions/method_delete.go @@ -1,4 +1,4 @@ -package tagrules +package policydefinitions import ( "context" @@ -17,11 +17,10 @@ type DeleteOperationResponse struct { } // Delete ... -func (c TagRulesClient) Delete(ctx context.Context, id TagRuleId) (result DeleteOperationResponse, err error) { +func (c PolicyDefinitionsClient) Delete(ctx context.Context, id ProviderPolicyDefinitionId) (result DeleteOperationResponse, err error) { opts := client.RequestOptions{ ContentType: "application/json; charset=utf-8", ExpectedStatusCodes: []int{ - http.StatusAccepted, http.StatusNoContent, http.StatusOK, }, diff --git a/resource-manager/resources/2025-03-01/policydefinitions/method_deleteatmanagementgroup.go b/resource-manager/resources/2025-03-01/policydefinitions/method_deleteatmanagementgroup.go new file mode 100644 index 00000000000..5cbb401f88b --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitions/method_deleteatmanagementgroup.go @@ -0,0 +1,47 @@ +package policydefinitions + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteAtManagementGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteAtManagementGroup ... +func (c PolicyDefinitionsClient) DeleteAtManagementGroup(ctx context.Context, id Providers2PolicyDefinitionId) (result DeleteAtManagementGroupOperationResponse, 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/logz/2020-10-01/monitors/method_get.go b/resource-manager/resources/2025-03-01/policydefinitions/method_get.go similarity index 81% rename from resource-manager/logz/2020-10-01/monitors/method_get.go rename to resource-manager/resources/2025-03-01/policydefinitions/method_get.go index c0d0afd93e9..ab435566011 100644 --- a/resource-manager/logz/2020-10-01/monitors/method_get.go +++ b/resource-manager/resources/2025-03-01/policydefinitions/method_get.go @@ -1,4 +1,4 @@ -package monitors +package policydefinitions import ( "context" @@ -14,11 +14,11 @@ import ( type GetOperationResponse struct { HttpResponse *http.Response OData *odata.OData - Model *LogzMonitorResource + Model *PolicyDefinition } // Get ... -func (c MonitorsClient) Get(ctx context.Context, id MonitorId) (result GetOperationResponse, err error) { +func (c PolicyDefinitionsClient) Get(ctx context.Context, id ProviderPolicyDefinitionId) (result GetOperationResponse, err error) { opts := client.RequestOptions{ ContentType: "application/json; charset=utf-8", ExpectedStatusCodes: []int{ @@ -43,7 +43,7 @@ func (c MonitorsClient) Get(ctx context.Context, id MonitorId) (result GetOperat return } - var model LogzMonitorResource + var model PolicyDefinition result.Model = &model if err = resp.Unmarshal(result.Model); err != nil { return diff --git a/resource-manager/resources/2025-03-01/policydefinitions/method_getatmanagementgroup.go b/resource-manager/resources/2025-03-01/policydefinitions/method_getatmanagementgroup.go new file mode 100644 index 00000000000..619311a0491 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitions/method_getatmanagementgroup.go @@ -0,0 +1,53 @@ +package policydefinitions + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetAtManagementGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicyDefinition +} + +// GetAtManagementGroup ... +func (c PolicyDefinitionsClient) GetAtManagementGroup(ctx context.Context, id Providers2PolicyDefinitionId) (result GetAtManagementGroupOperationResponse, 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 PolicyDefinition + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/resources/2025-03-01/policydefinitions/method_getbuiltin.go b/resource-manager/resources/2025-03-01/policydefinitions/method_getbuiltin.go new file mode 100644 index 00000000000..8c099b9dae9 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitions/method_getbuiltin.go @@ -0,0 +1,53 @@ +package policydefinitions + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetBuiltInOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicyDefinition +} + +// GetBuiltIn ... +func (c PolicyDefinitionsClient) GetBuiltIn(ctx context.Context, id PolicyDefinitionId) (result GetBuiltInOperationResponse, 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 PolicyDefinition + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/resources/2025-03-01/policydefinitions/method_list.go b/resource-manager/resources/2025-03-01/policydefinitions/method_list.go new file mode 100644 index 00000000000..259a941f6d2 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitions/method_list.go @@ -0,0 +1,139 @@ +package policydefinitions + +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 *[]PolicyDefinition +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []PolicyDefinition +} + +type ListOperationOptions struct { + Filter *string + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +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 PolicyDefinitionsClient) 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.Authorization/policyDefinitions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PolicyDefinition `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 PolicyDefinitionsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, PolicyDefinitionOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PolicyDefinitionsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions, predicate PolicyDefinitionOperationPredicate) (result ListCompleteResult, err error) { + items := make([]PolicyDefinition, 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/resources/2025-03-01/policydefinitions/method_listbuiltin.go b/resource-manager/resources/2025-03-01/policydefinitions/method_listbuiltin.go new file mode 100644 index 00000000000..245f42edce3 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitions/method_listbuiltin.go @@ -0,0 +1,138 @@ +package policydefinitions + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListBuiltInOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PolicyDefinition +} + +type ListBuiltInCompleteResult struct { + LatestHttpResponse *http.Response + Items []PolicyDefinition +} + +type ListBuiltInOperationOptions struct { + Filter *string + Top *int64 +} + +func DefaultListBuiltInOperationOptions() ListBuiltInOperationOptions { + return ListBuiltInOperationOptions{} +} + +func (o ListBuiltInOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListBuiltInOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListBuiltInOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListBuiltInCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBuiltInCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBuiltIn ... +func (c PolicyDefinitionsClient) ListBuiltIn(ctx context.Context, options ListBuiltInOperationOptions) (result ListBuiltInOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListBuiltInCustomPager{}, + Path: "/providers/Microsoft.Authorization/policyDefinitions", + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PolicyDefinition `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBuiltInComplete retrieves all the results into a single object +func (c PolicyDefinitionsClient) ListBuiltInComplete(ctx context.Context, options ListBuiltInOperationOptions) (ListBuiltInCompleteResult, error) { + return c.ListBuiltInCompleteMatchingPredicate(ctx, options, PolicyDefinitionOperationPredicate{}) +} + +// ListBuiltInCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PolicyDefinitionsClient) ListBuiltInCompleteMatchingPredicate(ctx context.Context, options ListBuiltInOperationOptions, predicate PolicyDefinitionOperationPredicate) (result ListBuiltInCompleteResult, err error) { + items := make([]PolicyDefinition, 0) + + resp, err := c.ListBuiltIn(ctx, 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 = ListBuiltInCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/resources/2025-03-01/policydefinitions/method_listbymanagementgroup.go b/resource-manager/resources/2025-03-01/policydefinitions/method_listbymanagementgroup.go new file mode 100644 index 00000000000..6ab9d13e71f --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitions/method_listbymanagementgroup.go @@ -0,0 +1,139 @@ +package policydefinitions + +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 ListByManagementGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PolicyDefinition +} + +type ListByManagementGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []PolicyDefinition +} + +type ListByManagementGroupOperationOptions struct { + Filter *string + Top *int64 +} + +func DefaultListByManagementGroupOperationOptions() ListByManagementGroupOperationOptions { + return ListByManagementGroupOperationOptions{} +} + +func (o ListByManagementGroupOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByManagementGroupOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListByManagementGroupOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListByManagementGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByManagementGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByManagementGroup ... +func (c PolicyDefinitionsClient) ListByManagementGroup(ctx context.Context, id commonids.ManagementGroupId, options ListByManagementGroupOperationOptions) (result ListByManagementGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListByManagementGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Authorization/policyDefinitions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PolicyDefinition `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByManagementGroupComplete retrieves all the results into a single object +func (c PolicyDefinitionsClient) ListByManagementGroupComplete(ctx context.Context, id commonids.ManagementGroupId, options ListByManagementGroupOperationOptions) (ListByManagementGroupCompleteResult, error) { + return c.ListByManagementGroupCompleteMatchingPredicate(ctx, id, options, PolicyDefinitionOperationPredicate{}) +} + +// ListByManagementGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PolicyDefinitionsClient) ListByManagementGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ManagementGroupId, options ListByManagementGroupOperationOptions, predicate PolicyDefinitionOperationPredicate) (result ListByManagementGroupCompleteResult, err error) { + items := make([]PolicyDefinition, 0) + + resp, err := c.ListByManagementGroup(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 = ListByManagementGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/resources/2025-03-01/policydefinitions/model_externalevaluationendpointsettings.go b/resource-manager/resources/2025-03-01/policydefinitions/model_externalevaluationendpointsettings.go new file mode 100644 index 00000000000..bc6148add0f --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitions/model_externalevaluationendpointsettings.go @@ -0,0 +1,9 @@ +package policydefinitions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExternalEvaluationEndpointSettings struct { + Details *interface{} `json:"details,omitempty"` + Kind *string `json:"kind,omitempty"` +} diff --git a/resource-manager/resources/2025-03-01/policydefinitions/model_externalevaluationenforcementsettings.go b/resource-manager/resources/2025-03-01/policydefinitions/model_externalevaluationenforcementsettings.go new file mode 100644 index 00000000000..a2d79f78eec --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitions/model_externalevaluationenforcementsettings.go @@ -0,0 +1,11 @@ +package policydefinitions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExternalEvaluationEnforcementSettings struct { + EndpointSettings *ExternalEvaluationEndpointSettings `json:"endpointSettings,omitempty"` + MissingTokenAction *string `json:"missingTokenAction,omitempty"` + ResultLifespan *string `json:"resultLifespan,omitempty"` + RoleDefinitionIds *[]string `json:"roleDefinitionIds,omitempty"` +} diff --git a/resource-manager/resources/2025-03-01/policydefinitions/model_parameterdefinitionsvalue.go b/resource-manager/resources/2025-03-01/policydefinitions/model_parameterdefinitionsvalue.go new file mode 100644 index 00000000000..7507ffb9e98 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitions/model_parameterdefinitionsvalue.go @@ -0,0 +1,12 @@ +package policydefinitions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ParameterDefinitionsValue struct { + AllowedValues *[]interface{} `json:"allowedValues,omitempty"` + DefaultValue *interface{} `json:"defaultValue,omitempty"` + Metadata *ParameterDefinitionsValueMetadata `json:"metadata,omitempty"` + Schema *interface{} `json:"schema,omitempty"` + Type *ParameterType `json:"type,omitempty"` +} diff --git a/resource-manager/resources/2025-03-01/policydefinitions/model_parameterdefinitionsvaluemetadata.go b/resource-manager/resources/2025-03-01/policydefinitions/model_parameterdefinitionsvaluemetadata.go new file mode 100644 index 00000000000..8d3599aa802 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitions/model_parameterdefinitionsvaluemetadata.go @@ -0,0 +1,11 @@ +package policydefinitions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ParameterDefinitionsValueMetadata struct { + AssignPermissions *bool `json:"assignPermissions,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + StrongType *string `json:"strongType,omitempty"` +} diff --git a/resource-manager/logz/2020-10-01/singlesignon/model_logzsinglesignonresource.go b/resource-manager/resources/2025-03-01/policydefinitions/model_policydefinition.go similarity index 80% rename from resource-manager/logz/2020-10-01/singlesignon/model_logzsinglesignonresource.go rename to resource-manager/resources/2025-03-01/policydefinitions/model_policydefinition.go index 665f3fa3493..a7d0e238d29 100644 --- a/resource-manager/logz/2020-10-01/singlesignon/model_logzsinglesignonresource.go +++ b/resource-manager/resources/2025-03-01/policydefinitions/model_policydefinition.go @@ -1,4 +1,4 @@ -package singlesignon +package policydefinitions import ( "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" @@ -7,10 +7,10 @@ import ( // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. -type LogzSingleSignOnResource struct { +type PolicyDefinition struct { Id *string `json:"id,omitempty"` Name *string `json:"name,omitempty"` - Properties *LogzSingleSignOnProperties `json:"properties,omitempty"` + Properties *PolicyDefinitionProperties `json:"properties,omitempty"` SystemData *systemdata.SystemData `json:"systemData,omitempty"` Type *string `json:"type,omitempty"` } diff --git a/resource-manager/resources/2025-03-01/policydefinitions/model_policydefinitionproperties.go b/resource-manager/resources/2025-03-01/policydefinitions/model_policydefinitionproperties.go new file mode 100644 index 00000000000..6daf0252f8d --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitions/model_policydefinitionproperties.go @@ -0,0 +1,17 @@ +package policydefinitions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PolicyDefinitionProperties struct { + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + ExternalEvaluationEnforcementSettings *ExternalEvaluationEnforcementSettings `json:"externalEvaluationEnforcementSettings,omitempty"` + Metadata *interface{} `json:"metadata,omitempty"` + Mode *string `json:"mode,omitempty"` + Parameters *map[string]ParameterDefinitionsValue `json:"parameters,omitempty"` + PolicyRule *interface{} `json:"policyRule,omitempty"` + PolicyType *PolicyType `json:"policyType,omitempty"` + Version *string `json:"version,omitempty"` + Versions *[]string `json:"versions,omitempty"` +} diff --git a/resource-manager/logz/2020-10-01/tagrules/predicates.go b/resource-manager/resources/2025-03-01/policydefinitions/predicates.go similarity index 75% rename from resource-manager/logz/2020-10-01/tagrules/predicates.go rename to resource-manager/resources/2025-03-01/policydefinitions/predicates.go index a75bf2a34b3..41e1ad64139 100644 --- a/resource-manager/logz/2020-10-01/tagrules/predicates.go +++ b/resource-manager/resources/2025-03-01/policydefinitions/predicates.go @@ -1,15 +1,15 @@ -package tagrules +package policydefinitions // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. -type MonitoringTagRulesOperationPredicate struct { +type PolicyDefinitionOperationPredicate struct { Id *string Name *string Type *string } -func (p MonitoringTagRulesOperationPredicate) Matches(input MonitoringTagRules) bool { +func (p PolicyDefinitionOperationPredicate) Matches(input PolicyDefinition) bool { if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { return false diff --git a/resource-manager/resources/2025-03-01/policydefinitions/version.go b/resource-manager/resources/2025-03-01/policydefinitions/version.go new file mode 100644 index 00000000000..c126c5c8faa --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitions/version.go @@ -0,0 +1,10 @@ +package policydefinitions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-03-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/policydefinitions/2025-03-01" +} diff --git a/resource-manager/resources/2025-03-01/policydefinitionversions/README.md b/resource-manager/resources/2025-03-01/policydefinitionversions/README.md new file mode 100644 index 00000000000..b1c59936e2b --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitionversions/README.md @@ -0,0 +1,245 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/resources/2025-03-01/policydefinitionversions` Documentation + +The `policydefinitionversions` SDK allows for interaction with Azure Resource Manager `resources` (API Version `2025-03-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/resources/2025-03-01/policydefinitionversions" +``` + + +### Client Initialization + +```go +client := policydefinitionversions.NewPolicyDefinitionVersionsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PolicyDefinitionVersionsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := policydefinitionversions.NewPolicyDefinitionVersionID("12345678-1234-9876-4563-123456789012", "policyDefinitionName", "versionName") + +payload := policydefinitionversions.PolicyDefinitionVersion{ + // ... +} + + +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: `PolicyDefinitionVersionsClient.CreateOrUpdateAtManagementGroup` + +```go +ctx := context.TODO() +id := policydefinitionversions.NewProviders2PolicyDefinitionVersionID("managementGroupName", "policyDefinitionName", "versionName") + +payload := policydefinitionversions.PolicyDefinitionVersion{ + // ... +} + + +read, err := client.CreateOrUpdateAtManagementGroup(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PolicyDefinitionVersionsClient.Delete` + +```go +ctx := context.TODO() +id := policydefinitionversions.NewPolicyDefinitionVersionID("12345678-1234-9876-4563-123456789012", "policyDefinitionName", "versionName") + +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: `PolicyDefinitionVersionsClient.DeleteAtManagementGroup` + +```go +ctx := context.TODO() +id := policydefinitionversions.NewProviders2PolicyDefinitionVersionID("managementGroupName", "policyDefinitionName", "versionName") + +read, err := client.DeleteAtManagementGroup(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PolicyDefinitionVersionsClient.Get` + +```go +ctx := context.TODO() +id := policydefinitionversions.NewPolicyDefinitionVersionID("12345678-1234-9876-4563-123456789012", "policyDefinitionName", "versionName") + +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: `PolicyDefinitionVersionsClient.GetAtManagementGroup` + +```go +ctx := context.TODO() +id := policydefinitionversions.NewProviders2PolicyDefinitionVersionID("managementGroupName", "policyDefinitionName", "versionName") + +read, err := client.GetAtManagementGroup(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PolicyDefinitionVersionsClient.GetBuiltIn` + +```go +ctx := context.TODO() +id := policydefinitionversions.NewVersionID("policyDefinitionName", "versionName") + +read, err := client.GetBuiltIn(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PolicyDefinitionVersionsClient.List` + +```go +ctx := context.TODO() +id := policydefinitionversions.NewProviderPolicyDefinitionID("12345678-1234-9876-4563-123456789012", "policyDefinitionName") + +// alternatively `client.List(ctx, id, policydefinitionversions.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, policydefinitionversions.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PolicyDefinitionVersionsClient.ListAll` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListAll(ctx, id)` can be used to do batched pagination +items, err := client.ListAllComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PolicyDefinitionVersionsClient.ListAllAtManagementGroup` + +```go +ctx := context.TODO() +id := commonids.NewManagementGroupID("groupId") + +// alternatively `client.ListAllAtManagementGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListAllAtManagementGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PolicyDefinitionVersionsClient.ListAllBuiltins` + +```go +ctx := context.TODO() + + +// alternatively `client.ListAllBuiltins(ctx)` can be used to do batched pagination +items, err := client.ListAllBuiltinsComplete(ctx) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PolicyDefinitionVersionsClient.ListBuiltIn` + +```go +ctx := context.TODO() +id := policydefinitionversions.NewPolicyDefinitionID("policyDefinitionName") + +// alternatively `client.ListBuiltIn(ctx, id, policydefinitionversions.DefaultListBuiltInOperationOptions())` can be used to do batched pagination +items, err := client.ListBuiltInComplete(ctx, id, policydefinitionversions.DefaultListBuiltInOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PolicyDefinitionVersionsClient.ListByManagementGroup` + +```go +ctx := context.TODO() +id := policydefinitionversions.NewProviders2PolicyDefinitionID("managementGroupName", "policyDefinitionName") + +// alternatively `client.ListByManagementGroup(ctx, id, policydefinitionversions.DefaultListByManagementGroupOperationOptions())` can be used to do batched pagination +items, err := client.ListByManagementGroupComplete(ctx, id, policydefinitionversions.DefaultListByManagementGroupOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/resources/2025-03-01/policydefinitionversions/client.go b/resource-manager/resources/2025-03-01/policydefinitionversions/client.go new file mode 100644 index 00000000000..9e13a043f48 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitionversions/client.go @@ -0,0 +1,26 @@ +package policydefinitionversions + +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 PolicyDefinitionVersionsClient struct { + Client *resourcemanager.Client +} + +func NewPolicyDefinitionVersionsClientWithBaseURI(sdkApi sdkEnv.Api) (*PolicyDefinitionVersionsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "policydefinitionversions", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PolicyDefinitionVersionsClient: %+v", err) + } + + return &PolicyDefinitionVersionsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/resources/2025-03-01/policydefinitionversions/constants.go b/resource-manager/resources/2025-03-01/policydefinitionversions/constants.go new file mode 100644 index 00000000000..5a5ffa07407 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitionversions/constants.go @@ -0,0 +1,113 @@ +package policydefinitionversions + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ParameterType string + +const ( + ParameterTypeArray ParameterType = "Array" + ParameterTypeBoolean ParameterType = "Boolean" + ParameterTypeDateTime ParameterType = "DateTime" + ParameterTypeFloat ParameterType = "Float" + ParameterTypeInteger ParameterType = "Integer" + ParameterTypeObject ParameterType = "Object" + ParameterTypeString ParameterType = "String" +) + +func PossibleValuesForParameterType() []string { + return []string{ + string(ParameterTypeArray), + string(ParameterTypeBoolean), + string(ParameterTypeDateTime), + string(ParameterTypeFloat), + string(ParameterTypeInteger), + string(ParameterTypeObject), + string(ParameterTypeString), + } +} + +func (s *ParameterType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseParameterType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseParameterType(input string) (*ParameterType, error) { + vals := map[string]ParameterType{ + "array": ParameterTypeArray, + "boolean": ParameterTypeBoolean, + "datetime": ParameterTypeDateTime, + "float": ParameterTypeFloat, + "integer": ParameterTypeInteger, + "object": ParameterTypeObject, + "string": ParameterTypeString, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ParameterType(input) + return &out, nil +} + +type PolicyType string + +const ( + PolicyTypeBuiltIn PolicyType = "BuiltIn" + PolicyTypeCustom PolicyType = "Custom" + PolicyTypeNotSpecified PolicyType = "NotSpecified" + PolicyTypeStatic PolicyType = "Static" +) + +func PossibleValuesForPolicyType() []string { + return []string{ + string(PolicyTypeBuiltIn), + string(PolicyTypeCustom), + string(PolicyTypeNotSpecified), + string(PolicyTypeStatic), + } +} + +func (s *PolicyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePolicyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePolicyType(input string) (*PolicyType, error) { + vals := map[string]PolicyType{ + "builtin": PolicyTypeBuiltIn, + "custom": PolicyTypeCustom, + "notspecified": PolicyTypeNotSpecified, + "static": PolicyTypeStatic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PolicyType(input) + return &out, nil +} diff --git a/resource-manager/resources/2025-03-01/policydefinitionversions/id_policydefinition.go b/resource-manager/resources/2025-03-01/policydefinitionversions/id_policydefinition.go new file mode 100644 index 00000000000..52e214cfc5b --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitionversions/id_policydefinition.go @@ -0,0 +1,112 @@ +package policydefinitionversions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PolicyDefinitionId{}) +} + +var _ resourceids.ResourceId = &PolicyDefinitionId{} + +// PolicyDefinitionId is a struct representing the Resource ID for a Policy Definition +type PolicyDefinitionId struct { + PolicyDefinitionName string +} + +// NewPolicyDefinitionID returns a new PolicyDefinitionId struct +func NewPolicyDefinitionID(policyDefinitionName string) PolicyDefinitionId { + return PolicyDefinitionId{ + PolicyDefinitionName: policyDefinitionName, + } +} + +// ParsePolicyDefinitionID parses 'input' into a PolicyDefinitionId +func ParsePolicyDefinitionID(input string) (*PolicyDefinitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PolicyDefinitionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PolicyDefinitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePolicyDefinitionIDInsensitively parses 'input' case-insensitively into a PolicyDefinitionId +// note: this method should only be used for API response data and not user input +func ParsePolicyDefinitionIDInsensitively(input string) (*PolicyDefinitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PolicyDefinitionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PolicyDefinitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PolicyDefinitionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.PolicyDefinitionName, ok = input.Parsed["policyDefinitionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "policyDefinitionName", input) + } + + return nil +} + +// ValidatePolicyDefinitionID checks that 'input' can be parsed as a Policy Definition ID +func ValidatePolicyDefinitionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParsePolicyDefinitionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Policy Definition ID +func (id PolicyDefinitionId) ID() string { + fmtString := "/providers/Microsoft.Authorization/policyDefinitions/%s" + return fmt.Sprintf(fmtString, id.PolicyDefinitionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Policy Definition ID +func (id PolicyDefinitionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftAuthorization", "Microsoft.Authorization", "Microsoft.Authorization"), + resourceids.StaticSegment("staticPolicyDefinitions", "policyDefinitions", "policyDefinitions"), + resourceids.UserSpecifiedSegment("policyDefinitionName", "policyDefinitionName"), + } +} + +// String returns a human-readable description of this Policy Definition ID +func (id PolicyDefinitionId) String() string { + components := []string{ + fmt.Sprintf("Policy Definition Name: %q", id.PolicyDefinitionName), + } + return fmt.Sprintf("Policy Definition (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/resources/2025-03-01/policydefinitionversions/id_policydefinition_test.go b/resource-manager/resources/2025-03-01/policydefinitionversions/id_policydefinition_test.go new file mode 100644 index 00000000000..bdd4e06bd13 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitionversions/id_policydefinition_test.go @@ -0,0 +1,192 @@ +package policydefinitionversions + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PolicyDefinitionId{} + +func TestNewPolicyDefinitionID(t *testing.T) { + id := NewPolicyDefinitionID("policyDefinitionName") + + if id.PolicyDefinitionName != "policyDefinitionName" { + t.Fatalf("Expected %q but got %q for Segment 'PolicyDefinitionName'", id.PolicyDefinitionName, "policyDefinitionName") + } +} + +func TestFormatPolicyDefinitionID(t *testing.T) { + actual := NewPolicyDefinitionID("policyDefinitionName").ID() + expected := "/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePolicyDefinitionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PolicyDefinitionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Authorization/policyDefinitions", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName", + Expected: &PolicyDefinitionId{ + PolicyDefinitionName: "policyDefinitionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePolicyDefinitionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.PolicyDefinitionName != v.Expected.PolicyDefinitionName { + t.Fatalf("Expected %q but got %q for PolicyDefinitionName", v.Expected.PolicyDefinitionName, actual.PolicyDefinitionName) + } + + } +} + +func TestParsePolicyDefinitionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PolicyDefinitionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Authorization/policyDefinitions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYdEfInItIoNs", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName", + Expected: &PolicyDefinitionId{ + PolicyDefinitionName: "policyDefinitionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYdEfInItIoNs/pOlIcYdEfInItIoNnAmE", + Expected: &PolicyDefinitionId{ + PolicyDefinitionName: "pOlIcYdEfInItIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYdEfInItIoNs/pOlIcYdEfInItIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePolicyDefinitionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.PolicyDefinitionName != v.Expected.PolicyDefinitionName { + t.Fatalf("Expected %q but got %q for PolicyDefinitionName", v.Expected.PolicyDefinitionName, actual.PolicyDefinitionName) + } + + } +} + +func TestSegmentsForPolicyDefinitionId(t *testing.T) { + segments := PolicyDefinitionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PolicyDefinitionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/resources/2025-03-01/policydefinitionversions/id_policydefinitionversion.go b/resource-manager/resources/2025-03-01/policydefinitionversions/id_policydefinitionversion.go new file mode 100644 index 00000000000..d83027984f1 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitionversions/id_policydefinitionversion.go @@ -0,0 +1,130 @@ +package policydefinitionversions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PolicyDefinitionVersionId{}) +} + +var _ resourceids.ResourceId = &PolicyDefinitionVersionId{} + +// PolicyDefinitionVersionId is a struct representing the Resource ID for a Policy Definition Version +type PolicyDefinitionVersionId struct { + SubscriptionId string + PolicyDefinitionName string + VersionName string +} + +// NewPolicyDefinitionVersionID returns a new PolicyDefinitionVersionId struct +func NewPolicyDefinitionVersionID(subscriptionId string, policyDefinitionName string, versionName string) PolicyDefinitionVersionId { + return PolicyDefinitionVersionId{ + SubscriptionId: subscriptionId, + PolicyDefinitionName: policyDefinitionName, + VersionName: versionName, + } +} + +// ParsePolicyDefinitionVersionID parses 'input' into a PolicyDefinitionVersionId +func ParsePolicyDefinitionVersionID(input string) (*PolicyDefinitionVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PolicyDefinitionVersionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PolicyDefinitionVersionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePolicyDefinitionVersionIDInsensitively parses 'input' case-insensitively into a PolicyDefinitionVersionId +// note: this method should only be used for API response data and not user input +func ParsePolicyDefinitionVersionIDInsensitively(input string) (*PolicyDefinitionVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PolicyDefinitionVersionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PolicyDefinitionVersionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PolicyDefinitionVersionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.PolicyDefinitionName, ok = input.Parsed["policyDefinitionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "policyDefinitionName", input) + } + + if id.VersionName, ok = input.Parsed["versionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "versionName", input) + } + + return nil +} + +// ValidatePolicyDefinitionVersionID checks that 'input' can be parsed as a Policy Definition Version ID +func ValidatePolicyDefinitionVersionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParsePolicyDefinitionVersionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Policy Definition Version ID +func (id PolicyDefinitionVersionId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Authorization/policyDefinitions/%s/versions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.PolicyDefinitionName, id.VersionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Policy Definition Version ID +func (id PolicyDefinitionVersionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftAuthorization", "Microsoft.Authorization", "Microsoft.Authorization"), + resourceids.StaticSegment("staticPolicyDefinitions", "policyDefinitions", "policyDefinitions"), + resourceids.UserSpecifiedSegment("policyDefinitionName", "policyDefinitionName"), + resourceids.StaticSegment("staticVersions", "versions", "versions"), + resourceids.UserSpecifiedSegment("versionName", "versionName"), + } +} + +// String returns a human-readable description of this Policy Definition Version ID +func (id PolicyDefinitionVersionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Policy Definition Name: %q", id.PolicyDefinitionName), + fmt.Sprintf("Version Name: %q", id.VersionName), + } + return fmt.Sprintf("Policy Definition Version (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/resources/2025-03-01/policydefinitionversions/id_policydefinitionversion_test.go b/resource-manager/resources/2025-03-01/policydefinitionversions/id_policydefinitionversion_test.go new file mode 100644 index 00000000000..a1a0f288b99 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitionversions/id_policydefinitionversion_test.go @@ -0,0 +1,282 @@ +package policydefinitionversions + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PolicyDefinitionVersionId{} + +func TestNewPolicyDefinitionVersionID(t *testing.T) { + id := NewPolicyDefinitionVersionID("12345678-1234-9876-4563-123456789012", "policyDefinitionName", "versionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.PolicyDefinitionName != "policyDefinitionName" { + t.Fatalf("Expected %q but got %q for Segment 'PolicyDefinitionName'", id.PolicyDefinitionName, "policyDefinitionName") + } + + if id.VersionName != "versionName" { + t.Fatalf("Expected %q but got %q for Segment 'VersionName'", id.VersionName, "versionName") + } +} + +func TestFormatPolicyDefinitionVersionID(t *testing.T) { + actual := NewPolicyDefinitionVersionID("12345678-1234-9876-4563-123456789012", "policyDefinitionName", "versionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/versions/versionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePolicyDefinitionVersionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PolicyDefinitionVersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/versions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/versions/versionName", + Expected: &PolicyDefinitionVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicyDefinitionName: "policyDefinitionName", + VersionName: "versionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/versions/versionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePolicyDefinitionVersionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.PolicyDefinitionName != v.Expected.PolicyDefinitionName { + t.Fatalf("Expected %q but got %q for PolicyDefinitionName", v.Expected.PolicyDefinitionName, actual.PolicyDefinitionName) + } + + if actual.VersionName != v.Expected.VersionName { + t.Fatalf("Expected %q but got %q for VersionName", v.Expected.VersionName, actual.VersionName) + } + + } +} + +func TestParsePolicyDefinitionVersionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PolicyDefinitionVersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYdEfInItIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYdEfInItIoNs/pOlIcYdEfInItIoNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/versions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYdEfInItIoNs/pOlIcYdEfInItIoNnAmE/vErSiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/versions/versionName", + Expected: &PolicyDefinitionVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicyDefinitionName: "policyDefinitionName", + VersionName: "versionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/versions/versionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYdEfInItIoNs/pOlIcYdEfInItIoNnAmE/vErSiOnS/vErSiOnNaMe", + Expected: &PolicyDefinitionVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicyDefinitionName: "pOlIcYdEfInItIoNnAmE", + VersionName: "vErSiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYdEfInItIoNs/pOlIcYdEfInItIoNnAmE/vErSiOnS/vErSiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePolicyDefinitionVersionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.PolicyDefinitionName != v.Expected.PolicyDefinitionName { + t.Fatalf("Expected %q but got %q for PolicyDefinitionName", v.Expected.PolicyDefinitionName, actual.PolicyDefinitionName) + } + + if actual.VersionName != v.Expected.VersionName { + t.Fatalf("Expected %q but got %q for VersionName", v.Expected.VersionName, actual.VersionName) + } + + } +} + +func TestSegmentsForPolicyDefinitionVersionId(t *testing.T) { + segments := PolicyDefinitionVersionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PolicyDefinitionVersionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/resources/2025-03-01/policydefinitionversions/id_providerpolicydefinition.go b/resource-manager/resources/2025-03-01/policydefinitionversions/id_providerpolicydefinition.go new file mode 100644 index 00000000000..8fca8b6997e --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitionversions/id_providerpolicydefinition.go @@ -0,0 +1,121 @@ +package policydefinitionversions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ProviderPolicyDefinitionId{}) +} + +var _ resourceids.ResourceId = &ProviderPolicyDefinitionId{} + +// ProviderPolicyDefinitionId is a struct representing the Resource ID for a Provider Policy Definition +type ProviderPolicyDefinitionId struct { + SubscriptionId string + PolicyDefinitionName string +} + +// NewProviderPolicyDefinitionID returns a new ProviderPolicyDefinitionId struct +func NewProviderPolicyDefinitionID(subscriptionId string, policyDefinitionName string) ProviderPolicyDefinitionId { + return ProviderPolicyDefinitionId{ + SubscriptionId: subscriptionId, + PolicyDefinitionName: policyDefinitionName, + } +} + +// ParseProviderPolicyDefinitionID parses 'input' into a ProviderPolicyDefinitionId +func ParseProviderPolicyDefinitionID(input string) (*ProviderPolicyDefinitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderPolicyDefinitionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderPolicyDefinitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProviderPolicyDefinitionIDInsensitively parses 'input' case-insensitively into a ProviderPolicyDefinitionId +// note: this method should only be used for API response data and not user input +func ParseProviderPolicyDefinitionIDInsensitively(input string) (*ProviderPolicyDefinitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderPolicyDefinitionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderPolicyDefinitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProviderPolicyDefinitionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.PolicyDefinitionName, ok = input.Parsed["policyDefinitionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "policyDefinitionName", input) + } + + return nil +} + +// ValidateProviderPolicyDefinitionID checks that 'input' can be parsed as a Provider Policy Definition ID +func ValidateProviderPolicyDefinitionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseProviderPolicyDefinitionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Provider Policy Definition ID +func (id ProviderPolicyDefinitionId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Authorization/policyDefinitions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.PolicyDefinitionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Provider Policy Definition ID +func (id ProviderPolicyDefinitionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftAuthorization", "Microsoft.Authorization", "Microsoft.Authorization"), + resourceids.StaticSegment("staticPolicyDefinitions", "policyDefinitions", "policyDefinitions"), + resourceids.UserSpecifiedSegment("policyDefinitionName", "policyDefinitionName"), + } +} + +// String returns a human-readable description of this Provider Policy Definition ID +func (id ProviderPolicyDefinitionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Policy Definition Name: %q", id.PolicyDefinitionName), + } + return fmt.Sprintf("Provider Policy Definition (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/resources/2025-03-01/policydefinitionversions/id_providerpolicydefinition_test.go b/resource-manager/resources/2025-03-01/policydefinitionversions/id_providerpolicydefinition_test.go new file mode 100644 index 00000000000..5c7284613ab --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitionversions/id_providerpolicydefinition_test.go @@ -0,0 +1,237 @@ +package policydefinitionversions + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ProviderPolicyDefinitionId{} + +func TestNewProviderPolicyDefinitionID(t *testing.T) { + id := NewProviderPolicyDefinitionID("12345678-1234-9876-4563-123456789012", "policyDefinitionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.PolicyDefinitionName != "policyDefinitionName" { + t.Fatalf("Expected %q but got %q for Segment 'PolicyDefinitionName'", id.PolicyDefinitionName, "policyDefinitionName") + } +} + +func TestFormatProviderPolicyDefinitionID(t *testing.T) { + actual := NewProviderPolicyDefinitionID("12345678-1234-9876-4563-123456789012", "policyDefinitionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProviderPolicyDefinitionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderPolicyDefinitionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName", + Expected: &ProviderPolicyDefinitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicyDefinitionName: "policyDefinitionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderPolicyDefinitionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.PolicyDefinitionName != v.Expected.PolicyDefinitionName { + t.Fatalf("Expected %q but got %q for PolicyDefinitionName", v.Expected.PolicyDefinitionName, actual.PolicyDefinitionName) + } + + } +} + +func TestParseProviderPolicyDefinitionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderPolicyDefinitionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYdEfInItIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName", + Expected: &ProviderPolicyDefinitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicyDefinitionName: "policyDefinitionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYdEfInItIoNs/pOlIcYdEfInItIoNnAmE", + Expected: &ProviderPolicyDefinitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicyDefinitionName: "pOlIcYdEfInItIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYdEfInItIoNs/pOlIcYdEfInItIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderPolicyDefinitionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.PolicyDefinitionName != v.Expected.PolicyDefinitionName { + t.Fatalf("Expected %q but got %q for PolicyDefinitionName", v.Expected.PolicyDefinitionName, actual.PolicyDefinitionName) + } + + } +} + +func TestSegmentsForProviderPolicyDefinitionId(t *testing.T) { + segments := ProviderPolicyDefinitionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProviderPolicyDefinitionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/resources/2025-03-01/policydefinitionversions/id_providers2policydefinition.go b/resource-manager/resources/2025-03-01/policydefinitionversions/id_providers2policydefinition.go new file mode 100644 index 00000000000..4023c077680 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitionversions/id_providers2policydefinition.go @@ -0,0 +1,123 @@ +package policydefinitionversions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&Providers2PolicyDefinitionId{}) +} + +var _ resourceids.ResourceId = &Providers2PolicyDefinitionId{} + +// Providers2PolicyDefinitionId is a struct representing the Resource ID for a Providers 2 Policy Definition +type Providers2PolicyDefinitionId struct { + ManagementGroupName string + PolicyDefinitionName string +} + +// NewProviders2PolicyDefinitionID returns a new Providers2PolicyDefinitionId struct +func NewProviders2PolicyDefinitionID(managementGroupName string, policyDefinitionName string) Providers2PolicyDefinitionId { + return Providers2PolicyDefinitionId{ + ManagementGroupName: managementGroupName, + PolicyDefinitionName: policyDefinitionName, + } +} + +// ParseProviders2PolicyDefinitionID parses 'input' into a Providers2PolicyDefinitionId +func ParseProviders2PolicyDefinitionID(input string) (*Providers2PolicyDefinitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&Providers2PolicyDefinitionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := Providers2PolicyDefinitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProviders2PolicyDefinitionIDInsensitively parses 'input' case-insensitively into a Providers2PolicyDefinitionId +// note: this method should only be used for API response data and not user input +func ParseProviders2PolicyDefinitionIDInsensitively(input string) (*Providers2PolicyDefinitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&Providers2PolicyDefinitionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := Providers2PolicyDefinitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *Providers2PolicyDefinitionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.ManagementGroupName, ok = input.Parsed["managementGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managementGroupName", input) + } + + if id.PolicyDefinitionName, ok = input.Parsed["policyDefinitionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "policyDefinitionName", input) + } + + return nil +} + +// ValidateProviders2PolicyDefinitionID checks that 'input' can be parsed as a Providers 2 Policy Definition ID +func ValidateProviders2PolicyDefinitionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseProviders2PolicyDefinitionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Providers 2 Policy Definition ID +func (id Providers2PolicyDefinitionId) ID() string { + fmtString := "/providers/Microsoft.Management/managementGroups/%s/providers/Microsoft.Authorization/policyDefinitions/%s" + return fmt.Sprintf(fmtString, id.ManagementGroupName, id.PolicyDefinitionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Providers 2 Policy Definition ID +func (id Providers2PolicyDefinitionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftManagement", "Microsoft.Management", "Microsoft.Management"), + resourceids.StaticSegment("staticManagementGroups", "managementGroups", "managementGroups"), + resourceids.UserSpecifiedSegment("managementGroupName", "managementGroupName"), + resourceids.StaticSegment("staticProviders2", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftAuthorization", "Microsoft.Authorization", "Microsoft.Authorization"), + resourceids.StaticSegment("staticPolicyDefinitions", "policyDefinitions", "policyDefinitions"), + resourceids.UserSpecifiedSegment("policyDefinitionName", "policyDefinitionName"), + } +} + +// String returns a human-readable description of this Providers 2 Policy Definition ID +func (id Providers2PolicyDefinitionId) String() string { + components := []string{ + fmt.Sprintf("Management Group Name: %q", id.ManagementGroupName), + fmt.Sprintf("Policy Definition Name: %q", id.PolicyDefinitionName), + } + return fmt.Sprintf("Providers 2 Policy Definition (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/resources/2025-03-01/policydefinitionversions/id_providers2policydefinition_test.go b/resource-manager/resources/2025-03-01/policydefinitionversions/id_providers2policydefinition_test.go new file mode 100644 index 00000000000..1a2a3d77912 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitionversions/id_providers2policydefinition_test.go @@ -0,0 +1,267 @@ +package policydefinitionversions + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &Providers2PolicyDefinitionId{} + +func TestNewProviders2PolicyDefinitionID(t *testing.T) { + id := NewProviders2PolicyDefinitionID("managementGroupName", "policyDefinitionName") + + if id.ManagementGroupName != "managementGroupName" { + t.Fatalf("Expected %q but got %q for Segment 'ManagementGroupName'", id.ManagementGroupName, "managementGroupName") + } + + if id.PolicyDefinitionName != "policyDefinitionName" { + t.Fatalf("Expected %q but got %q for Segment 'PolicyDefinitionName'", id.PolicyDefinitionName, "policyDefinitionName") + } +} + +func TestFormatProviders2PolicyDefinitionID(t *testing.T) { + actual := NewProviders2PolicyDefinitionID("managementGroupName", "policyDefinitionName").ID() + expected := "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProviders2PolicyDefinitionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *Providers2PolicyDefinitionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policyDefinitions", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName", + Expected: &Providers2PolicyDefinitionId{ + ManagementGroupName: "managementGroupName", + PolicyDefinitionName: "policyDefinitionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviders2PolicyDefinitionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.ManagementGroupName != v.Expected.ManagementGroupName { + t.Fatalf("Expected %q but got %q for ManagementGroupName", v.Expected.ManagementGroupName, actual.ManagementGroupName) + } + + if actual.PolicyDefinitionName != v.Expected.PolicyDefinitionName { + t.Fatalf("Expected %q but got %q for PolicyDefinitionName", v.Expected.PolicyDefinitionName, actual.PolicyDefinitionName) + } + + } +} + +func TestParseProviders2PolicyDefinitionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *Providers2PolicyDefinitionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpNaMe/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpNaMe/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policyDefinitions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpNaMe/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYdEfInItIoNs", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName", + Expected: &Providers2PolicyDefinitionId{ + ManagementGroupName: "managementGroupName", + PolicyDefinitionName: "policyDefinitionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpNaMe/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYdEfInItIoNs/pOlIcYdEfInItIoNnAmE", + Expected: &Providers2PolicyDefinitionId{ + ManagementGroupName: "mAnAgEmEnTgRoUpNaMe", + PolicyDefinitionName: "pOlIcYdEfInItIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpNaMe/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYdEfInItIoNs/pOlIcYdEfInItIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviders2PolicyDefinitionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.ManagementGroupName != v.Expected.ManagementGroupName { + t.Fatalf("Expected %q but got %q for ManagementGroupName", v.Expected.ManagementGroupName, actual.ManagementGroupName) + } + + if actual.PolicyDefinitionName != v.Expected.PolicyDefinitionName { + t.Fatalf("Expected %q but got %q for PolicyDefinitionName", v.Expected.PolicyDefinitionName, actual.PolicyDefinitionName) + } + + } +} + +func TestSegmentsForProviders2PolicyDefinitionId(t *testing.T) { + segments := Providers2PolicyDefinitionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("Providers2PolicyDefinitionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/resources/2025-03-01/policydefinitionversions/id_providers2policydefinitionversion.go b/resource-manager/resources/2025-03-01/policydefinitionversions/id_providers2policydefinitionversion.go new file mode 100644 index 00000000000..9dfe76f91c5 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitionversions/id_providers2policydefinitionversion.go @@ -0,0 +1,132 @@ +package policydefinitionversions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&Providers2PolicyDefinitionVersionId{}) +} + +var _ resourceids.ResourceId = &Providers2PolicyDefinitionVersionId{} + +// Providers2PolicyDefinitionVersionId is a struct representing the Resource ID for a Providers 2 Policy Definition Version +type Providers2PolicyDefinitionVersionId struct { + ManagementGroupName string + PolicyDefinitionName string + VersionName string +} + +// NewProviders2PolicyDefinitionVersionID returns a new Providers2PolicyDefinitionVersionId struct +func NewProviders2PolicyDefinitionVersionID(managementGroupName string, policyDefinitionName string, versionName string) Providers2PolicyDefinitionVersionId { + return Providers2PolicyDefinitionVersionId{ + ManagementGroupName: managementGroupName, + PolicyDefinitionName: policyDefinitionName, + VersionName: versionName, + } +} + +// ParseProviders2PolicyDefinitionVersionID parses 'input' into a Providers2PolicyDefinitionVersionId +func ParseProviders2PolicyDefinitionVersionID(input string) (*Providers2PolicyDefinitionVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&Providers2PolicyDefinitionVersionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := Providers2PolicyDefinitionVersionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProviders2PolicyDefinitionVersionIDInsensitively parses 'input' case-insensitively into a Providers2PolicyDefinitionVersionId +// note: this method should only be used for API response data and not user input +func ParseProviders2PolicyDefinitionVersionIDInsensitively(input string) (*Providers2PolicyDefinitionVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&Providers2PolicyDefinitionVersionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := Providers2PolicyDefinitionVersionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *Providers2PolicyDefinitionVersionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.ManagementGroupName, ok = input.Parsed["managementGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managementGroupName", input) + } + + if id.PolicyDefinitionName, ok = input.Parsed["policyDefinitionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "policyDefinitionName", input) + } + + if id.VersionName, ok = input.Parsed["versionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "versionName", input) + } + + return nil +} + +// ValidateProviders2PolicyDefinitionVersionID checks that 'input' can be parsed as a Providers 2 Policy Definition Version ID +func ValidateProviders2PolicyDefinitionVersionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseProviders2PolicyDefinitionVersionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Providers 2 Policy Definition Version ID +func (id Providers2PolicyDefinitionVersionId) ID() string { + fmtString := "/providers/Microsoft.Management/managementGroups/%s/providers/Microsoft.Authorization/policyDefinitions/%s/versions/%s" + return fmt.Sprintf(fmtString, id.ManagementGroupName, id.PolicyDefinitionName, id.VersionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Providers 2 Policy Definition Version ID +func (id Providers2PolicyDefinitionVersionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftManagement", "Microsoft.Management", "Microsoft.Management"), + resourceids.StaticSegment("staticManagementGroups", "managementGroups", "managementGroups"), + resourceids.UserSpecifiedSegment("managementGroupName", "managementGroupName"), + resourceids.StaticSegment("staticProviders2", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftAuthorization", "Microsoft.Authorization", "Microsoft.Authorization"), + resourceids.StaticSegment("staticPolicyDefinitions", "policyDefinitions", "policyDefinitions"), + resourceids.UserSpecifiedSegment("policyDefinitionName", "policyDefinitionName"), + resourceids.StaticSegment("staticVersions", "versions", "versions"), + resourceids.UserSpecifiedSegment("versionName", "versionName"), + } +} + +// String returns a human-readable description of this Providers 2 Policy Definition Version ID +func (id Providers2PolicyDefinitionVersionId) String() string { + components := []string{ + fmt.Sprintf("Management Group Name: %q", id.ManagementGroupName), + fmt.Sprintf("Policy Definition Name: %q", id.PolicyDefinitionName), + fmt.Sprintf("Version Name: %q", id.VersionName), + } + return fmt.Sprintf("Providers 2 Policy Definition Version (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/resources/2025-03-01/policydefinitionversions/id_providers2policydefinitionversion_test.go b/resource-manager/resources/2025-03-01/policydefinitionversions/id_providers2policydefinitionversion_test.go new file mode 100644 index 00000000000..b609dcc9b0f --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitionversions/id_providers2policydefinitionversion_test.go @@ -0,0 +1,312 @@ +package policydefinitionversions + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &Providers2PolicyDefinitionVersionId{} + +func TestNewProviders2PolicyDefinitionVersionID(t *testing.T) { + id := NewProviders2PolicyDefinitionVersionID("managementGroupName", "policyDefinitionName", "versionName") + + if id.ManagementGroupName != "managementGroupName" { + t.Fatalf("Expected %q but got %q for Segment 'ManagementGroupName'", id.ManagementGroupName, "managementGroupName") + } + + if id.PolicyDefinitionName != "policyDefinitionName" { + t.Fatalf("Expected %q but got %q for Segment 'PolicyDefinitionName'", id.PolicyDefinitionName, "policyDefinitionName") + } + + if id.VersionName != "versionName" { + t.Fatalf("Expected %q but got %q for Segment 'VersionName'", id.VersionName, "versionName") + } +} + +func TestFormatProviders2PolicyDefinitionVersionID(t *testing.T) { + actual := NewProviders2PolicyDefinitionVersionID("managementGroupName", "policyDefinitionName", "versionName").ID() + expected := "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/versions/versionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProviders2PolicyDefinitionVersionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *Providers2PolicyDefinitionVersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policyDefinitions", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/versions", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/versions/versionName", + Expected: &Providers2PolicyDefinitionVersionId{ + ManagementGroupName: "managementGroupName", + PolicyDefinitionName: "policyDefinitionName", + VersionName: "versionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/versions/versionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviders2PolicyDefinitionVersionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.ManagementGroupName != v.Expected.ManagementGroupName { + t.Fatalf("Expected %q but got %q for ManagementGroupName", v.Expected.ManagementGroupName, actual.ManagementGroupName) + } + + if actual.PolicyDefinitionName != v.Expected.PolicyDefinitionName { + t.Fatalf("Expected %q but got %q for PolicyDefinitionName", v.Expected.PolicyDefinitionName, actual.PolicyDefinitionName) + } + + if actual.VersionName != v.Expected.VersionName { + t.Fatalf("Expected %q but got %q for VersionName", v.Expected.VersionName, actual.VersionName) + } + + } +} + +func TestParseProviders2PolicyDefinitionVersionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *Providers2PolicyDefinitionVersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpNaMe/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpNaMe/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policyDefinitions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpNaMe/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYdEfInItIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpNaMe/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYdEfInItIoNs/pOlIcYdEfInItIoNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/versions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpNaMe/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYdEfInItIoNs/pOlIcYdEfInItIoNnAmE/vErSiOnS", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/versions/versionName", + Expected: &Providers2PolicyDefinitionVersionId{ + ManagementGroupName: "managementGroupName", + PolicyDefinitionName: "policyDefinitionName", + VersionName: "versionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/versions/versionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpNaMe/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYdEfInItIoNs/pOlIcYdEfInItIoNnAmE/vErSiOnS/vErSiOnNaMe", + Expected: &Providers2PolicyDefinitionVersionId{ + ManagementGroupName: "mAnAgEmEnTgRoUpNaMe", + PolicyDefinitionName: "pOlIcYdEfInItIoNnAmE", + VersionName: "vErSiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpNaMe/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYdEfInItIoNs/pOlIcYdEfInItIoNnAmE/vErSiOnS/vErSiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviders2PolicyDefinitionVersionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.ManagementGroupName != v.Expected.ManagementGroupName { + t.Fatalf("Expected %q but got %q for ManagementGroupName", v.Expected.ManagementGroupName, actual.ManagementGroupName) + } + + if actual.PolicyDefinitionName != v.Expected.PolicyDefinitionName { + t.Fatalf("Expected %q but got %q for PolicyDefinitionName", v.Expected.PolicyDefinitionName, actual.PolicyDefinitionName) + } + + if actual.VersionName != v.Expected.VersionName { + t.Fatalf("Expected %q but got %q for VersionName", v.Expected.VersionName, actual.VersionName) + } + + } +} + +func TestSegmentsForProviders2PolicyDefinitionVersionId(t *testing.T) { + segments := Providers2PolicyDefinitionVersionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("Providers2PolicyDefinitionVersionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/resources/2025-03-01/policydefinitionversions/id_version.go b/resource-manager/resources/2025-03-01/policydefinitionversions/id_version.go new file mode 100644 index 00000000000..ce6f46f871b --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitionversions/id_version.go @@ -0,0 +1,121 @@ +package policydefinitionversions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VersionId{}) +} + +var _ resourceids.ResourceId = &VersionId{} + +// VersionId is a struct representing the Resource ID for a Version +type VersionId struct { + PolicyDefinitionName string + VersionName string +} + +// NewVersionID returns a new VersionId struct +func NewVersionID(policyDefinitionName string, versionName string) VersionId { + return VersionId{ + PolicyDefinitionName: policyDefinitionName, + VersionName: versionName, + } +} + +// ParseVersionID parses 'input' into a VersionId +func ParseVersionID(input string) (*VersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&VersionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VersionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVersionIDInsensitively parses 'input' case-insensitively into a VersionId +// note: this method should only be used for API response data and not user input +func ParseVersionIDInsensitively(input string) (*VersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&VersionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VersionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VersionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.PolicyDefinitionName, ok = input.Parsed["policyDefinitionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "policyDefinitionName", input) + } + + if id.VersionName, ok = input.Parsed["versionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "versionName", input) + } + + return nil +} + +// ValidateVersionID checks that 'input' can be parsed as a Version ID +func ValidateVersionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVersionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Version ID +func (id VersionId) ID() string { + fmtString := "/providers/Microsoft.Authorization/policyDefinitions/%s/versions/%s" + return fmt.Sprintf(fmtString, id.PolicyDefinitionName, id.VersionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Version ID +func (id VersionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftAuthorization", "Microsoft.Authorization", "Microsoft.Authorization"), + resourceids.StaticSegment("staticPolicyDefinitions", "policyDefinitions", "policyDefinitions"), + resourceids.UserSpecifiedSegment("policyDefinitionName", "policyDefinitionName"), + resourceids.StaticSegment("staticVersions", "versions", "versions"), + resourceids.UserSpecifiedSegment("versionName", "versionName"), + } +} + +// String returns a human-readable description of this Version ID +func (id VersionId) String() string { + components := []string{ + fmt.Sprintf("Policy Definition Name: %q", id.PolicyDefinitionName), + fmt.Sprintf("Version Name: %q", id.VersionName), + } + return fmt.Sprintf("Version (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/resources/2025-03-01/policydefinitionversions/id_version_test.go b/resource-manager/resources/2025-03-01/policydefinitionversions/id_version_test.go new file mode 100644 index 00000000000..c2e814ea098 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitionversions/id_version_test.go @@ -0,0 +1,237 @@ +package policydefinitionversions + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VersionId{} + +func TestNewVersionID(t *testing.T) { + id := NewVersionID("policyDefinitionName", "versionName") + + if id.PolicyDefinitionName != "policyDefinitionName" { + t.Fatalf("Expected %q but got %q for Segment 'PolicyDefinitionName'", id.PolicyDefinitionName, "policyDefinitionName") + } + + if id.VersionName != "versionName" { + t.Fatalf("Expected %q but got %q for Segment 'VersionName'", id.VersionName, "versionName") + } +} + +func TestFormatVersionID(t *testing.T) { + actual := NewVersionID("policyDefinitionName", "versionName").ID() + expected := "/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/versions/versionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVersionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Authorization/policyDefinitions", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/versions", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/versions/versionName", + Expected: &VersionId{ + PolicyDefinitionName: "policyDefinitionName", + VersionName: "versionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/versions/versionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVersionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.PolicyDefinitionName != v.Expected.PolicyDefinitionName { + t.Fatalf("Expected %q but got %q for PolicyDefinitionName", v.Expected.PolicyDefinitionName, actual.PolicyDefinitionName) + } + + if actual.VersionName != v.Expected.VersionName { + t.Fatalf("Expected %q but got %q for VersionName", v.Expected.VersionName, actual.VersionName) + } + + } +} + +func TestParseVersionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Authorization/policyDefinitions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYdEfInItIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYdEfInItIoNs/pOlIcYdEfInItIoNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/versions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYdEfInItIoNs/pOlIcYdEfInItIoNnAmE/vErSiOnS", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/versions/versionName", + Expected: &VersionId{ + PolicyDefinitionName: "policyDefinitionName", + VersionName: "versionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/versions/versionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYdEfInItIoNs/pOlIcYdEfInItIoNnAmE/vErSiOnS/vErSiOnNaMe", + Expected: &VersionId{ + PolicyDefinitionName: "pOlIcYdEfInItIoNnAmE", + VersionName: "vErSiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYdEfInItIoNs/pOlIcYdEfInItIoNnAmE/vErSiOnS/vErSiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVersionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.PolicyDefinitionName != v.Expected.PolicyDefinitionName { + t.Fatalf("Expected %q but got %q for PolicyDefinitionName", v.Expected.PolicyDefinitionName, actual.PolicyDefinitionName) + } + + if actual.VersionName != v.Expected.VersionName { + t.Fatalf("Expected %q but got %q for VersionName", v.Expected.VersionName, actual.VersionName) + } + + } +} + +func TestSegmentsForVersionId(t *testing.T) { + segments := VersionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VersionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/resources/2025-03-01/policydefinitionversions/method_createorupdate.go b/resource-manager/resources/2025-03-01/policydefinitionversions/method_createorupdate.go new file mode 100644 index 00000000000..5248bef72ed --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitionversions/method_createorupdate.go @@ -0,0 +1,58 @@ +package policydefinitionversions + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *PolicyDefinitionVersion +} + +// CreateOrUpdate ... +func (c PolicyDefinitionVersionsClient) CreateOrUpdate(ctx context.Context, id PolicyDefinitionVersionId, input PolicyDefinitionVersion) (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 PolicyDefinitionVersion + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/resources/2025-03-01/policydefinitionversions/method_createorupdateatmanagementgroup.go b/resource-manager/resources/2025-03-01/policydefinitionversions/method_createorupdateatmanagementgroup.go new file mode 100644 index 00000000000..38bc47e27ac --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitionversions/method_createorupdateatmanagementgroup.go @@ -0,0 +1,58 @@ +package policydefinitionversions + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateAtManagementGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicyDefinitionVersion +} + +// CreateOrUpdateAtManagementGroup ... +func (c PolicyDefinitionVersionsClient) CreateOrUpdateAtManagementGroup(ctx context.Context, id Providers2PolicyDefinitionVersionId, input PolicyDefinitionVersion) (result CreateOrUpdateAtManagementGroupOperationResponse, 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 PolicyDefinitionVersion + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/logz/2020-10-01/tagrules/method_subaccounttagrulesdelete.go b/resource-manager/resources/2025-03-01/policydefinitionversions/method_delete.go similarity index 74% rename from resource-manager/logz/2020-10-01/tagrules/method_subaccounttagrulesdelete.go rename to resource-manager/resources/2025-03-01/policydefinitionversions/method_delete.go index eaae465991a..b0bc3317c9d 100644 --- a/resource-manager/logz/2020-10-01/tagrules/method_subaccounttagrulesdelete.go +++ b/resource-manager/resources/2025-03-01/policydefinitionversions/method_delete.go @@ -1,4 +1,4 @@ -package tagrules +package policydefinitionversions import ( "context" @@ -11,17 +11,16 @@ import ( // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. -type SubAccountTagRulesDeleteOperationResponse struct { +type DeleteOperationResponse struct { HttpResponse *http.Response OData *odata.OData } -// SubAccountTagRulesDelete ... -func (c TagRulesClient) SubAccountTagRulesDelete(ctx context.Context, id AccountTagRuleId) (result SubAccountTagRulesDeleteOperationResponse, err error) { +// Delete ... +func (c PolicyDefinitionVersionsClient) Delete(ctx context.Context, id PolicyDefinitionVersionId) (result DeleteOperationResponse, err error) { opts := client.RequestOptions{ ContentType: "application/json; charset=utf-8", ExpectedStatusCodes: []int{ - http.StatusAccepted, http.StatusNoContent, http.StatusOK, }, diff --git a/resource-manager/resources/2025-03-01/policydefinitionversions/method_deleteatmanagementgroup.go b/resource-manager/resources/2025-03-01/policydefinitionversions/method_deleteatmanagementgroup.go new file mode 100644 index 00000000000..e3843b37c57 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitionversions/method_deleteatmanagementgroup.go @@ -0,0 +1,47 @@ +package policydefinitionversions + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteAtManagementGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteAtManagementGroup ... +func (c PolicyDefinitionVersionsClient) DeleteAtManagementGroup(ctx context.Context, id Providers2PolicyDefinitionVersionId) (result DeleteAtManagementGroupOperationResponse, 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/logz/2020-10-01/singlesignon/method_get.go b/resource-manager/resources/2025-03-01/policydefinitionversions/method_get.go similarity index 79% rename from resource-manager/logz/2020-10-01/singlesignon/method_get.go rename to resource-manager/resources/2025-03-01/policydefinitionversions/method_get.go index 693f1c8ad4d..cad28eff23d 100644 --- a/resource-manager/logz/2020-10-01/singlesignon/method_get.go +++ b/resource-manager/resources/2025-03-01/policydefinitionversions/method_get.go @@ -1,4 +1,4 @@ -package singlesignon +package policydefinitionversions import ( "context" @@ -14,11 +14,11 @@ import ( type GetOperationResponse struct { HttpResponse *http.Response OData *odata.OData - Model *LogzSingleSignOnResource + Model *PolicyDefinitionVersion } // Get ... -func (c SingleSignOnClient) Get(ctx context.Context, id SingleSignOnConfigurationId) (result GetOperationResponse, err error) { +func (c PolicyDefinitionVersionsClient) Get(ctx context.Context, id PolicyDefinitionVersionId) (result GetOperationResponse, err error) { opts := client.RequestOptions{ ContentType: "application/json; charset=utf-8", ExpectedStatusCodes: []int{ @@ -43,7 +43,7 @@ func (c SingleSignOnClient) Get(ctx context.Context, id SingleSignOnConfiguratio return } - var model LogzSingleSignOnResource + var model PolicyDefinitionVersion result.Model = &model if err = resp.Unmarshal(result.Model); err != nil { return diff --git a/resource-manager/resources/2025-03-01/policydefinitionversions/method_getatmanagementgroup.go b/resource-manager/resources/2025-03-01/policydefinitionversions/method_getatmanagementgroup.go new file mode 100644 index 00000000000..5d62cf59198 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitionversions/method_getatmanagementgroup.go @@ -0,0 +1,53 @@ +package policydefinitionversions + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetAtManagementGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicyDefinitionVersion +} + +// GetAtManagementGroup ... +func (c PolicyDefinitionVersionsClient) GetAtManagementGroup(ctx context.Context, id Providers2PolicyDefinitionVersionId) (result GetAtManagementGroupOperationResponse, 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 PolicyDefinitionVersion + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/resources/2025-03-01/policydefinitionversions/method_getbuiltin.go b/resource-manager/resources/2025-03-01/policydefinitionversions/method_getbuiltin.go new file mode 100644 index 00000000000..17cb6e0faf3 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitionversions/method_getbuiltin.go @@ -0,0 +1,53 @@ +package policydefinitionversions + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetBuiltInOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicyDefinitionVersion +} + +// GetBuiltIn ... +func (c PolicyDefinitionVersionsClient) GetBuiltIn(ctx context.Context, id VersionId) (result GetBuiltInOperationResponse, 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 PolicyDefinitionVersion + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/logz/2020-10-01/singlesignon/method_list.go b/resource-manager/resources/2025-03-01/policydefinitionversions/method_list.go similarity index 51% rename from resource-manager/logz/2020-10-01/singlesignon/method_list.go rename to resource-manager/resources/2025-03-01/policydefinitionversions/method_list.go index b46549cc5fc..2cf45b424e4 100644 --- a/resource-manager/logz/2020-10-01/singlesignon/method_list.go +++ b/resource-manager/resources/2025-03-01/policydefinitionversions/method_list.go @@ -1,4 +1,4 @@ -package singlesignon +package policydefinitionversions import ( "context" @@ -15,12 +15,40 @@ import ( type ListOperationResponse struct { HttpResponse *http.Response OData *odata.OData - Model *[]LogzSingleSignOnResource + Model *[]PolicyDefinitionVersion } type ListCompleteResult struct { LatestHttpResponse *http.Response - Items []LogzSingleSignOnResource + Items []PolicyDefinitionVersion +} + +type ListOperationOptions struct { + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out } type ListCustomPager struct { @@ -36,15 +64,16 @@ func (p *ListCustomPager) NextPageLink() *odata.Link { } // List ... -func (c SingleSignOnClient) List(ctx context.Context, id MonitorId) (result ListOperationResponse, err error) { +func (c PolicyDefinitionVersionsClient) List(ctx context.Context, id ProviderPolicyDefinitionId, options ListOperationOptions) (result ListOperationResponse, err error) { opts := client.RequestOptions{ ContentType: "application/json; charset=utf-8", ExpectedStatusCodes: []int{ http.StatusOK, }, - HttpMethod: http.MethodGet, - Pager: &ListCustomPager{}, - Path: fmt.Sprintf("%s/singleSignOnConfigurations", id.ID()), + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/versions", id.ID()), } req, err := c.Client.NewRequest(ctx, opts) @@ -63,7 +92,7 @@ func (c SingleSignOnClient) List(ctx context.Context, id MonitorId) (result List } var values struct { - Values *[]LogzSingleSignOnResource `json:"value"` + Values *[]PolicyDefinitionVersion `json:"value"` } if err = resp.Unmarshal(&values); err != nil { return @@ -75,15 +104,15 @@ func (c SingleSignOnClient) List(ctx context.Context, id MonitorId) (result List } // ListComplete retrieves all the results into a single object -func (c SingleSignOnClient) ListComplete(ctx context.Context, id MonitorId) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, LogzSingleSignOnResourceOperationPredicate{}) +func (c PolicyDefinitionVersionsClient) ListComplete(ctx context.Context, id ProviderPolicyDefinitionId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, PolicyDefinitionVersionOperationPredicate{}) } // ListCompleteMatchingPredicate retrieves all the results and then applies the predicate -func (c SingleSignOnClient) ListCompleteMatchingPredicate(ctx context.Context, id MonitorId, predicate LogzSingleSignOnResourceOperationPredicate) (result ListCompleteResult, err error) { - items := make([]LogzSingleSignOnResource, 0) +func (c PolicyDefinitionVersionsClient) ListCompleteMatchingPredicate(ctx context.Context, id ProviderPolicyDefinitionId, options ListOperationOptions, predicate PolicyDefinitionVersionOperationPredicate) (result ListCompleteResult, err error) { + items := make([]PolicyDefinitionVersion, 0) - resp, err := c.List(ctx, id) + resp, err := c.List(ctx, id, options) if err != nil { result.LatestHttpResponse = resp.HttpResponse err = fmt.Errorf("loading results: %+v", err) diff --git a/resource-manager/resources/2025-03-01/policydefinitionversions/method_listall.go b/resource-manager/resources/2025-03-01/policydefinitionversions/method_listall.go new file mode 100644 index 00000000000..4a992172f23 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitionversions/method_listall.go @@ -0,0 +1,106 @@ +package policydefinitionversions + +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 ListAllOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PolicyDefinitionVersion +} + +type ListAllCompleteResult struct { + LatestHttpResponse *http.Response + Items []PolicyDefinitionVersion +} + +type ListAllCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListAllCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListAll ... +func (c PolicyDefinitionVersionsClient) ListAll(ctx context.Context, id commonids.SubscriptionId) (result ListAllOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ListAllCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Authorization/listPolicyDefinitionVersions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PolicyDefinitionVersion `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAllComplete retrieves all the results into a single object +func (c PolicyDefinitionVersionsClient) ListAllComplete(ctx context.Context, id commonids.SubscriptionId) (ListAllCompleteResult, error) { + return c.ListAllCompleteMatchingPredicate(ctx, id, PolicyDefinitionVersionOperationPredicate{}) +} + +// ListAllCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PolicyDefinitionVersionsClient) ListAllCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate PolicyDefinitionVersionOperationPredicate) (result ListAllCompleteResult, err error) { + items := make([]PolicyDefinitionVersion, 0) + + resp, err := c.ListAll(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 = ListAllCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/resources/2025-03-01/policydefinitionversions/method_listallatmanagementgroup.go b/resource-manager/resources/2025-03-01/policydefinitionversions/method_listallatmanagementgroup.go new file mode 100644 index 00000000000..63c8235e445 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitionversions/method_listallatmanagementgroup.go @@ -0,0 +1,106 @@ +package policydefinitionversions + +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 ListAllAtManagementGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PolicyDefinitionVersion +} + +type ListAllAtManagementGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []PolicyDefinitionVersion +} + +type ListAllAtManagementGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListAllAtManagementGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListAllAtManagementGroup ... +func (c PolicyDefinitionVersionsClient) ListAllAtManagementGroup(ctx context.Context, id commonids.ManagementGroupId) (result ListAllAtManagementGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ListAllAtManagementGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Authorization/listPolicyDefinitionVersions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PolicyDefinitionVersion `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAllAtManagementGroupComplete retrieves all the results into a single object +func (c PolicyDefinitionVersionsClient) ListAllAtManagementGroupComplete(ctx context.Context, id commonids.ManagementGroupId) (ListAllAtManagementGroupCompleteResult, error) { + return c.ListAllAtManagementGroupCompleteMatchingPredicate(ctx, id, PolicyDefinitionVersionOperationPredicate{}) +} + +// ListAllAtManagementGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PolicyDefinitionVersionsClient) ListAllAtManagementGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ManagementGroupId, predicate PolicyDefinitionVersionOperationPredicate) (result ListAllAtManagementGroupCompleteResult, err error) { + items := make([]PolicyDefinitionVersion, 0) + + resp, err := c.ListAllAtManagementGroup(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 = ListAllAtManagementGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/logz/2020-10-01/vmhost/method_subaccountlistvmhosts.go b/resource-manager/resources/2025-03-01/policydefinitionversions/method_listallbuiltins.go similarity index 50% rename from resource-manager/logz/2020-10-01/vmhost/method_subaccountlistvmhosts.go rename to resource-manager/resources/2025-03-01/policydefinitionversions/method_listallbuiltins.go index 2516b25a439..8fd53743f10 100644 --- a/resource-manager/logz/2020-10-01/vmhost/method_subaccountlistvmhosts.go +++ b/resource-manager/resources/2025-03-01/policydefinitionversions/method_listallbuiltins.go @@ -1,4 +1,4 @@ -package vmhost +package policydefinitionversions import ( "context" @@ -12,22 +12,22 @@ import ( // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. -type SubAccountListVMHostsOperationResponse struct { +type ListAllBuiltinsOperationResponse struct { HttpResponse *http.Response OData *odata.OData - Model *[]VMResources + Model *[]PolicyDefinitionVersion } -type SubAccountListVMHostsCompleteResult struct { +type ListAllBuiltinsCompleteResult struct { LatestHttpResponse *http.Response - Items []VMResources + Items []PolicyDefinitionVersion } -type SubAccountListVMHostsCustomPager struct { +type ListAllBuiltinsCustomPager struct { NextLink *odata.Link `json:"nextLink"` } -func (p *SubAccountListVMHostsCustomPager) NextPageLink() *odata.Link { +func (p *ListAllBuiltinsCustomPager) NextPageLink() *odata.Link { defer func() { p.NextLink = nil }() @@ -35,16 +35,16 @@ func (p *SubAccountListVMHostsCustomPager) NextPageLink() *odata.Link { return p.NextLink } -// SubAccountListVMHosts ... -func (c VMHostClient) SubAccountListVMHosts(ctx context.Context, id AccountId) (result SubAccountListVMHostsOperationResponse, err error) { +// ListAllBuiltins ... +func (c PolicyDefinitionVersionsClient) ListAllBuiltins(ctx context.Context) (result ListAllBuiltinsOperationResponse, err error) { opts := client.RequestOptions{ ContentType: "application/json; charset=utf-8", ExpectedStatusCodes: []int{ http.StatusOK, }, HttpMethod: http.MethodPost, - Pager: &SubAccountListVMHostsCustomPager{}, - Path: fmt.Sprintf("%s/listVMHosts", id.ID()), + Pager: &ListAllBuiltinsCustomPager{}, + Path: "/providers/Microsoft.Authorization/listPolicyDefinitionVersions", } req, err := c.Client.NewRequest(ctx, opts) @@ -63,7 +63,7 @@ func (c VMHostClient) SubAccountListVMHosts(ctx context.Context, id AccountId) ( } var values struct { - Values *[]VMResources `json:"value"` + Values *[]PolicyDefinitionVersion `json:"value"` } if err = resp.Unmarshal(&values); err != nil { return @@ -74,16 +74,16 @@ func (c VMHostClient) SubAccountListVMHosts(ctx context.Context, id AccountId) ( return } -// SubAccountListVMHostsComplete retrieves all the results into a single object -func (c VMHostClient) SubAccountListVMHostsComplete(ctx context.Context, id AccountId) (SubAccountListVMHostsCompleteResult, error) { - return c.SubAccountListVMHostsCompleteMatchingPredicate(ctx, id, VMResourcesOperationPredicate{}) +// ListAllBuiltinsComplete retrieves all the results into a single object +func (c PolicyDefinitionVersionsClient) ListAllBuiltinsComplete(ctx context.Context) (ListAllBuiltinsCompleteResult, error) { + return c.ListAllBuiltinsCompleteMatchingPredicate(ctx, PolicyDefinitionVersionOperationPredicate{}) } -// SubAccountListVMHostsCompleteMatchingPredicate retrieves all the results and then applies the predicate -func (c VMHostClient) SubAccountListVMHostsCompleteMatchingPredicate(ctx context.Context, id AccountId, predicate VMResourcesOperationPredicate) (result SubAccountListVMHostsCompleteResult, err error) { - items := make([]VMResources, 0) +// ListAllBuiltinsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PolicyDefinitionVersionsClient) ListAllBuiltinsCompleteMatchingPredicate(ctx context.Context, predicate PolicyDefinitionVersionOperationPredicate) (result ListAllBuiltinsCompleteResult, err error) { + items := make([]PolicyDefinitionVersion, 0) - resp, err := c.SubAccountListVMHosts(ctx, id) + resp, err := c.ListAllBuiltins(ctx) if err != nil { result.LatestHttpResponse = resp.HttpResponse err = fmt.Errorf("loading results: %+v", err) @@ -97,7 +97,7 @@ func (c VMHostClient) SubAccountListVMHostsCompleteMatchingPredicate(ctx context } } - result = SubAccountListVMHostsCompleteResult{ + result = ListAllBuiltinsCompleteResult{ LatestHttpResponse: resp.HttpResponse, Items: items, } diff --git a/resource-manager/resources/2025-03-01/policydefinitionversions/method_listbuiltin.go b/resource-manager/resources/2025-03-01/policydefinitionversions/method_listbuiltin.go new file mode 100644 index 00000000000..6211414c0a0 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitionversions/method_listbuiltin.go @@ -0,0 +1,134 @@ +package policydefinitionversions + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListBuiltInOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PolicyDefinitionVersion +} + +type ListBuiltInCompleteResult struct { + LatestHttpResponse *http.Response + Items []PolicyDefinitionVersion +} + +type ListBuiltInOperationOptions struct { + Top *int64 +} + +func DefaultListBuiltInOperationOptions() ListBuiltInOperationOptions { + return ListBuiltInOperationOptions{} +} + +func (o ListBuiltInOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListBuiltInOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListBuiltInOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListBuiltInCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBuiltInCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBuiltIn ... +func (c PolicyDefinitionVersionsClient) ListBuiltIn(ctx context.Context, id PolicyDefinitionId, options ListBuiltInOperationOptions) (result ListBuiltInOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListBuiltInCustomPager{}, + Path: fmt.Sprintf("%s/versions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PolicyDefinitionVersion `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBuiltInComplete retrieves all the results into a single object +func (c PolicyDefinitionVersionsClient) ListBuiltInComplete(ctx context.Context, id PolicyDefinitionId, options ListBuiltInOperationOptions) (ListBuiltInCompleteResult, error) { + return c.ListBuiltInCompleteMatchingPredicate(ctx, id, options, PolicyDefinitionVersionOperationPredicate{}) +} + +// ListBuiltInCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PolicyDefinitionVersionsClient) ListBuiltInCompleteMatchingPredicate(ctx context.Context, id PolicyDefinitionId, options ListBuiltInOperationOptions, predicate PolicyDefinitionVersionOperationPredicate) (result ListBuiltInCompleteResult, err error) { + items := make([]PolicyDefinitionVersion, 0) + + resp, err := c.ListBuiltIn(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 = ListBuiltInCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/resources/2025-03-01/policydefinitionversions/method_listbymanagementgroup.go b/resource-manager/resources/2025-03-01/policydefinitionversions/method_listbymanagementgroup.go new file mode 100644 index 00000000000..fa899ddfcd4 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitionversions/method_listbymanagementgroup.go @@ -0,0 +1,134 @@ +package policydefinitionversions + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByManagementGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PolicyDefinitionVersion +} + +type ListByManagementGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []PolicyDefinitionVersion +} + +type ListByManagementGroupOperationOptions struct { + Top *int64 +} + +func DefaultListByManagementGroupOperationOptions() ListByManagementGroupOperationOptions { + return ListByManagementGroupOperationOptions{} +} + +func (o ListByManagementGroupOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByManagementGroupOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListByManagementGroupOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListByManagementGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByManagementGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByManagementGroup ... +func (c PolicyDefinitionVersionsClient) ListByManagementGroup(ctx context.Context, id Providers2PolicyDefinitionId, options ListByManagementGroupOperationOptions) (result ListByManagementGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListByManagementGroupCustomPager{}, + Path: fmt.Sprintf("%s/versions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PolicyDefinitionVersion `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByManagementGroupComplete retrieves all the results into a single object +func (c PolicyDefinitionVersionsClient) ListByManagementGroupComplete(ctx context.Context, id Providers2PolicyDefinitionId, options ListByManagementGroupOperationOptions) (ListByManagementGroupCompleteResult, error) { + return c.ListByManagementGroupCompleteMatchingPredicate(ctx, id, options, PolicyDefinitionVersionOperationPredicate{}) +} + +// ListByManagementGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PolicyDefinitionVersionsClient) ListByManagementGroupCompleteMatchingPredicate(ctx context.Context, id Providers2PolicyDefinitionId, options ListByManagementGroupOperationOptions, predicate PolicyDefinitionVersionOperationPredicate) (result ListByManagementGroupCompleteResult, err error) { + items := make([]PolicyDefinitionVersion, 0) + + resp, err := c.ListByManagementGroup(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 = ListByManagementGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/resources/2025-03-01/policydefinitionversions/model_externalevaluationendpointsettings.go b/resource-manager/resources/2025-03-01/policydefinitionversions/model_externalevaluationendpointsettings.go new file mode 100644 index 00000000000..a2644354e0b --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitionversions/model_externalevaluationendpointsettings.go @@ -0,0 +1,9 @@ +package policydefinitionversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExternalEvaluationEndpointSettings struct { + Details *interface{} `json:"details,omitempty"` + Kind *string `json:"kind,omitempty"` +} diff --git a/resource-manager/resources/2025-03-01/policydefinitionversions/model_externalevaluationenforcementsettings.go b/resource-manager/resources/2025-03-01/policydefinitionversions/model_externalevaluationenforcementsettings.go new file mode 100644 index 00000000000..c685ae84ba8 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitionversions/model_externalevaluationenforcementsettings.go @@ -0,0 +1,11 @@ +package policydefinitionversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExternalEvaluationEnforcementSettings struct { + EndpointSettings *ExternalEvaluationEndpointSettings `json:"endpointSettings,omitempty"` + MissingTokenAction *string `json:"missingTokenAction,omitempty"` + ResultLifespan *string `json:"resultLifespan,omitempty"` + RoleDefinitionIds *[]string `json:"roleDefinitionIds,omitempty"` +} diff --git a/resource-manager/resources/2025-03-01/policydefinitionversions/model_parameterdefinitionsvalue.go b/resource-manager/resources/2025-03-01/policydefinitionversions/model_parameterdefinitionsvalue.go new file mode 100644 index 00000000000..924a3e907c0 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitionversions/model_parameterdefinitionsvalue.go @@ -0,0 +1,12 @@ +package policydefinitionversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ParameterDefinitionsValue struct { + AllowedValues *[]interface{} `json:"allowedValues,omitempty"` + DefaultValue *interface{} `json:"defaultValue,omitempty"` + Metadata *ParameterDefinitionsValueMetadata `json:"metadata,omitempty"` + Schema *interface{} `json:"schema,omitempty"` + Type *ParameterType `json:"type,omitempty"` +} diff --git a/resource-manager/resources/2025-03-01/policydefinitionversions/model_parameterdefinitionsvaluemetadata.go b/resource-manager/resources/2025-03-01/policydefinitionversions/model_parameterdefinitionsvaluemetadata.go new file mode 100644 index 00000000000..946f532c70b --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitionversions/model_parameterdefinitionsvaluemetadata.go @@ -0,0 +1,11 @@ +package policydefinitionversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ParameterDefinitionsValueMetadata struct { + AssignPermissions *bool `json:"assignPermissions,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + StrongType *string `json:"strongType,omitempty"` +} diff --git a/resource-manager/resources/2025-03-01/policydefinitionversions/model_policydefinitionversion.go b/resource-manager/resources/2025-03-01/policydefinitionversions/model_policydefinitionversion.go new file mode 100644 index 00000000000..e85b06a71b7 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitionversions/model_policydefinitionversion.go @@ -0,0 +1,16 @@ +package policydefinitionversions + +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 PolicyDefinitionVersion struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PolicyDefinitionVersionProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/resources/2025-03-01/policydefinitionversions/model_policydefinitionversionproperties.go b/resource-manager/resources/2025-03-01/policydefinitionversions/model_policydefinitionversionproperties.go new file mode 100644 index 00000000000..e5da77db767 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitionversions/model_policydefinitionversionproperties.go @@ -0,0 +1,16 @@ +package policydefinitionversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PolicyDefinitionVersionProperties struct { + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + ExternalEvaluationEnforcementSettings *ExternalEvaluationEnforcementSettings `json:"externalEvaluationEnforcementSettings,omitempty"` + Metadata *interface{} `json:"metadata,omitempty"` + Mode *string `json:"mode,omitempty"` + Parameters *map[string]ParameterDefinitionsValue `json:"parameters,omitempty"` + PolicyRule *interface{} `json:"policyRule,omitempty"` + PolicyType *PolicyType `json:"policyType,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/resources/2025-03-01/policydefinitionversions/predicates.go b/resource-manager/resources/2025-03-01/policydefinitionversions/predicates.go new file mode 100644 index 00000000000..4959126875b --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitionversions/predicates.go @@ -0,0 +1,27 @@ +package policydefinitionversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PolicyDefinitionVersionOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p PolicyDefinitionVersionOperationPredicate) Matches(input PolicyDefinitionVersion) 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/resources/2025-03-01/policydefinitionversions/version.go b/resource-manager/resources/2025-03-01/policydefinitionversions/version.go new file mode 100644 index 00000000000..899f55f5082 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policydefinitionversions/version.go @@ -0,0 +1,10 @@ +package policydefinitionversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-03-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/policydefinitionversions/2025-03-01" +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitions/README.md b/resource-manager/resources/2025-03-01/policysetdefinitions/README.md new file mode 100644 index 00000000000..f0c5744a7ff --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitions/README.md @@ -0,0 +1,194 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/resources/2025-03-01/policysetdefinitions` Documentation + +The `policysetdefinitions` SDK allows for interaction with Azure Resource Manager `resources` (API Version `2025-03-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/resources/2025-03-01/policysetdefinitions" +``` + + +### Client Initialization + +```go +client := policysetdefinitions.NewPolicySetDefinitionsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PolicySetDefinitionsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := policysetdefinitions.NewProviderPolicySetDefinitionID("12345678-1234-9876-4563-123456789012", "policySetDefinitionName") + +payload := policysetdefinitions.PolicySetDefinition{ + // ... +} + + +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: `PolicySetDefinitionsClient.CreateOrUpdateAtManagementGroup` + +```go +ctx := context.TODO() +id := policysetdefinitions.NewProviders2PolicySetDefinitionID("managementGroupName", "policySetDefinitionName") + +payload := policysetdefinitions.PolicySetDefinition{ + // ... +} + + +read, err := client.CreateOrUpdateAtManagementGroup(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PolicySetDefinitionsClient.Delete` + +```go +ctx := context.TODO() +id := policysetdefinitions.NewProviderPolicySetDefinitionID("12345678-1234-9876-4563-123456789012", "policySetDefinitionName") + +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: `PolicySetDefinitionsClient.DeleteAtManagementGroup` + +```go +ctx := context.TODO() +id := policysetdefinitions.NewProviders2PolicySetDefinitionID("managementGroupName", "policySetDefinitionName") + +read, err := client.DeleteAtManagementGroup(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PolicySetDefinitionsClient.Get` + +```go +ctx := context.TODO() +id := policysetdefinitions.NewProviderPolicySetDefinitionID("12345678-1234-9876-4563-123456789012", "policySetDefinitionName") + +read, err := client.Get(ctx, id, policysetdefinitions.DefaultGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PolicySetDefinitionsClient.GetAtManagementGroup` + +```go +ctx := context.TODO() +id := policysetdefinitions.NewProviders2PolicySetDefinitionID("managementGroupName", "policySetDefinitionName") + +read, err := client.GetAtManagementGroup(ctx, id, policysetdefinitions.DefaultGetAtManagementGroupOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PolicySetDefinitionsClient.GetBuiltIn` + +```go +ctx := context.TODO() +id := policysetdefinitions.NewPolicySetDefinitionID("policySetDefinitionName") + +read, err := client.GetBuiltIn(ctx, id, policysetdefinitions.DefaultGetBuiltInOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PolicySetDefinitionsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id, policysetdefinitions.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, policysetdefinitions.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PolicySetDefinitionsClient.ListBuiltIn` + +```go +ctx := context.TODO() + + +// alternatively `client.ListBuiltIn(ctx, policysetdefinitions.DefaultListBuiltInOperationOptions())` can be used to do batched pagination +items, err := client.ListBuiltInComplete(ctx, policysetdefinitions.DefaultListBuiltInOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PolicySetDefinitionsClient.ListByManagementGroup` + +```go +ctx := context.TODO() +id := commonids.NewManagementGroupID("groupId") + +// alternatively `client.ListByManagementGroup(ctx, id, policysetdefinitions.DefaultListByManagementGroupOperationOptions())` can be used to do batched pagination +items, err := client.ListByManagementGroupComplete(ctx, id, policysetdefinitions.DefaultListByManagementGroupOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/resources/2025-03-01/policysetdefinitions/client.go b/resource-manager/resources/2025-03-01/policysetdefinitions/client.go new file mode 100644 index 00000000000..10b35d461c0 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitions/client.go @@ -0,0 +1,26 @@ +package policysetdefinitions + +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 PolicySetDefinitionsClient struct { + Client *resourcemanager.Client +} + +func NewPolicySetDefinitionsClientWithBaseURI(sdkApi sdkEnv.Api) (*PolicySetDefinitionsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "policysetdefinitions", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PolicySetDefinitionsClient: %+v", err) + } + + return &PolicySetDefinitionsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitions/constants.go b/resource-manager/resources/2025-03-01/policysetdefinitions/constants.go new file mode 100644 index 00000000000..6c3aa285a7e --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitions/constants.go @@ -0,0 +1,113 @@ +package policysetdefinitions + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ParameterType string + +const ( + ParameterTypeArray ParameterType = "Array" + ParameterTypeBoolean ParameterType = "Boolean" + ParameterTypeDateTime ParameterType = "DateTime" + ParameterTypeFloat ParameterType = "Float" + ParameterTypeInteger ParameterType = "Integer" + ParameterTypeObject ParameterType = "Object" + ParameterTypeString ParameterType = "String" +) + +func PossibleValuesForParameterType() []string { + return []string{ + string(ParameterTypeArray), + string(ParameterTypeBoolean), + string(ParameterTypeDateTime), + string(ParameterTypeFloat), + string(ParameterTypeInteger), + string(ParameterTypeObject), + string(ParameterTypeString), + } +} + +func (s *ParameterType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseParameterType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseParameterType(input string) (*ParameterType, error) { + vals := map[string]ParameterType{ + "array": ParameterTypeArray, + "boolean": ParameterTypeBoolean, + "datetime": ParameterTypeDateTime, + "float": ParameterTypeFloat, + "integer": ParameterTypeInteger, + "object": ParameterTypeObject, + "string": ParameterTypeString, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ParameterType(input) + return &out, nil +} + +type PolicyType string + +const ( + PolicyTypeBuiltIn PolicyType = "BuiltIn" + PolicyTypeCustom PolicyType = "Custom" + PolicyTypeNotSpecified PolicyType = "NotSpecified" + PolicyTypeStatic PolicyType = "Static" +) + +func PossibleValuesForPolicyType() []string { + return []string{ + string(PolicyTypeBuiltIn), + string(PolicyTypeCustom), + string(PolicyTypeNotSpecified), + string(PolicyTypeStatic), + } +} + +func (s *PolicyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePolicyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePolicyType(input string) (*PolicyType, error) { + vals := map[string]PolicyType{ + "builtin": PolicyTypeBuiltIn, + "custom": PolicyTypeCustom, + "notspecified": PolicyTypeNotSpecified, + "static": PolicyTypeStatic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PolicyType(input) + return &out, nil +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitions/id_policysetdefinition.go b/resource-manager/resources/2025-03-01/policysetdefinitions/id_policysetdefinition.go new file mode 100644 index 00000000000..c008bd1d9b8 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitions/id_policysetdefinition.go @@ -0,0 +1,112 @@ +package policysetdefinitions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PolicySetDefinitionId{}) +} + +var _ resourceids.ResourceId = &PolicySetDefinitionId{} + +// PolicySetDefinitionId is a struct representing the Resource ID for a Policy Set Definition +type PolicySetDefinitionId struct { + PolicySetDefinitionName string +} + +// NewPolicySetDefinitionID returns a new PolicySetDefinitionId struct +func NewPolicySetDefinitionID(policySetDefinitionName string) PolicySetDefinitionId { + return PolicySetDefinitionId{ + PolicySetDefinitionName: policySetDefinitionName, + } +} + +// ParsePolicySetDefinitionID parses 'input' into a PolicySetDefinitionId +func ParsePolicySetDefinitionID(input string) (*PolicySetDefinitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PolicySetDefinitionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PolicySetDefinitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePolicySetDefinitionIDInsensitively parses 'input' case-insensitively into a PolicySetDefinitionId +// note: this method should only be used for API response data and not user input +func ParsePolicySetDefinitionIDInsensitively(input string) (*PolicySetDefinitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PolicySetDefinitionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PolicySetDefinitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PolicySetDefinitionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.PolicySetDefinitionName, ok = input.Parsed["policySetDefinitionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "policySetDefinitionName", input) + } + + return nil +} + +// ValidatePolicySetDefinitionID checks that 'input' can be parsed as a Policy Set Definition ID +func ValidatePolicySetDefinitionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParsePolicySetDefinitionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Policy Set Definition ID +func (id PolicySetDefinitionId) ID() string { + fmtString := "/providers/Microsoft.Authorization/policySetDefinitions/%s" + return fmt.Sprintf(fmtString, id.PolicySetDefinitionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Policy Set Definition ID +func (id PolicySetDefinitionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftAuthorization", "Microsoft.Authorization", "Microsoft.Authorization"), + resourceids.StaticSegment("staticPolicySetDefinitions", "policySetDefinitions", "policySetDefinitions"), + resourceids.UserSpecifiedSegment("policySetDefinitionName", "policySetDefinitionName"), + } +} + +// String returns a human-readable description of this Policy Set Definition ID +func (id PolicySetDefinitionId) String() string { + components := []string{ + fmt.Sprintf("Policy Set Definition Name: %q", id.PolicySetDefinitionName), + } + return fmt.Sprintf("Policy Set Definition (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitions/id_policysetdefinition_test.go b/resource-manager/resources/2025-03-01/policysetdefinitions/id_policysetdefinition_test.go new file mode 100644 index 00000000000..7cd1142ea4f --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitions/id_policysetdefinition_test.go @@ -0,0 +1,192 @@ +package policysetdefinitions + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PolicySetDefinitionId{} + +func TestNewPolicySetDefinitionID(t *testing.T) { + id := NewPolicySetDefinitionID("policySetDefinitionName") + + if id.PolicySetDefinitionName != "policySetDefinitionName" { + t.Fatalf("Expected %q but got %q for Segment 'PolicySetDefinitionName'", id.PolicySetDefinitionName, "policySetDefinitionName") + } +} + +func TestFormatPolicySetDefinitionID(t *testing.T) { + actual := NewPolicySetDefinitionID("policySetDefinitionName").ID() + expected := "/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePolicySetDefinitionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PolicySetDefinitionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Authorization/policySetDefinitions", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName", + Expected: &PolicySetDefinitionId{ + PolicySetDefinitionName: "policySetDefinitionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePolicySetDefinitionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.PolicySetDefinitionName != v.Expected.PolicySetDefinitionName { + t.Fatalf("Expected %q but got %q for PolicySetDefinitionName", v.Expected.PolicySetDefinitionName, actual.PolicySetDefinitionName) + } + + } +} + +func TestParsePolicySetDefinitionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PolicySetDefinitionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Authorization/policySetDefinitions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYsEtDeFiNiTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName", + Expected: &PolicySetDefinitionId{ + PolicySetDefinitionName: "policySetDefinitionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYsEtDeFiNiTiOnS/pOlIcYsEtDeFiNiTiOnNaMe", + Expected: &PolicySetDefinitionId{ + PolicySetDefinitionName: "pOlIcYsEtDeFiNiTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYsEtDeFiNiTiOnS/pOlIcYsEtDeFiNiTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePolicySetDefinitionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.PolicySetDefinitionName != v.Expected.PolicySetDefinitionName { + t.Fatalf("Expected %q but got %q for PolicySetDefinitionName", v.Expected.PolicySetDefinitionName, actual.PolicySetDefinitionName) + } + + } +} + +func TestSegmentsForPolicySetDefinitionId(t *testing.T) { + segments := PolicySetDefinitionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PolicySetDefinitionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitions/id_providerpolicysetdefinition.go b/resource-manager/resources/2025-03-01/policysetdefinitions/id_providerpolicysetdefinition.go new file mode 100644 index 00000000000..e3d73af1632 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitions/id_providerpolicysetdefinition.go @@ -0,0 +1,121 @@ +package policysetdefinitions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ProviderPolicySetDefinitionId{}) +} + +var _ resourceids.ResourceId = &ProviderPolicySetDefinitionId{} + +// ProviderPolicySetDefinitionId is a struct representing the Resource ID for a Provider Policy Set Definition +type ProviderPolicySetDefinitionId struct { + SubscriptionId string + PolicySetDefinitionName string +} + +// NewProviderPolicySetDefinitionID returns a new ProviderPolicySetDefinitionId struct +func NewProviderPolicySetDefinitionID(subscriptionId string, policySetDefinitionName string) ProviderPolicySetDefinitionId { + return ProviderPolicySetDefinitionId{ + SubscriptionId: subscriptionId, + PolicySetDefinitionName: policySetDefinitionName, + } +} + +// ParseProviderPolicySetDefinitionID parses 'input' into a ProviderPolicySetDefinitionId +func ParseProviderPolicySetDefinitionID(input string) (*ProviderPolicySetDefinitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderPolicySetDefinitionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderPolicySetDefinitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProviderPolicySetDefinitionIDInsensitively parses 'input' case-insensitively into a ProviderPolicySetDefinitionId +// note: this method should only be used for API response data and not user input +func ParseProviderPolicySetDefinitionIDInsensitively(input string) (*ProviderPolicySetDefinitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderPolicySetDefinitionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderPolicySetDefinitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProviderPolicySetDefinitionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.PolicySetDefinitionName, ok = input.Parsed["policySetDefinitionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "policySetDefinitionName", input) + } + + return nil +} + +// ValidateProviderPolicySetDefinitionID checks that 'input' can be parsed as a Provider Policy Set Definition ID +func ValidateProviderPolicySetDefinitionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseProviderPolicySetDefinitionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Provider Policy Set Definition ID +func (id ProviderPolicySetDefinitionId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Authorization/policySetDefinitions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.PolicySetDefinitionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Provider Policy Set Definition ID +func (id ProviderPolicySetDefinitionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftAuthorization", "Microsoft.Authorization", "Microsoft.Authorization"), + resourceids.StaticSegment("staticPolicySetDefinitions", "policySetDefinitions", "policySetDefinitions"), + resourceids.UserSpecifiedSegment("policySetDefinitionName", "policySetDefinitionName"), + } +} + +// String returns a human-readable description of this Provider Policy Set Definition ID +func (id ProviderPolicySetDefinitionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Policy Set Definition Name: %q", id.PolicySetDefinitionName), + } + return fmt.Sprintf("Provider Policy Set Definition (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitions/id_providerpolicysetdefinition_test.go b/resource-manager/resources/2025-03-01/policysetdefinitions/id_providerpolicysetdefinition_test.go new file mode 100644 index 00000000000..bfd6299b83f --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitions/id_providerpolicysetdefinition_test.go @@ -0,0 +1,237 @@ +package policysetdefinitions + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ProviderPolicySetDefinitionId{} + +func TestNewProviderPolicySetDefinitionID(t *testing.T) { + id := NewProviderPolicySetDefinitionID("12345678-1234-9876-4563-123456789012", "policySetDefinitionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.PolicySetDefinitionName != "policySetDefinitionName" { + t.Fatalf("Expected %q but got %q for Segment 'PolicySetDefinitionName'", id.PolicySetDefinitionName, "policySetDefinitionName") + } +} + +func TestFormatProviderPolicySetDefinitionID(t *testing.T) { + actual := NewProviderPolicySetDefinitionID("12345678-1234-9876-4563-123456789012", "policySetDefinitionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProviderPolicySetDefinitionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderPolicySetDefinitionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName", + Expected: &ProviderPolicySetDefinitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicySetDefinitionName: "policySetDefinitionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderPolicySetDefinitionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.PolicySetDefinitionName != v.Expected.PolicySetDefinitionName { + t.Fatalf("Expected %q but got %q for PolicySetDefinitionName", v.Expected.PolicySetDefinitionName, actual.PolicySetDefinitionName) + } + + } +} + +func TestParseProviderPolicySetDefinitionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderPolicySetDefinitionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYsEtDeFiNiTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName", + Expected: &ProviderPolicySetDefinitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicySetDefinitionName: "policySetDefinitionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYsEtDeFiNiTiOnS/pOlIcYsEtDeFiNiTiOnNaMe", + Expected: &ProviderPolicySetDefinitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicySetDefinitionName: "pOlIcYsEtDeFiNiTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYsEtDeFiNiTiOnS/pOlIcYsEtDeFiNiTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderPolicySetDefinitionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.PolicySetDefinitionName != v.Expected.PolicySetDefinitionName { + t.Fatalf("Expected %q but got %q for PolicySetDefinitionName", v.Expected.PolicySetDefinitionName, actual.PolicySetDefinitionName) + } + + } +} + +func TestSegmentsForProviderPolicySetDefinitionId(t *testing.T) { + segments := ProviderPolicySetDefinitionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProviderPolicySetDefinitionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitions/id_providers2policysetdefinition.go b/resource-manager/resources/2025-03-01/policysetdefinitions/id_providers2policysetdefinition.go new file mode 100644 index 00000000000..94590907ff7 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitions/id_providers2policysetdefinition.go @@ -0,0 +1,123 @@ +package policysetdefinitions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&Providers2PolicySetDefinitionId{}) +} + +var _ resourceids.ResourceId = &Providers2PolicySetDefinitionId{} + +// Providers2PolicySetDefinitionId is a struct representing the Resource ID for a Providers 2 Policy Set Definition +type Providers2PolicySetDefinitionId struct { + ManagementGroupName string + PolicySetDefinitionName string +} + +// NewProviders2PolicySetDefinitionID returns a new Providers2PolicySetDefinitionId struct +func NewProviders2PolicySetDefinitionID(managementGroupName string, policySetDefinitionName string) Providers2PolicySetDefinitionId { + return Providers2PolicySetDefinitionId{ + ManagementGroupName: managementGroupName, + PolicySetDefinitionName: policySetDefinitionName, + } +} + +// ParseProviders2PolicySetDefinitionID parses 'input' into a Providers2PolicySetDefinitionId +func ParseProviders2PolicySetDefinitionID(input string) (*Providers2PolicySetDefinitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&Providers2PolicySetDefinitionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := Providers2PolicySetDefinitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProviders2PolicySetDefinitionIDInsensitively parses 'input' case-insensitively into a Providers2PolicySetDefinitionId +// note: this method should only be used for API response data and not user input +func ParseProviders2PolicySetDefinitionIDInsensitively(input string) (*Providers2PolicySetDefinitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&Providers2PolicySetDefinitionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := Providers2PolicySetDefinitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *Providers2PolicySetDefinitionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.ManagementGroupName, ok = input.Parsed["managementGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managementGroupName", input) + } + + if id.PolicySetDefinitionName, ok = input.Parsed["policySetDefinitionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "policySetDefinitionName", input) + } + + return nil +} + +// ValidateProviders2PolicySetDefinitionID checks that 'input' can be parsed as a Providers 2 Policy Set Definition ID +func ValidateProviders2PolicySetDefinitionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseProviders2PolicySetDefinitionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Providers 2 Policy Set Definition ID +func (id Providers2PolicySetDefinitionId) ID() string { + fmtString := "/providers/Microsoft.Management/managementGroups/%s/providers/Microsoft.Authorization/policySetDefinitions/%s" + return fmt.Sprintf(fmtString, id.ManagementGroupName, id.PolicySetDefinitionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Providers 2 Policy Set Definition ID +func (id Providers2PolicySetDefinitionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftManagement", "Microsoft.Management", "Microsoft.Management"), + resourceids.StaticSegment("staticManagementGroups", "managementGroups", "managementGroups"), + resourceids.UserSpecifiedSegment("managementGroupName", "managementGroupName"), + resourceids.StaticSegment("staticProviders2", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftAuthorization", "Microsoft.Authorization", "Microsoft.Authorization"), + resourceids.StaticSegment("staticPolicySetDefinitions", "policySetDefinitions", "policySetDefinitions"), + resourceids.UserSpecifiedSegment("policySetDefinitionName", "policySetDefinitionName"), + } +} + +// String returns a human-readable description of this Providers 2 Policy Set Definition ID +func (id Providers2PolicySetDefinitionId) String() string { + components := []string{ + fmt.Sprintf("Management Group Name: %q", id.ManagementGroupName), + fmt.Sprintf("Policy Set Definition Name: %q", id.PolicySetDefinitionName), + } + return fmt.Sprintf("Providers 2 Policy Set Definition (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitions/id_providers2policysetdefinition_test.go b/resource-manager/resources/2025-03-01/policysetdefinitions/id_providers2policysetdefinition_test.go new file mode 100644 index 00000000000..8a2c11c0a60 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitions/id_providers2policysetdefinition_test.go @@ -0,0 +1,267 @@ +package policysetdefinitions + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &Providers2PolicySetDefinitionId{} + +func TestNewProviders2PolicySetDefinitionID(t *testing.T) { + id := NewProviders2PolicySetDefinitionID("managementGroupName", "policySetDefinitionName") + + if id.ManagementGroupName != "managementGroupName" { + t.Fatalf("Expected %q but got %q for Segment 'ManagementGroupName'", id.ManagementGroupName, "managementGroupName") + } + + if id.PolicySetDefinitionName != "policySetDefinitionName" { + t.Fatalf("Expected %q but got %q for Segment 'PolicySetDefinitionName'", id.PolicySetDefinitionName, "policySetDefinitionName") + } +} + +func TestFormatProviders2PolicySetDefinitionID(t *testing.T) { + actual := NewProviders2PolicySetDefinitionID("managementGroupName", "policySetDefinitionName").ID() + expected := "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProviders2PolicySetDefinitionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *Providers2PolicySetDefinitionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policySetDefinitions", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName", + Expected: &Providers2PolicySetDefinitionId{ + ManagementGroupName: "managementGroupName", + PolicySetDefinitionName: "policySetDefinitionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviders2PolicySetDefinitionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.ManagementGroupName != v.Expected.ManagementGroupName { + t.Fatalf("Expected %q but got %q for ManagementGroupName", v.Expected.ManagementGroupName, actual.ManagementGroupName) + } + + if actual.PolicySetDefinitionName != v.Expected.PolicySetDefinitionName { + t.Fatalf("Expected %q but got %q for PolicySetDefinitionName", v.Expected.PolicySetDefinitionName, actual.PolicySetDefinitionName) + } + + } +} + +func TestParseProviders2PolicySetDefinitionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *Providers2PolicySetDefinitionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpNaMe/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpNaMe/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policySetDefinitions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpNaMe/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYsEtDeFiNiTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName", + Expected: &Providers2PolicySetDefinitionId{ + ManagementGroupName: "managementGroupName", + PolicySetDefinitionName: "policySetDefinitionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpNaMe/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYsEtDeFiNiTiOnS/pOlIcYsEtDeFiNiTiOnNaMe", + Expected: &Providers2PolicySetDefinitionId{ + ManagementGroupName: "mAnAgEmEnTgRoUpNaMe", + PolicySetDefinitionName: "pOlIcYsEtDeFiNiTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpNaMe/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYsEtDeFiNiTiOnS/pOlIcYsEtDeFiNiTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviders2PolicySetDefinitionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.ManagementGroupName != v.Expected.ManagementGroupName { + t.Fatalf("Expected %q but got %q for ManagementGroupName", v.Expected.ManagementGroupName, actual.ManagementGroupName) + } + + if actual.PolicySetDefinitionName != v.Expected.PolicySetDefinitionName { + t.Fatalf("Expected %q but got %q for PolicySetDefinitionName", v.Expected.PolicySetDefinitionName, actual.PolicySetDefinitionName) + } + + } +} + +func TestSegmentsForProviders2PolicySetDefinitionId(t *testing.T) { + segments := Providers2PolicySetDefinitionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("Providers2PolicySetDefinitionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/logz/2020-10-01/tagrules/method_subaccounttagrulescreateorupdate.go b/resource-manager/resources/2025-03-01/policysetdefinitions/method_createorupdate.go similarity index 71% rename from resource-manager/logz/2020-10-01/tagrules/method_subaccounttagrulescreateorupdate.go rename to resource-manager/resources/2025-03-01/policysetdefinitions/method_createorupdate.go index 3de8ad32941..7a7aae2ce33 100644 --- a/resource-manager/logz/2020-10-01/tagrules/method_subaccounttagrulescreateorupdate.go +++ b/resource-manager/resources/2025-03-01/policysetdefinitions/method_createorupdate.go @@ -1,4 +1,4 @@ -package tagrules +package policysetdefinitions import ( "context" @@ -11,17 +11,18 @@ import ( // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. -type SubAccountTagRulesCreateOrUpdateOperationResponse struct { +type CreateOrUpdateOperationResponse struct { HttpResponse *http.Response OData *odata.OData - Model *MonitoringTagRules + Model *PolicySetDefinition } -// SubAccountTagRulesCreateOrUpdate ... -func (c TagRulesClient) SubAccountTagRulesCreateOrUpdate(ctx context.Context, id AccountTagRuleId, input MonitoringTagRules) (result SubAccountTagRulesCreateOrUpdateOperationResponse, err error) { +// CreateOrUpdate ... +func (c PolicySetDefinitionsClient) CreateOrUpdate(ctx context.Context, id ProviderPolicySetDefinitionId, input PolicySetDefinition) (result CreateOrUpdateOperationResponse, err error) { opts := client.RequestOptions{ ContentType: "application/json; charset=utf-8", ExpectedStatusCodes: []int{ + http.StatusCreated, http.StatusOK, }, HttpMethod: http.MethodPut, @@ -47,7 +48,7 @@ func (c TagRulesClient) SubAccountTagRulesCreateOrUpdate(ctx context.Context, id return } - var model MonitoringTagRules + var model PolicySetDefinition result.Model = &model if err = resp.Unmarshal(result.Model); err != nil { return diff --git a/resource-manager/resources/2025-03-01/policysetdefinitions/method_createorupdateatmanagementgroup.go b/resource-manager/resources/2025-03-01/policysetdefinitions/method_createorupdateatmanagementgroup.go new file mode 100644 index 00000000000..0ab2ef4c3cd --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitions/method_createorupdateatmanagementgroup.go @@ -0,0 +1,58 @@ +package policysetdefinitions + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateAtManagementGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicySetDefinition +} + +// CreateOrUpdateAtManagementGroup ... +func (c PolicySetDefinitionsClient) CreateOrUpdateAtManagementGroup(ctx context.Context, id Providers2PolicySetDefinitionId, input PolicySetDefinition) (result CreateOrUpdateAtManagementGroupOperationResponse, 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 PolicySetDefinition + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitions/method_delete.go b/resource-manager/resources/2025-03-01/policysetdefinitions/method_delete.go new file mode 100644 index 00000000000..a78d69723cf --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitions/method_delete.go @@ -0,0 +1,47 @@ +package policysetdefinitions + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 PolicySetDefinitionsClient) Delete(ctx context.Context, id ProviderPolicySetDefinitionId) (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/resources/2025-03-01/policysetdefinitions/method_deleteatmanagementgroup.go b/resource-manager/resources/2025-03-01/policysetdefinitions/method_deleteatmanagementgroup.go new file mode 100644 index 00000000000..34af6ab987d --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitions/method_deleteatmanagementgroup.go @@ -0,0 +1,47 @@ +package policysetdefinitions + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteAtManagementGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteAtManagementGroup ... +func (c PolicySetDefinitionsClient) DeleteAtManagementGroup(ctx context.Context, id Providers2PolicySetDefinitionId) (result DeleteAtManagementGroupOperationResponse, 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/resources/2025-03-01/policysetdefinitions/method_get.go b/resource-manager/resources/2025-03-01/policysetdefinitions/method_get.go new file mode 100644 index 00000000000..ed0b37459b6 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitions/method_get.go @@ -0,0 +1,83 @@ +package policysetdefinitions + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *PolicySetDefinition +} + +type GetOperationOptions struct { + Expand *string +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + return &out +} + +// Get ... +func (c PolicySetDefinitionsClient) Get(ctx context.Context, id ProviderPolicySetDefinitionId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 + } + + var model PolicySetDefinition + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitions/method_getatmanagementgroup.go b/resource-manager/resources/2025-03-01/policysetdefinitions/method_getatmanagementgroup.go new file mode 100644 index 00000000000..701bb015544 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitions/method_getatmanagementgroup.go @@ -0,0 +1,83 @@ +package policysetdefinitions + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetAtManagementGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicySetDefinition +} + +type GetAtManagementGroupOperationOptions struct { + Expand *string +} + +func DefaultGetAtManagementGroupOperationOptions() GetAtManagementGroupOperationOptions { + return GetAtManagementGroupOperationOptions{} +} + +func (o GetAtManagementGroupOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetAtManagementGroupOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetAtManagementGroupOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + return &out +} + +// GetAtManagementGroup ... +func (c PolicySetDefinitionsClient) GetAtManagementGroup(ctx context.Context, id Providers2PolicySetDefinitionId, options GetAtManagementGroupOperationOptions) (result GetAtManagementGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 + } + + var model PolicySetDefinition + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitions/method_getbuiltin.go b/resource-manager/resources/2025-03-01/policysetdefinitions/method_getbuiltin.go new file mode 100644 index 00000000000..ccbcce8d40c --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitions/method_getbuiltin.go @@ -0,0 +1,83 @@ +package policysetdefinitions + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetBuiltInOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicySetDefinition +} + +type GetBuiltInOperationOptions struct { + Expand *string +} + +func DefaultGetBuiltInOperationOptions() GetBuiltInOperationOptions { + return GetBuiltInOperationOptions{} +} + +func (o GetBuiltInOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetBuiltInOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetBuiltInOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + return &out +} + +// GetBuiltIn ... +func (c PolicySetDefinitionsClient) GetBuiltIn(ctx context.Context, id PolicySetDefinitionId, options GetBuiltInOperationOptions) (result GetBuiltInOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 + } + + var model PolicySetDefinition + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitions/method_list.go b/resource-manager/resources/2025-03-01/policysetdefinitions/method_list.go new file mode 100644 index 00000000000..dab6e2833fe --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitions/method_list.go @@ -0,0 +1,143 @@ +package policysetdefinitions + +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 *[]PolicySetDefinition +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []PolicySetDefinition +} + +type ListOperationOptions struct { + Expand *string + Filter *string + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +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 PolicySetDefinitionsClient) 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.Authorization/policySetDefinitions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PolicySetDefinition `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 PolicySetDefinitionsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, PolicySetDefinitionOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PolicySetDefinitionsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions, predicate PolicySetDefinitionOperationPredicate) (result ListCompleteResult, err error) { + items := make([]PolicySetDefinition, 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/resources/2025-03-01/policysetdefinitions/method_listbuiltin.go b/resource-manager/resources/2025-03-01/policysetdefinitions/method_listbuiltin.go new file mode 100644 index 00000000000..f8981ad74d8 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitions/method_listbuiltin.go @@ -0,0 +1,142 @@ +package policysetdefinitions + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListBuiltInOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PolicySetDefinition +} + +type ListBuiltInCompleteResult struct { + LatestHttpResponse *http.Response + Items []PolicySetDefinition +} + +type ListBuiltInOperationOptions struct { + Expand *string + Filter *string + Top *int64 +} + +func DefaultListBuiltInOperationOptions() ListBuiltInOperationOptions { + return ListBuiltInOperationOptions{} +} + +func (o ListBuiltInOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListBuiltInOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListBuiltInOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListBuiltInCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBuiltInCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBuiltIn ... +func (c PolicySetDefinitionsClient) ListBuiltIn(ctx context.Context, options ListBuiltInOperationOptions) (result ListBuiltInOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListBuiltInCustomPager{}, + Path: "/providers/Microsoft.Authorization/policySetDefinitions", + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PolicySetDefinition `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBuiltInComplete retrieves all the results into a single object +func (c PolicySetDefinitionsClient) ListBuiltInComplete(ctx context.Context, options ListBuiltInOperationOptions) (ListBuiltInCompleteResult, error) { + return c.ListBuiltInCompleteMatchingPredicate(ctx, options, PolicySetDefinitionOperationPredicate{}) +} + +// ListBuiltInCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PolicySetDefinitionsClient) ListBuiltInCompleteMatchingPredicate(ctx context.Context, options ListBuiltInOperationOptions, predicate PolicySetDefinitionOperationPredicate) (result ListBuiltInCompleteResult, err error) { + items := make([]PolicySetDefinition, 0) + + resp, err := c.ListBuiltIn(ctx, 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 = ListBuiltInCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitions/method_listbymanagementgroup.go b/resource-manager/resources/2025-03-01/policysetdefinitions/method_listbymanagementgroup.go new file mode 100644 index 00000000000..7f4fdc28775 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitions/method_listbymanagementgroup.go @@ -0,0 +1,143 @@ +package policysetdefinitions + +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 ListByManagementGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PolicySetDefinition +} + +type ListByManagementGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []PolicySetDefinition +} + +type ListByManagementGroupOperationOptions struct { + Expand *string + Filter *string + Top *int64 +} + +func DefaultListByManagementGroupOperationOptions() ListByManagementGroupOperationOptions { + return ListByManagementGroupOperationOptions{} +} + +func (o ListByManagementGroupOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByManagementGroupOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListByManagementGroupOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListByManagementGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByManagementGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByManagementGroup ... +func (c PolicySetDefinitionsClient) ListByManagementGroup(ctx context.Context, id commonids.ManagementGroupId, options ListByManagementGroupOperationOptions) (result ListByManagementGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListByManagementGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Authorization/policySetDefinitions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PolicySetDefinition `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByManagementGroupComplete retrieves all the results into a single object +func (c PolicySetDefinitionsClient) ListByManagementGroupComplete(ctx context.Context, id commonids.ManagementGroupId, options ListByManagementGroupOperationOptions) (ListByManagementGroupCompleteResult, error) { + return c.ListByManagementGroupCompleteMatchingPredicate(ctx, id, options, PolicySetDefinitionOperationPredicate{}) +} + +// ListByManagementGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PolicySetDefinitionsClient) ListByManagementGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ManagementGroupId, options ListByManagementGroupOperationOptions, predicate PolicySetDefinitionOperationPredicate) (result ListByManagementGroupCompleteResult, err error) { + items := make([]PolicySetDefinition, 0) + + resp, err := c.ListByManagementGroup(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 = ListByManagementGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitions/model_parameterdefinitionsvalue.go b/resource-manager/resources/2025-03-01/policysetdefinitions/model_parameterdefinitionsvalue.go new file mode 100644 index 00000000000..9bd593d1fab --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitions/model_parameterdefinitionsvalue.go @@ -0,0 +1,12 @@ +package policysetdefinitions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ParameterDefinitionsValue struct { + AllowedValues *[]interface{} `json:"allowedValues,omitempty"` + DefaultValue *interface{} `json:"defaultValue,omitempty"` + Metadata *ParameterDefinitionsValueMetadata `json:"metadata,omitempty"` + Schema *interface{} `json:"schema,omitempty"` + Type *ParameterType `json:"type,omitempty"` +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitions/model_parameterdefinitionsvaluemetadata.go b/resource-manager/resources/2025-03-01/policysetdefinitions/model_parameterdefinitionsvaluemetadata.go new file mode 100644 index 00000000000..4bd9ddeb854 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitions/model_parameterdefinitionsvaluemetadata.go @@ -0,0 +1,11 @@ +package policysetdefinitions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ParameterDefinitionsValueMetadata struct { + AssignPermissions *bool `json:"assignPermissions,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + StrongType *string `json:"strongType,omitempty"` +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitions/model_parametervaluesvalue.go b/resource-manager/resources/2025-03-01/policysetdefinitions/model_parametervaluesvalue.go new file mode 100644 index 00000000000..3499f4fa976 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitions/model_parametervaluesvalue.go @@ -0,0 +1,8 @@ +package policysetdefinitions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ParameterValuesValue struct { + Value *interface{} `json:"value,omitempty"` +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitions/model_policydefinitiongroup.go b/resource-manager/resources/2025-03-01/policysetdefinitions/model_policydefinitiongroup.go new file mode 100644 index 00000000000..a45afc88c25 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitions/model_policydefinitiongroup.go @@ -0,0 +1,12 @@ +package policysetdefinitions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PolicyDefinitionGroup struct { + AdditionalMetadataId *string `json:"additionalMetadataId,omitempty"` + Category *string `json:"category,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + Name string `json:"name"` +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitions/model_policydefinitionreference.go b/resource-manager/resources/2025-03-01/policysetdefinitions/model_policydefinitionreference.go new file mode 100644 index 00000000000..9baa9307de3 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitions/model_policydefinitionreference.go @@ -0,0 +1,14 @@ +package policysetdefinitions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PolicyDefinitionReference struct { + DefinitionVersion *string `json:"definitionVersion,omitempty"` + EffectiveDefinitionVersion *string `json:"effectiveDefinitionVersion,omitempty"` + GroupNames *[]string `json:"groupNames,omitempty"` + LatestDefinitionVersion *string `json:"latestDefinitionVersion,omitempty"` + Parameters *map[string]ParameterValuesValue `json:"parameters,omitempty"` + PolicyDefinitionId string `json:"policyDefinitionId"` + PolicyDefinitionReferenceId *string `json:"policyDefinitionReferenceId,omitempty"` +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitions/model_policysetdefinition.go b/resource-manager/resources/2025-03-01/policysetdefinitions/model_policysetdefinition.go new file mode 100644 index 00000000000..098c74def32 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitions/model_policysetdefinition.go @@ -0,0 +1,16 @@ +package policysetdefinitions + +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 PolicySetDefinition struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PolicySetDefinitionProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitions/model_policysetdefinitionproperties.go b/resource-manager/resources/2025-03-01/policysetdefinitions/model_policysetdefinitionproperties.go new file mode 100644 index 00000000000..dcb15941645 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitions/model_policysetdefinitionproperties.go @@ -0,0 +1,16 @@ +package policysetdefinitions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PolicySetDefinitionProperties struct { + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + Metadata *interface{} `json:"metadata,omitempty"` + Parameters *map[string]ParameterDefinitionsValue `json:"parameters,omitempty"` + PolicyDefinitionGroups *[]PolicyDefinitionGroup `json:"policyDefinitionGroups,omitempty"` + PolicyDefinitions []PolicyDefinitionReference `json:"policyDefinitions"` + PolicyType *PolicyType `json:"policyType,omitempty"` + Version *string `json:"version,omitempty"` + Versions *[]string `json:"versions,omitempty"` +} diff --git a/resource-manager/logz/2020-10-01/singlesignon/predicates.go b/resource-manager/resources/2025-03-01/policysetdefinitions/predicates.go similarity index 72% rename from resource-manager/logz/2020-10-01/singlesignon/predicates.go rename to resource-manager/resources/2025-03-01/policysetdefinitions/predicates.go index 74f004e69f8..5466ffd65ff 100644 --- a/resource-manager/logz/2020-10-01/singlesignon/predicates.go +++ b/resource-manager/resources/2025-03-01/policysetdefinitions/predicates.go @@ -1,15 +1,15 @@ -package singlesignon +package policysetdefinitions // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. -type LogzSingleSignOnResourceOperationPredicate struct { +type PolicySetDefinitionOperationPredicate struct { Id *string Name *string Type *string } -func (p LogzSingleSignOnResourceOperationPredicate) Matches(input LogzSingleSignOnResource) bool { +func (p PolicySetDefinitionOperationPredicate) Matches(input PolicySetDefinition) bool { if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { return false diff --git a/resource-manager/resources/2025-03-01/policysetdefinitions/version.go b/resource-manager/resources/2025-03-01/policysetdefinitions/version.go new file mode 100644 index 00000000000..6f8d66474eb --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitions/version.go @@ -0,0 +1,10 @@ +package policysetdefinitions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-03-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/policysetdefinitions/2025-03-01" +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitionversions/README.md b/resource-manager/resources/2025-03-01/policysetdefinitionversions/README.md new file mode 100644 index 00000000000..eac28807121 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitionversions/README.md @@ -0,0 +1,245 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/resources/2025-03-01/policysetdefinitionversions` Documentation + +The `policysetdefinitionversions` SDK allows for interaction with Azure Resource Manager `resources` (API Version `2025-03-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/resources/2025-03-01/policysetdefinitionversions" +``` + + +### Client Initialization + +```go +client := policysetdefinitionversions.NewPolicySetDefinitionVersionsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PolicySetDefinitionVersionsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := policysetdefinitionversions.NewProviderPolicySetDefinitionVersionID("12345678-1234-9876-4563-123456789012", "policySetDefinitionName", "versionName") + +payload := policysetdefinitionversions.PolicySetDefinitionVersion{ + // ... +} + + +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: `PolicySetDefinitionVersionsClient.CreateOrUpdateAtManagementGroup` + +```go +ctx := context.TODO() +id := policysetdefinitionversions.NewProviders2PolicySetDefinitionVersionID("managementGroupName", "policySetDefinitionName", "versionName") + +payload := policysetdefinitionversions.PolicySetDefinitionVersion{ + // ... +} + + +read, err := client.CreateOrUpdateAtManagementGroup(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PolicySetDefinitionVersionsClient.Delete` + +```go +ctx := context.TODO() +id := policysetdefinitionversions.NewProviderPolicySetDefinitionVersionID("12345678-1234-9876-4563-123456789012", "policySetDefinitionName", "versionName") + +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: `PolicySetDefinitionVersionsClient.DeleteAtManagementGroup` + +```go +ctx := context.TODO() +id := policysetdefinitionversions.NewProviders2PolicySetDefinitionVersionID("managementGroupName", "policySetDefinitionName", "versionName") + +read, err := client.DeleteAtManagementGroup(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PolicySetDefinitionVersionsClient.Get` + +```go +ctx := context.TODO() +id := policysetdefinitionversions.NewProviderPolicySetDefinitionVersionID("12345678-1234-9876-4563-123456789012", "policySetDefinitionName", "versionName") + +read, err := client.Get(ctx, id, policysetdefinitionversions.DefaultGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PolicySetDefinitionVersionsClient.GetAtManagementGroup` + +```go +ctx := context.TODO() +id := policysetdefinitionversions.NewProviders2PolicySetDefinitionVersionID("managementGroupName", "policySetDefinitionName", "versionName") + +read, err := client.GetAtManagementGroup(ctx, id, policysetdefinitionversions.DefaultGetAtManagementGroupOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PolicySetDefinitionVersionsClient.GetBuiltIn` + +```go +ctx := context.TODO() +id := policysetdefinitionversions.NewPolicySetDefinitionVersionID("policySetDefinitionName", "versionName") + +read, err := client.GetBuiltIn(ctx, id, policysetdefinitionversions.DefaultGetBuiltInOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PolicySetDefinitionVersionsClient.List` + +```go +ctx := context.TODO() +id := policysetdefinitionversions.NewProviderPolicySetDefinitionID("12345678-1234-9876-4563-123456789012", "policySetDefinitionName") + +// alternatively `client.List(ctx, id, policysetdefinitionversions.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, policysetdefinitionversions.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PolicySetDefinitionVersionsClient.ListAll` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListAll(ctx, id)` can be used to do batched pagination +items, err := client.ListAllComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PolicySetDefinitionVersionsClient.ListAllAtManagementGroup` + +```go +ctx := context.TODO() +id := commonids.NewManagementGroupID("groupId") + +// alternatively `client.ListAllAtManagementGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListAllAtManagementGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PolicySetDefinitionVersionsClient.ListAllBuiltins` + +```go +ctx := context.TODO() + + +// alternatively `client.ListAllBuiltins(ctx)` can be used to do batched pagination +items, err := client.ListAllBuiltinsComplete(ctx) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PolicySetDefinitionVersionsClient.ListBuiltIn` + +```go +ctx := context.TODO() +id := policysetdefinitionversions.NewPolicySetDefinitionID("policySetDefinitionName") + +// alternatively `client.ListBuiltIn(ctx, id, policysetdefinitionversions.DefaultListBuiltInOperationOptions())` can be used to do batched pagination +items, err := client.ListBuiltInComplete(ctx, id, policysetdefinitionversions.DefaultListBuiltInOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PolicySetDefinitionVersionsClient.ListByManagementGroup` + +```go +ctx := context.TODO() +id := policysetdefinitionversions.NewProviders2PolicySetDefinitionID("managementGroupName", "policySetDefinitionName") + +// alternatively `client.ListByManagementGroup(ctx, id, policysetdefinitionversions.DefaultListByManagementGroupOperationOptions())` can be used to do batched pagination +items, err := client.ListByManagementGroupComplete(ctx, id, policysetdefinitionversions.DefaultListByManagementGroupOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/resources/2025-03-01/policysetdefinitionversions/client.go b/resource-manager/resources/2025-03-01/policysetdefinitionversions/client.go new file mode 100644 index 00000000000..cfad377fb13 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitionversions/client.go @@ -0,0 +1,26 @@ +package policysetdefinitionversions + +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 PolicySetDefinitionVersionsClient struct { + Client *resourcemanager.Client +} + +func NewPolicySetDefinitionVersionsClientWithBaseURI(sdkApi sdkEnv.Api) (*PolicySetDefinitionVersionsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "policysetdefinitionversions", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PolicySetDefinitionVersionsClient: %+v", err) + } + + return &PolicySetDefinitionVersionsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitionversions/constants.go b/resource-manager/resources/2025-03-01/policysetdefinitionversions/constants.go new file mode 100644 index 00000000000..ff930f4626c --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitionversions/constants.go @@ -0,0 +1,113 @@ +package policysetdefinitionversions + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ParameterType string + +const ( + ParameterTypeArray ParameterType = "Array" + ParameterTypeBoolean ParameterType = "Boolean" + ParameterTypeDateTime ParameterType = "DateTime" + ParameterTypeFloat ParameterType = "Float" + ParameterTypeInteger ParameterType = "Integer" + ParameterTypeObject ParameterType = "Object" + ParameterTypeString ParameterType = "String" +) + +func PossibleValuesForParameterType() []string { + return []string{ + string(ParameterTypeArray), + string(ParameterTypeBoolean), + string(ParameterTypeDateTime), + string(ParameterTypeFloat), + string(ParameterTypeInteger), + string(ParameterTypeObject), + string(ParameterTypeString), + } +} + +func (s *ParameterType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseParameterType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseParameterType(input string) (*ParameterType, error) { + vals := map[string]ParameterType{ + "array": ParameterTypeArray, + "boolean": ParameterTypeBoolean, + "datetime": ParameterTypeDateTime, + "float": ParameterTypeFloat, + "integer": ParameterTypeInteger, + "object": ParameterTypeObject, + "string": ParameterTypeString, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ParameterType(input) + return &out, nil +} + +type PolicyType string + +const ( + PolicyTypeBuiltIn PolicyType = "BuiltIn" + PolicyTypeCustom PolicyType = "Custom" + PolicyTypeNotSpecified PolicyType = "NotSpecified" + PolicyTypeStatic PolicyType = "Static" +) + +func PossibleValuesForPolicyType() []string { + return []string{ + string(PolicyTypeBuiltIn), + string(PolicyTypeCustom), + string(PolicyTypeNotSpecified), + string(PolicyTypeStatic), + } +} + +func (s *PolicyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePolicyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePolicyType(input string) (*PolicyType, error) { + vals := map[string]PolicyType{ + "builtin": PolicyTypeBuiltIn, + "custom": PolicyTypeCustom, + "notspecified": PolicyTypeNotSpecified, + "static": PolicyTypeStatic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PolicyType(input) + return &out, nil +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitionversions/id_policysetdefinition.go b/resource-manager/resources/2025-03-01/policysetdefinitionversions/id_policysetdefinition.go new file mode 100644 index 00000000000..2da8302392e --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitionversions/id_policysetdefinition.go @@ -0,0 +1,112 @@ +package policysetdefinitionversions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PolicySetDefinitionId{}) +} + +var _ resourceids.ResourceId = &PolicySetDefinitionId{} + +// PolicySetDefinitionId is a struct representing the Resource ID for a Policy Set Definition +type PolicySetDefinitionId struct { + PolicySetDefinitionName string +} + +// NewPolicySetDefinitionID returns a new PolicySetDefinitionId struct +func NewPolicySetDefinitionID(policySetDefinitionName string) PolicySetDefinitionId { + return PolicySetDefinitionId{ + PolicySetDefinitionName: policySetDefinitionName, + } +} + +// ParsePolicySetDefinitionID parses 'input' into a PolicySetDefinitionId +func ParsePolicySetDefinitionID(input string) (*PolicySetDefinitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PolicySetDefinitionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PolicySetDefinitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePolicySetDefinitionIDInsensitively parses 'input' case-insensitively into a PolicySetDefinitionId +// note: this method should only be used for API response data and not user input +func ParsePolicySetDefinitionIDInsensitively(input string) (*PolicySetDefinitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PolicySetDefinitionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PolicySetDefinitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PolicySetDefinitionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.PolicySetDefinitionName, ok = input.Parsed["policySetDefinitionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "policySetDefinitionName", input) + } + + return nil +} + +// ValidatePolicySetDefinitionID checks that 'input' can be parsed as a Policy Set Definition ID +func ValidatePolicySetDefinitionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParsePolicySetDefinitionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Policy Set Definition ID +func (id PolicySetDefinitionId) ID() string { + fmtString := "/providers/Microsoft.Authorization/policySetDefinitions/%s" + return fmt.Sprintf(fmtString, id.PolicySetDefinitionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Policy Set Definition ID +func (id PolicySetDefinitionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftAuthorization", "Microsoft.Authorization", "Microsoft.Authorization"), + resourceids.StaticSegment("staticPolicySetDefinitions", "policySetDefinitions", "policySetDefinitions"), + resourceids.UserSpecifiedSegment("policySetDefinitionName", "policySetDefinitionName"), + } +} + +// String returns a human-readable description of this Policy Set Definition ID +func (id PolicySetDefinitionId) String() string { + components := []string{ + fmt.Sprintf("Policy Set Definition Name: %q", id.PolicySetDefinitionName), + } + return fmt.Sprintf("Policy Set Definition (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitionversions/id_policysetdefinition_test.go b/resource-manager/resources/2025-03-01/policysetdefinitionversions/id_policysetdefinition_test.go new file mode 100644 index 00000000000..cc0149a0a57 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitionversions/id_policysetdefinition_test.go @@ -0,0 +1,192 @@ +package policysetdefinitionversions + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PolicySetDefinitionId{} + +func TestNewPolicySetDefinitionID(t *testing.T) { + id := NewPolicySetDefinitionID("policySetDefinitionName") + + if id.PolicySetDefinitionName != "policySetDefinitionName" { + t.Fatalf("Expected %q but got %q for Segment 'PolicySetDefinitionName'", id.PolicySetDefinitionName, "policySetDefinitionName") + } +} + +func TestFormatPolicySetDefinitionID(t *testing.T) { + actual := NewPolicySetDefinitionID("policySetDefinitionName").ID() + expected := "/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePolicySetDefinitionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PolicySetDefinitionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Authorization/policySetDefinitions", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName", + Expected: &PolicySetDefinitionId{ + PolicySetDefinitionName: "policySetDefinitionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePolicySetDefinitionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.PolicySetDefinitionName != v.Expected.PolicySetDefinitionName { + t.Fatalf("Expected %q but got %q for PolicySetDefinitionName", v.Expected.PolicySetDefinitionName, actual.PolicySetDefinitionName) + } + + } +} + +func TestParsePolicySetDefinitionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PolicySetDefinitionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Authorization/policySetDefinitions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYsEtDeFiNiTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName", + Expected: &PolicySetDefinitionId{ + PolicySetDefinitionName: "policySetDefinitionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYsEtDeFiNiTiOnS/pOlIcYsEtDeFiNiTiOnNaMe", + Expected: &PolicySetDefinitionId{ + PolicySetDefinitionName: "pOlIcYsEtDeFiNiTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYsEtDeFiNiTiOnS/pOlIcYsEtDeFiNiTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePolicySetDefinitionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.PolicySetDefinitionName != v.Expected.PolicySetDefinitionName { + t.Fatalf("Expected %q but got %q for PolicySetDefinitionName", v.Expected.PolicySetDefinitionName, actual.PolicySetDefinitionName) + } + + } +} + +func TestSegmentsForPolicySetDefinitionId(t *testing.T) { + segments := PolicySetDefinitionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PolicySetDefinitionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitionversions/id_policysetdefinitionversion.go b/resource-manager/resources/2025-03-01/policysetdefinitionversions/id_policysetdefinitionversion.go new file mode 100644 index 00000000000..021a6afdc9b --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitionversions/id_policysetdefinitionversion.go @@ -0,0 +1,121 @@ +package policysetdefinitionversions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PolicySetDefinitionVersionId{}) +} + +var _ resourceids.ResourceId = &PolicySetDefinitionVersionId{} + +// PolicySetDefinitionVersionId is a struct representing the Resource ID for a Policy Set Definition Version +type PolicySetDefinitionVersionId struct { + PolicySetDefinitionName string + VersionName string +} + +// NewPolicySetDefinitionVersionID returns a new PolicySetDefinitionVersionId struct +func NewPolicySetDefinitionVersionID(policySetDefinitionName string, versionName string) PolicySetDefinitionVersionId { + return PolicySetDefinitionVersionId{ + PolicySetDefinitionName: policySetDefinitionName, + VersionName: versionName, + } +} + +// ParsePolicySetDefinitionVersionID parses 'input' into a PolicySetDefinitionVersionId +func ParsePolicySetDefinitionVersionID(input string) (*PolicySetDefinitionVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PolicySetDefinitionVersionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PolicySetDefinitionVersionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePolicySetDefinitionVersionIDInsensitively parses 'input' case-insensitively into a PolicySetDefinitionVersionId +// note: this method should only be used for API response data and not user input +func ParsePolicySetDefinitionVersionIDInsensitively(input string) (*PolicySetDefinitionVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PolicySetDefinitionVersionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PolicySetDefinitionVersionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PolicySetDefinitionVersionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.PolicySetDefinitionName, ok = input.Parsed["policySetDefinitionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "policySetDefinitionName", input) + } + + if id.VersionName, ok = input.Parsed["versionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "versionName", input) + } + + return nil +} + +// ValidatePolicySetDefinitionVersionID checks that 'input' can be parsed as a Policy Set Definition Version ID +func ValidatePolicySetDefinitionVersionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParsePolicySetDefinitionVersionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Policy Set Definition Version ID +func (id PolicySetDefinitionVersionId) ID() string { + fmtString := "/providers/Microsoft.Authorization/policySetDefinitions/%s/versions/%s" + return fmt.Sprintf(fmtString, id.PolicySetDefinitionName, id.VersionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Policy Set Definition Version ID +func (id PolicySetDefinitionVersionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftAuthorization", "Microsoft.Authorization", "Microsoft.Authorization"), + resourceids.StaticSegment("staticPolicySetDefinitions", "policySetDefinitions", "policySetDefinitions"), + resourceids.UserSpecifiedSegment("policySetDefinitionName", "policySetDefinitionName"), + resourceids.StaticSegment("staticVersions", "versions", "versions"), + resourceids.UserSpecifiedSegment("versionName", "versionName"), + } +} + +// String returns a human-readable description of this Policy Set Definition Version ID +func (id PolicySetDefinitionVersionId) String() string { + components := []string{ + fmt.Sprintf("Policy Set Definition Name: %q", id.PolicySetDefinitionName), + fmt.Sprintf("Version Name: %q", id.VersionName), + } + return fmt.Sprintf("Policy Set Definition Version (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitionversions/id_policysetdefinitionversion_test.go b/resource-manager/resources/2025-03-01/policysetdefinitionversions/id_policysetdefinitionversion_test.go new file mode 100644 index 00000000000..aa3965d5a5c --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitionversions/id_policysetdefinitionversion_test.go @@ -0,0 +1,237 @@ +package policysetdefinitionversions + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PolicySetDefinitionVersionId{} + +func TestNewPolicySetDefinitionVersionID(t *testing.T) { + id := NewPolicySetDefinitionVersionID("policySetDefinitionName", "versionName") + + if id.PolicySetDefinitionName != "policySetDefinitionName" { + t.Fatalf("Expected %q but got %q for Segment 'PolicySetDefinitionName'", id.PolicySetDefinitionName, "policySetDefinitionName") + } + + if id.VersionName != "versionName" { + t.Fatalf("Expected %q but got %q for Segment 'VersionName'", id.VersionName, "versionName") + } +} + +func TestFormatPolicySetDefinitionVersionID(t *testing.T) { + actual := NewPolicySetDefinitionVersionID("policySetDefinitionName", "versionName").ID() + expected := "/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName/versions/versionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePolicySetDefinitionVersionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PolicySetDefinitionVersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Authorization/policySetDefinitions", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName/versions", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName/versions/versionName", + Expected: &PolicySetDefinitionVersionId{ + PolicySetDefinitionName: "policySetDefinitionName", + VersionName: "versionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName/versions/versionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePolicySetDefinitionVersionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.PolicySetDefinitionName != v.Expected.PolicySetDefinitionName { + t.Fatalf("Expected %q but got %q for PolicySetDefinitionName", v.Expected.PolicySetDefinitionName, actual.PolicySetDefinitionName) + } + + if actual.VersionName != v.Expected.VersionName { + t.Fatalf("Expected %q but got %q for VersionName", v.Expected.VersionName, actual.VersionName) + } + + } +} + +func TestParsePolicySetDefinitionVersionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PolicySetDefinitionVersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Authorization/policySetDefinitions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYsEtDeFiNiTiOnS", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYsEtDeFiNiTiOnS/pOlIcYsEtDeFiNiTiOnNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName/versions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYsEtDeFiNiTiOnS/pOlIcYsEtDeFiNiTiOnNaMe/vErSiOnS", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName/versions/versionName", + Expected: &PolicySetDefinitionVersionId{ + PolicySetDefinitionName: "policySetDefinitionName", + VersionName: "versionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName/versions/versionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYsEtDeFiNiTiOnS/pOlIcYsEtDeFiNiTiOnNaMe/vErSiOnS/vErSiOnNaMe", + Expected: &PolicySetDefinitionVersionId{ + PolicySetDefinitionName: "pOlIcYsEtDeFiNiTiOnNaMe", + VersionName: "vErSiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYsEtDeFiNiTiOnS/pOlIcYsEtDeFiNiTiOnNaMe/vErSiOnS/vErSiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePolicySetDefinitionVersionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.PolicySetDefinitionName != v.Expected.PolicySetDefinitionName { + t.Fatalf("Expected %q but got %q for PolicySetDefinitionName", v.Expected.PolicySetDefinitionName, actual.PolicySetDefinitionName) + } + + if actual.VersionName != v.Expected.VersionName { + t.Fatalf("Expected %q but got %q for VersionName", v.Expected.VersionName, actual.VersionName) + } + + } +} + +func TestSegmentsForPolicySetDefinitionVersionId(t *testing.T) { + segments := PolicySetDefinitionVersionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PolicySetDefinitionVersionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitionversions/id_providerpolicysetdefinition.go b/resource-manager/resources/2025-03-01/policysetdefinitionversions/id_providerpolicysetdefinition.go new file mode 100644 index 00000000000..67ed258faf1 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitionversions/id_providerpolicysetdefinition.go @@ -0,0 +1,121 @@ +package policysetdefinitionversions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ProviderPolicySetDefinitionId{}) +} + +var _ resourceids.ResourceId = &ProviderPolicySetDefinitionId{} + +// ProviderPolicySetDefinitionId is a struct representing the Resource ID for a Provider Policy Set Definition +type ProviderPolicySetDefinitionId struct { + SubscriptionId string + PolicySetDefinitionName string +} + +// NewProviderPolicySetDefinitionID returns a new ProviderPolicySetDefinitionId struct +func NewProviderPolicySetDefinitionID(subscriptionId string, policySetDefinitionName string) ProviderPolicySetDefinitionId { + return ProviderPolicySetDefinitionId{ + SubscriptionId: subscriptionId, + PolicySetDefinitionName: policySetDefinitionName, + } +} + +// ParseProviderPolicySetDefinitionID parses 'input' into a ProviderPolicySetDefinitionId +func ParseProviderPolicySetDefinitionID(input string) (*ProviderPolicySetDefinitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderPolicySetDefinitionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderPolicySetDefinitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProviderPolicySetDefinitionIDInsensitively parses 'input' case-insensitively into a ProviderPolicySetDefinitionId +// note: this method should only be used for API response data and not user input +func ParseProviderPolicySetDefinitionIDInsensitively(input string) (*ProviderPolicySetDefinitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderPolicySetDefinitionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderPolicySetDefinitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProviderPolicySetDefinitionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.PolicySetDefinitionName, ok = input.Parsed["policySetDefinitionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "policySetDefinitionName", input) + } + + return nil +} + +// ValidateProviderPolicySetDefinitionID checks that 'input' can be parsed as a Provider Policy Set Definition ID +func ValidateProviderPolicySetDefinitionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseProviderPolicySetDefinitionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Provider Policy Set Definition ID +func (id ProviderPolicySetDefinitionId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Authorization/policySetDefinitions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.PolicySetDefinitionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Provider Policy Set Definition ID +func (id ProviderPolicySetDefinitionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftAuthorization", "Microsoft.Authorization", "Microsoft.Authorization"), + resourceids.StaticSegment("staticPolicySetDefinitions", "policySetDefinitions", "policySetDefinitions"), + resourceids.UserSpecifiedSegment("policySetDefinitionName", "policySetDefinitionName"), + } +} + +// String returns a human-readable description of this Provider Policy Set Definition ID +func (id ProviderPolicySetDefinitionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Policy Set Definition Name: %q", id.PolicySetDefinitionName), + } + return fmt.Sprintf("Provider Policy Set Definition (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitionversions/id_providerpolicysetdefinition_test.go b/resource-manager/resources/2025-03-01/policysetdefinitionversions/id_providerpolicysetdefinition_test.go new file mode 100644 index 00000000000..e3afe4a3e4f --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitionversions/id_providerpolicysetdefinition_test.go @@ -0,0 +1,237 @@ +package policysetdefinitionversions + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ProviderPolicySetDefinitionId{} + +func TestNewProviderPolicySetDefinitionID(t *testing.T) { + id := NewProviderPolicySetDefinitionID("12345678-1234-9876-4563-123456789012", "policySetDefinitionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.PolicySetDefinitionName != "policySetDefinitionName" { + t.Fatalf("Expected %q but got %q for Segment 'PolicySetDefinitionName'", id.PolicySetDefinitionName, "policySetDefinitionName") + } +} + +func TestFormatProviderPolicySetDefinitionID(t *testing.T) { + actual := NewProviderPolicySetDefinitionID("12345678-1234-9876-4563-123456789012", "policySetDefinitionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProviderPolicySetDefinitionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderPolicySetDefinitionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName", + Expected: &ProviderPolicySetDefinitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicySetDefinitionName: "policySetDefinitionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderPolicySetDefinitionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.PolicySetDefinitionName != v.Expected.PolicySetDefinitionName { + t.Fatalf("Expected %q but got %q for PolicySetDefinitionName", v.Expected.PolicySetDefinitionName, actual.PolicySetDefinitionName) + } + + } +} + +func TestParseProviderPolicySetDefinitionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderPolicySetDefinitionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYsEtDeFiNiTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName", + Expected: &ProviderPolicySetDefinitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicySetDefinitionName: "policySetDefinitionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYsEtDeFiNiTiOnS/pOlIcYsEtDeFiNiTiOnNaMe", + Expected: &ProviderPolicySetDefinitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicySetDefinitionName: "pOlIcYsEtDeFiNiTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYsEtDeFiNiTiOnS/pOlIcYsEtDeFiNiTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderPolicySetDefinitionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.PolicySetDefinitionName != v.Expected.PolicySetDefinitionName { + t.Fatalf("Expected %q but got %q for PolicySetDefinitionName", v.Expected.PolicySetDefinitionName, actual.PolicySetDefinitionName) + } + + } +} + +func TestSegmentsForProviderPolicySetDefinitionId(t *testing.T) { + segments := ProviderPolicySetDefinitionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProviderPolicySetDefinitionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitionversions/id_providerpolicysetdefinitionversion.go b/resource-manager/resources/2025-03-01/policysetdefinitionversions/id_providerpolicysetdefinitionversion.go new file mode 100644 index 00000000000..5776f4f1216 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitionversions/id_providerpolicysetdefinitionversion.go @@ -0,0 +1,130 @@ +package policysetdefinitionversions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ProviderPolicySetDefinitionVersionId{}) +} + +var _ resourceids.ResourceId = &ProviderPolicySetDefinitionVersionId{} + +// ProviderPolicySetDefinitionVersionId is a struct representing the Resource ID for a Provider Policy Set Definition Version +type ProviderPolicySetDefinitionVersionId struct { + SubscriptionId string + PolicySetDefinitionName string + VersionName string +} + +// NewProviderPolicySetDefinitionVersionID returns a new ProviderPolicySetDefinitionVersionId struct +func NewProviderPolicySetDefinitionVersionID(subscriptionId string, policySetDefinitionName string, versionName string) ProviderPolicySetDefinitionVersionId { + return ProviderPolicySetDefinitionVersionId{ + SubscriptionId: subscriptionId, + PolicySetDefinitionName: policySetDefinitionName, + VersionName: versionName, + } +} + +// ParseProviderPolicySetDefinitionVersionID parses 'input' into a ProviderPolicySetDefinitionVersionId +func ParseProviderPolicySetDefinitionVersionID(input string) (*ProviderPolicySetDefinitionVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderPolicySetDefinitionVersionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderPolicySetDefinitionVersionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProviderPolicySetDefinitionVersionIDInsensitively parses 'input' case-insensitively into a ProviderPolicySetDefinitionVersionId +// note: this method should only be used for API response data and not user input +func ParseProviderPolicySetDefinitionVersionIDInsensitively(input string) (*ProviderPolicySetDefinitionVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderPolicySetDefinitionVersionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderPolicySetDefinitionVersionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProviderPolicySetDefinitionVersionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.PolicySetDefinitionName, ok = input.Parsed["policySetDefinitionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "policySetDefinitionName", input) + } + + if id.VersionName, ok = input.Parsed["versionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "versionName", input) + } + + return nil +} + +// ValidateProviderPolicySetDefinitionVersionID checks that 'input' can be parsed as a Provider Policy Set Definition Version ID +func ValidateProviderPolicySetDefinitionVersionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseProviderPolicySetDefinitionVersionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Provider Policy Set Definition Version ID +func (id ProviderPolicySetDefinitionVersionId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Authorization/policySetDefinitions/%s/versions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.PolicySetDefinitionName, id.VersionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Provider Policy Set Definition Version ID +func (id ProviderPolicySetDefinitionVersionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftAuthorization", "Microsoft.Authorization", "Microsoft.Authorization"), + resourceids.StaticSegment("staticPolicySetDefinitions", "policySetDefinitions", "policySetDefinitions"), + resourceids.UserSpecifiedSegment("policySetDefinitionName", "policySetDefinitionName"), + resourceids.StaticSegment("staticVersions", "versions", "versions"), + resourceids.UserSpecifiedSegment("versionName", "versionName"), + } +} + +// String returns a human-readable description of this Provider Policy Set Definition Version ID +func (id ProviderPolicySetDefinitionVersionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Policy Set Definition Name: %q", id.PolicySetDefinitionName), + fmt.Sprintf("Version Name: %q", id.VersionName), + } + return fmt.Sprintf("Provider Policy Set Definition Version (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitionversions/id_providerpolicysetdefinitionversion_test.go b/resource-manager/resources/2025-03-01/policysetdefinitionversions/id_providerpolicysetdefinitionversion_test.go new file mode 100644 index 00000000000..3f36204ac89 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitionversions/id_providerpolicysetdefinitionversion_test.go @@ -0,0 +1,282 @@ +package policysetdefinitionversions + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ProviderPolicySetDefinitionVersionId{} + +func TestNewProviderPolicySetDefinitionVersionID(t *testing.T) { + id := NewProviderPolicySetDefinitionVersionID("12345678-1234-9876-4563-123456789012", "policySetDefinitionName", "versionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.PolicySetDefinitionName != "policySetDefinitionName" { + t.Fatalf("Expected %q but got %q for Segment 'PolicySetDefinitionName'", id.PolicySetDefinitionName, "policySetDefinitionName") + } + + if id.VersionName != "versionName" { + t.Fatalf("Expected %q but got %q for Segment 'VersionName'", id.VersionName, "versionName") + } +} + +func TestFormatProviderPolicySetDefinitionVersionID(t *testing.T) { + actual := NewProviderPolicySetDefinitionVersionID("12345678-1234-9876-4563-123456789012", "policySetDefinitionName", "versionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName/versions/versionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProviderPolicySetDefinitionVersionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderPolicySetDefinitionVersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName/versions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName/versions/versionName", + Expected: &ProviderPolicySetDefinitionVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicySetDefinitionName: "policySetDefinitionName", + VersionName: "versionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName/versions/versionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderPolicySetDefinitionVersionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.PolicySetDefinitionName != v.Expected.PolicySetDefinitionName { + t.Fatalf("Expected %q but got %q for PolicySetDefinitionName", v.Expected.PolicySetDefinitionName, actual.PolicySetDefinitionName) + } + + if actual.VersionName != v.Expected.VersionName { + t.Fatalf("Expected %q but got %q for VersionName", v.Expected.VersionName, actual.VersionName) + } + + } +} + +func TestParseProviderPolicySetDefinitionVersionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderPolicySetDefinitionVersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYsEtDeFiNiTiOnS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYsEtDeFiNiTiOnS/pOlIcYsEtDeFiNiTiOnNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName/versions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYsEtDeFiNiTiOnS/pOlIcYsEtDeFiNiTiOnNaMe/vErSiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName/versions/versionName", + Expected: &ProviderPolicySetDefinitionVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicySetDefinitionName: "policySetDefinitionName", + VersionName: "versionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName/versions/versionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYsEtDeFiNiTiOnS/pOlIcYsEtDeFiNiTiOnNaMe/vErSiOnS/vErSiOnNaMe", + Expected: &ProviderPolicySetDefinitionVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicySetDefinitionName: "pOlIcYsEtDeFiNiTiOnNaMe", + VersionName: "vErSiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYsEtDeFiNiTiOnS/pOlIcYsEtDeFiNiTiOnNaMe/vErSiOnS/vErSiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderPolicySetDefinitionVersionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.PolicySetDefinitionName != v.Expected.PolicySetDefinitionName { + t.Fatalf("Expected %q but got %q for PolicySetDefinitionName", v.Expected.PolicySetDefinitionName, actual.PolicySetDefinitionName) + } + + if actual.VersionName != v.Expected.VersionName { + t.Fatalf("Expected %q but got %q for VersionName", v.Expected.VersionName, actual.VersionName) + } + + } +} + +func TestSegmentsForProviderPolicySetDefinitionVersionId(t *testing.T) { + segments := ProviderPolicySetDefinitionVersionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProviderPolicySetDefinitionVersionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitionversions/id_providers2policysetdefinition.go b/resource-manager/resources/2025-03-01/policysetdefinitionversions/id_providers2policysetdefinition.go new file mode 100644 index 00000000000..8d044e651e9 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitionversions/id_providers2policysetdefinition.go @@ -0,0 +1,123 @@ +package policysetdefinitionversions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&Providers2PolicySetDefinitionId{}) +} + +var _ resourceids.ResourceId = &Providers2PolicySetDefinitionId{} + +// Providers2PolicySetDefinitionId is a struct representing the Resource ID for a Providers 2 Policy Set Definition +type Providers2PolicySetDefinitionId struct { + ManagementGroupName string + PolicySetDefinitionName string +} + +// NewProviders2PolicySetDefinitionID returns a new Providers2PolicySetDefinitionId struct +func NewProviders2PolicySetDefinitionID(managementGroupName string, policySetDefinitionName string) Providers2PolicySetDefinitionId { + return Providers2PolicySetDefinitionId{ + ManagementGroupName: managementGroupName, + PolicySetDefinitionName: policySetDefinitionName, + } +} + +// ParseProviders2PolicySetDefinitionID parses 'input' into a Providers2PolicySetDefinitionId +func ParseProviders2PolicySetDefinitionID(input string) (*Providers2PolicySetDefinitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&Providers2PolicySetDefinitionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := Providers2PolicySetDefinitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProviders2PolicySetDefinitionIDInsensitively parses 'input' case-insensitively into a Providers2PolicySetDefinitionId +// note: this method should only be used for API response data and not user input +func ParseProviders2PolicySetDefinitionIDInsensitively(input string) (*Providers2PolicySetDefinitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&Providers2PolicySetDefinitionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := Providers2PolicySetDefinitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *Providers2PolicySetDefinitionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.ManagementGroupName, ok = input.Parsed["managementGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managementGroupName", input) + } + + if id.PolicySetDefinitionName, ok = input.Parsed["policySetDefinitionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "policySetDefinitionName", input) + } + + return nil +} + +// ValidateProviders2PolicySetDefinitionID checks that 'input' can be parsed as a Providers 2 Policy Set Definition ID +func ValidateProviders2PolicySetDefinitionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseProviders2PolicySetDefinitionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Providers 2 Policy Set Definition ID +func (id Providers2PolicySetDefinitionId) ID() string { + fmtString := "/providers/Microsoft.Management/managementGroups/%s/providers/Microsoft.Authorization/policySetDefinitions/%s" + return fmt.Sprintf(fmtString, id.ManagementGroupName, id.PolicySetDefinitionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Providers 2 Policy Set Definition ID +func (id Providers2PolicySetDefinitionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftManagement", "Microsoft.Management", "Microsoft.Management"), + resourceids.StaticSegment("staticManagementGroups", "managementGroups", "managementGroups"), + resourceids.UserSpecifiedSegment("managementGroupName", "managementGroupName"), + resourceids.StaticSegment("staticProviders2", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftAuthorization", "Microsoft.Authorization", "Microsoft.Authorization"), + resourceids.StaticSegment("staticPolicySetDefinitions", "policySetDefinitions", "policySetDefinitions"), + resourceids.UserSpecifiedSegment("policySetDefinitionName", "policySetDefinitionName"), + } +} + +// String returns a human-readable description of this Providers 2 Policy Set Definition ID +func (id Providers2PolicySetDefinitionId) String() string { + components := []string{ + fmt.Sprintf("Management Group Name: %q", id.ManagementGroupName), + fmt.Sprintf("Policy Set Definition Name: %q", id.PolicySetDefinitionName), + } + return fmt.Sprintf("Providers 2 Policy Set Definition (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitionversions/id_providers2policysetdefinition_test.go b/resource-manager/resources/2025-03-01/policysetdefinitionversions/id_providers2policysetdefinition_test.go new file mode 100644 index 00000000000..bdd8f7292f0 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitionversions/id_providers2policysetdefinition_test.go @@ -0,0 +1,267 @@ +package policysetdefinitionversions + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &Providers2PolicySetDefinitionId{} + +func TestNewProviders2PolicySetDefinitionID(t *testing.T) { + id := NewProviders2PolicySetDefinitionID("managementGroupName", "policySetDefinitionName") + + if id.ManagementGroupName != "managementGroupName" { + t.Fatalf("Expected %q but got %q for Segment 'ManagementGroupName'", id.ManagementGroupName, "managementGroupName") + } + + if id.PolicySetDefinitionName != "policySetDefinitionName" { + t.Fatalf("Expected %q but got %q for Segment 'PolicySetDefinitionName'", id.PolicySetDefinitionName, "policySetDefinitionName") + } +} + +func TestFormatProviders2PolicySetDefinitionID(t *testing.T) { + actual := NewProviders2PolicySetDefinitionID("managementGroupName", "policySetDefinitionName").ID() + expected := "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProviders2PolicySetDefinitionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *Providers2PolicySetDefinitionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policySetDefinitions", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName", + Expected: &Providers2PolicySetDefinitionId{ + ManagementGroupName: "managementGroupName", + PolicySetDefinitionName: "policySetDefinitionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviders2PolicySetDefinitionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.ManagementGroupName != v.Expected.ManagementGroupName { + t.Fatalf("Expected %q but got %q for ManagementGroupName", v.Expected.ManagementGroupName, actual.ManagementGroupName) + } + + if actual.PolicySetDefinitionName != v.Expected.PolicySetDefinitionName { + t.Fatalf("Expected %q but got %q for PolicySetDefinitionName", v.Expected.PolicySetDefinitionName, actual.PolicySetDefinitionName) + } + + } +} + +func TestParseProviders2PolicySetDefinitionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *Providers2PolicySetDefinitionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpNaMe/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpNaMe/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policySetDefinitions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpNaMe/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYsEtDeFiNiTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName", + Expected: &Providers2PolicySetDefinitionId{ + ManagementGroupName: "managementGroupName", + PolicySetDefinitionName: "policySetDefinitionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpNaMe/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYsEtDeFiNiTiOnS/pOlIcYsEtDeFiNiTiOnNaMe", + Expected: &Providers2PolicySetDefinitionId{ + ManagementGroupName: "mAnAgEmEnTgRoUpNaMe", + PolicySetDefinitionName: "pOlIcYsEtDeFiNiTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpNaMe/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYsEtDeFiNiTiOnS/pOlIcYsEtDeFiNiTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviders2PolicySetDefinitionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.ManagementGroupName != v.Expected.ManagementGroupName { + t.Fatalf("Expected %q but got %q for ManagementGroupName", v.Expected.ManagementGroupName, actual.ManagementGroupName) + } + + if actual.PolicySetDefinitionName != v.Expected.PolicySetDefinitionName { + t.Fatalf("Expected %q but got %q for PolicySetDefinitionName", v.Expected.PolicySetDefinitionName, actual.PolicySetDefinitionName) + } + + } +} + +func TestSegmentsForProviders2PolicySetDefinitionId(t *testing.T) { + segments := Providers2PolicySetDefinitionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("Providers2PolicySetDefinitionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitionversions/id_providers2policysetdefinitionversion.go b/resource-manager/resources/2025-03-01/policysetdefinitionversions/id_providers2policysetdefinitionversion.go new file mode 100644 index 00000000000..a0e148117cf --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitionversions/id_providers2policysetdefinitionversion.go @@ -0,0 +1,132 @@ +package policysetdefinitionversions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&Providers2PolicySetDefinitionVersionId{}) +} + +var _ resourceids.ResourceId = &Providers2PolicySetDefinitionVersionId{} + +// Providers2PolicySetDefinitionVersionId is a struct representing the Resource ID for a Providers 2 Policy Set Definition Version +type Providers2PolicySetDefinitionVersionId struct { + ManagementGroupName string + PolicySetDefinitionName string + VersionName string +} + +// NewProviders2PolicySetDefinitionVersionID returns a new Providers2PolicySetDefinitionVersionId struct +func NewProviders2PolicySetDefinitionVersionID(managementGroupName string, policySetDefinitionName string, versionName string) Providers2PolicySetDefinitionVersionId { + return Providers2PolicySetDefinitionVersionId{ + ManagementGroupName: managementGroupName, + PolicySetDefinitionName: policySetDefinitionName, + VersionName: versionName, + } +} + +// ParseProviders2PolicySetDefinitionVersionID parses 'input' into a Providers2PolicySetDefinitionVersionId +func ParseProviders2PolicySetDefinitionVersionID(input string) (*Providers2PolicySetDefinitionVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&Providers2PolicySetDefinitionVersionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := Providers2PolicySetDefinitionVersionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProviders2PolicySetDefinitionVersionIDInsensitively parses 'input' case-insensitively into a Providers2PolicySetDefinitionVersionId +// note: this method should only be used for API response data and not user input +func ParseProviders2PolicySetDefinitionVersionIDInsensitively(input string) (*Providers2PolicySetDefinitionVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&Providers2PolicySetDefinitionVersionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := Providers2PolicySetDefinitionVersionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *Providers2PolicySetDefinitionVersionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.ManagementGroupName, ok = input.Parsed["managementGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managementGroupName", input) + } + + if id.PolicySetDefinitionName, ok = input.Parsed["policySetDefinitionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "policySetDefinitionName", input) + } + + if id.VersionName, ok = input.Parsed["versionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "versionName", input) + } + + return nil +} + +// ValidateProviders2PolicySetDefinitionVersionID checks that 'input' can be parsed as a Providers 2 Policy Set Definition Version ID +func ValidateProviders2PolicySetDefinitionVersionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseProviders2PolicySetDefinitionVersionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Providers 2 Policy Set Definition Version ID +func (id Providers2PolicySetDefinitionVersionId) ID() string { + fmtString := "/providers/Microsoft.Management/managementGroups/%s/providers/Microsoft.Authorization/policySetDefinitions/%s/versions/%s" + return fmt.Sprintf(fmtString, id.ManagementGroupName, id.PolicySetDefinitionName, id.VersionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Providers 2 Policy Set Definition Version ID +func (id Providers2PolicySetDefinitionVersionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftManagement", "Microsoft.Management", "Microsoft.Management"), + resourceids.StaticSegment("staticManagementGroups", "managementGroups", "managementGroups"), + resourceids.UserSpecifiedSegment("managementGroupName", "managementGroupName"), + resourceids.StaticSegment("staticProviders2", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftAuthorization", "Microsoft.Authorization", "Microsoft.Authorization"), + resourceids.StaticSegment("staticPolicySetDefinitions", "policySetDefinitions", "policySetDefinitions"), + resourceids.UserSpecifiedSegment("policySetDefinitionName", "policySetDefinitionName"), + resourceids.StaticSegment("staticVersions", "versions", "versions"), + resourceids.UserSpecifiedSegment("versionName", "versionName"), + } +} + +// String returns a human-readable description of this Providers 2 Policy Set Definition Version ID +func (id Providers2PolicySetDefinitionVersionId) String() string { + components := []string{ + fmt.Sprintf("Management Group Name: %q", id.ManagementGroupName), + fmt.Sprintf("Policy Set Definition Name: %q", id.PolicySetDefinitionName), + fmt.Sprintf("Version Name: %q", id.VersionName), + } + return fmt.Sprintf("Providers 2 Policy Set Definition Version (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitionversions/id_providers2policysetdefinitionversion_test.go b/resource-manager/resources/2025-03-01/policysetdefinitionversions/id_providers2policysetdefinitionversion_test.go new file mode 100644 index 00000000000..dbe00c68e33 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitionversions/id_providers2policysetdefinitionversion_test.go @@ -0,0 +1,312 @@ +package policysetdefinitionversions + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &Providers2PolicySetDefinitionVersionId{} + +func TestNewProviders2PolicySetDefinitionVersionID(t *testing.T) { + id := NewProviders2PolicySetDefinitionVersionID("managementGroupName", "policySetDefinitionName", "versionName") + + if id.ManagementGroupName != "managementGroupName" { + t.Fatalf("Expected %q but got %q for Segment 'ManagementGroupName'", id.ManagementGroupName, "managementGroupName") + } + + if id.PolicySetDefinitionName != "policySetDefinitionName" { + t.Fatalf("Expected %q but got %q for Segment 'PolicySetDefinitionName'", id.PolicySetDefinitionName, "policySetDefinitionName") + } + + if id.VersionName != "versionName" { + t.Fatalf("Expected %q but got %q for Segment 'VersionName'", id.VersionName, "versionName") + } +} + +func TestFormatProviders2PolicySetDefinitionVersionID(t *testing.T) { + actual := NewProviders2PolicySetDefinitionVersionID("managementGroupName", "policySetDefinitionName", "versionName").ID() + expected := "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName/versions/versionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProviders2PolicySetDefinitionVersionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *Providers2PolicySetDefinitionVersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policySetDefinitions", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName/versions", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName/versions/versionName", + Expected: &Providers2PolicySetDefinitionVersionId{ + ManagementGroupName: "managementGroupName", + PolicySetDefinitionName: "policySetDefinitionName", + VersionName: "versionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName/versions/versionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviders2PolicySetDefinitionVersionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.ManagementGroupName != v.Expected.ManagementGroupName { + t.Fatalf("Expected %q but got %q for ManagementGroupName", v.Expected.ManagementGroupName, actual.ManagementGroupName) + } + + if actual.PolicySetDefinitionName != v.Expected.PolicySetDefinitionName { + t.Fatalf("Expected %q but got %q for PolicySetDefinitionName", v.Expected.PolicySetDefinitionName, actual.PolicySetDefinitionName) + } + + if actual.VersionName != v.Expected.VersionName { + t.Fatalf("Expected %q but got %q for VersionName", v.Expected.VersionName, actual.VersionName) + } + + } +} + +func TestParseProviders2PolicySetDefinitionVersionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *Providers2PolicySetDefinitionVersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpNaMe/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpNaMe/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policySetDefinitions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpNaMe/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYsEtDeFiNiTiOnS", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpNaMe/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYsEtDeFiNiTiOnS/pOlIcYsEtDeFiNiTiOnNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName/versions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpNaMe/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYsEtDeFiNiTiOnS/pOlIcYsEtDeFiNiTiOnNaMe/vErSiOnS", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName/versions/versionName", + Expected: &Providers2PolicySetDefinitionVersionId{ + ManagementGroupName: "managementGroupName", + PolicySetDefinitionName: "policySetDefinitionName", + VersionName: "versionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName/versions/versionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpNaMe/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYsEtDeFiNiTiOnS/pOlIcYsEtDeFiNiTiOnNaMe/vErSiOnS/vErSiOnNaMe", + Expected: &Providers2PolicySetDefinitionVersionId{ + ManagementGroupName: "mAnAgEmEnTgRoUpNaMe", + PolicySetDefinitionName: "pOlIcYsEtDeFiNiTiOnNaMe", + VersionName: "vErSiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpNaMe/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYsEtDeFiNiTiOnS/pOlIcYsEtDeFiNiTiOnNaMe/vErSiOnS/vErSiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviders2PolicySetDefinitionVersionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.ManagementGroupName != v.Expected.ManagementGroupName { + t.Fatalf("Expected %q but got %q for ManagementGroupName", v.Expected.ManagementGroupName, actual.ManagementGroupName) + } + + if actual.PolicySetDefinitionName != v.Expected.PolicySetDefinitionName { + t.Fatalf("Expected %q but got %q for PolicySetDefinitionName", v.Expected.PolicySetDefinitionName, actual.PolicySetDefinitionName) + } + + if actual.VersionName != v.Expected.VersionName { + t.Fatalf("Expected %q but got %q for VersionName", v.Expected.VersionName, actual.VersionName) + } + + } +} + +func TestSegmentsForProviders2PolicySetDefinitionVersionId(t *testing.T) { + segments := Providers2PolicySetDefinitionVersionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("Providers2PolicySetDefinitionVersionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitionversions/method_createorupdate.go b/resource-manager/resources/2025-03-01/policysetdefinitionversions/method_createorupdate.go new file mode 100644 index 00000000000..25ebdfa4da2 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitionversions/method_createorupdate.go @@ -0,0 +1,58 @@ +package policysetdefinitionversions + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *PolicySetDefinitionVersion +} + +// CreateOrUpdate ... +func (c PolicySetDefinitionVersionsClient) CreateOrUpdate(ctx context.Context, id ProviderPolicySetDefinitionVersionId, input PolicySetDefinitionVersion) (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 PolicySetDefinitionVersion + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitionversions/method_createorupdateatmanagementgroup.go b/resource-manager/resources/2025-03-01/policysetdefinitionversions/method_createorupdateatmanagementgroup.go new file mode 100644 index 00000000000..90c6eee5a29 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitionversions/method_createorupdateatmanagementgroup.go @@ -0,0 +1,58 @@ +package policysetdefinitionversions + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateAtManagementGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicySetDefinitionVersion +} + +// CreateOrUpdateAtManagementGroup ... +func (c PolicySetDefinitionVersionsClient) CreateOrUpdateAtManagementGroup(ctx context.Context, id Providers2PolicySetDefinitionVersionId, input PolicySetDefinitionVersion) (result CreateOrUpdateAtManagementGroupOperationResponse, 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 PolicySetDefinitionVersion + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitionversions/method_delete.go b/resource-manager/resources/2025-03-01/policysetdefinitionversions/method_delete.go new file mode 100644 index 00000000000..3c519248fa6 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitionversions/method_delete.go @@ -0,0 +1,47 @@ +package policysetdefinitionversions + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 PolicySetDefinitionVersionsClient) Delete(ctx context.Context, id ProviderPolicySetDefinitionVersionId) (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/resources/2025-03-01/policysetdefinitionversions/method_deleteatmanagementgroup.go b/resource-manager/resources/2025-03-01/policysetdefinitionversions/method_deleteatmanagementgroup.go new file mode 100644 index 00000000000..b0f0b0a1de4 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitionversions/method_deleteatmanagementgroup.go @@ -0,0 +1,47 @@ +package policysetdefinitionversions + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteAtManagementGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteAtManagementGroup ... +func (c PolicySetDefinitionVersionsClient) DeleteAtManagementGroup(ctx context.Context, id Providers2PolicySetDefinitionVersionId) (result DeleteAtManagementGroupOperationResponse, 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/resources/2025-03-01/policysetdefinitionversions/method_get.go b/resource-manager/resources/2025-03-01/policysetdefinitionversions/method_get.go new file mode 100644 index 00000000000..51781ceece2 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitionversions/method_get.go @@ -0,0 +1,83 @@ +package policysetdefinitionversions + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *PolicySetDefinitionVersion +} + +type GetOperationOptions struct { + Expand *string +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + return &out +} + +// Get ... +func (c PolicySetDefinitionVersionsClient) Get(ctx context.Context, id ProviderPolicySetDefinitionVersionId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 + } + + var model PolicySetDefinitionVersion + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitionversions/method_getatmanagementgroup.go b/resource-manager/resources/2025-03-01/policysetdefinitionversions/method_getatmanagementgroup.go new file mode 100644 index 00000000000..b0aa943a1f7 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitionversions/method_getatmanagementgroup.go @@ -0,0 +1,83 @@ +package policysetdefinitionversions + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetAtManagementGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicySetDefinitionVersion +} + +type GetAtManagementGroupOperationOptions struct { + Expand *string +} + +func DefaultGetAtManagementGroupOperationOptions() GetAtManagementGroupOperationOptions { + return GetAtManagementGroupOperationOptions{} +} + +func (o GetAtManagementGroupOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetAtManagementGroupOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetAtManagementGroupOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + return &out +} + +// GetAtManagementGroup ... +func (c PolicySetDefinitionVersionsClient) GetAtManagementGroup(ctx context.Context, id Providers2PolicySetDefinitionVersionId, options GetAtManagementGroupOperationOptions) (result GetAtManagementGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 + } + + var model PolicySetDefinitionVersion + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitionversions/method_getbuiltin.go b/resource-manager/resources/2025-03-01/policysetdefinitionversions/method_getbuiltin.go new file mode 100644 index 00000000000..12e2159aca3 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitionversions/method_getbuiltin.go @@ -0,0 +1,83 @@ +package policysetdefinitionversions + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetBuiltInOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicySetDefinitionVersion +} + +type GetBuiltInOperationOptions struct { + Expand *string +} + +func DefaultGetBuiltInOperationOptions() GetBuiltInOperationOptions { + return GetBuiltInOperationOptions{} +} + +func (o GetBuiltInOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetBuiltInOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetBuiltInOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + return &out +} + +// GetBuiltIn ... +func (c PolicySetDefinitionVersionsClient) GetBuiltIn(ctx context.Context, id PolicySetDefinitionVersionId, options GetBuiltInOperationOptions) (result GetBuiltInOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 + } + + var model PolicySetDefinitionVersion + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitionversions/method_list.go b/resource-manager/resources/2025-03-01/policysetdefinitionversions/method_list.go new file mode 100644 index 00000000000..06a7741b476 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitionversions/method_list.go @@ -0,0 +1,138 @@ +package policysetdefinitionversions + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]PolicySetDefinitionVersion +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []PolicySetDefinitionVersion +} + +type ListOperationOptions struct { + Expand *string + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + 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 PolicySetDefinitionVersionsClient) List(ctx context.Context, id ProviderPolicySetDefinitionId, 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/versions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PolicySetDefinitionVersion `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 PolicySetDefinitionVersionsClient) ListComplete(ctx context.Context, id ProviderPolicySetDefinitionId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, PolicySetDefinitionVersionOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PolicySetDefinitionVersionsClient) ListCompleteMatchingPredicate(ctx context.Context, id ProviderPolicySetDefinitionId, options ListOperationOptions, predicate PolicySetDefinitionVersionOperationPredicate) (result ListCompleteResult, err error) { + items := make([]PolicySetDefinitionVersion, 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/resources/2025-03-01/policysetdefinitionversions/method_listall.go b/resource-manager/resources/2025-03-01/policysetdefinitionversions/method_listall.go new file mode 100644 index 00000000000..5c5a2d0233e --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitionversions/method_listall.go @@ -0,0 +1,106 @@ +package policysetdefinitionversions + +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 ListAllOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PolicySetDefinitionVersion +} + +type ListAllCompleteResult struct { + LatestHttpResponse *http.Response + Items []PolicySetDefinitionVersion +} + +type ListAllCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListAllCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListAll ... +func (c PolicySetDefinitionVersionsClient) ListAll(ctx context.Context, id commonids.SubscriptionId) (result ListAllOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ListAllCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Authorization/listPolicySetDefinitionVersions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PolicySetDefinitionVersion `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAllComplete retrieves all the results into a single object +func (c PolicySetDefinitionVersionsClient) ListAllComplete(ctx context.Context, id commonids.SubscriptionId) (ListAllCompleteResult, error) { + return c.ListAllCompleteMatchingPredicate(ctx, id, PolicySetDefinitionVersionOperationPredicate{}) +} + +// ListAllCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PolicySetDefinitionVersionsClient) ListAllCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate PolicySetDefinitionVersionOperationPredicate) (result ListAllCompleteResult, err error) { + items := make([]PolicySetDefinitionVersion, 0) + + resp, err := c.ListAll(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 = ListAllCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitionversions/method_listallatmanagementgroup.go b/resource-manager/resources/2025-03-01/policysetdefinitionversions/method_listallatmanagementgroup.go new file mode 100644 index 00000000000..2002e52b0ce --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitionversions/method_listallatmanagementgroup.go @@ -0,0 +1,106 @@ +package policysetdefinitionversions + +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 ListAllAtManagementGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PolicySetDefinitionVersion +} + +type ListAllAtManagementGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []PolicySetDefinitionVersion +} + +type ListAllAtManagementGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListAllAtManagementGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListAllAtManagementGroup ... +func (c PolicySetDefinitionVersionsClient) ListAllAtManagementGroup(ctx context.Context, id commonids.ManagementGroupId) (result ListAllAtManagementGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ListAllAtManagementGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Authorization/listPolicySetDefinitionVersions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PolicySetDefinitionVersion `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAllAtManagementGroupComplete retrieves all the results into a single object +func (c PolicySetDefinitionVersionsClient) ListAllAtManagementGroupComplete(ctx context.Context, id commonids.ManagementGroupId) (ListAllAtManagementGroupCompleteResult, error) { + return c.ListAllAtManagementGroupCompleteMatchingPredicate(ctx, id, PolicySetDefinitionVersionOperationPredicate{}) +} + +// ListAllAtManagementGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PolicySetDefinitionVersionsClient) ListAllAtManagementGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ManagementGroupId, predicate PolicySetDefinitionVersionOperationPredicate) (result ListAllAtManagementGroupCompleteResult, err error) { + items := make([]PolicySetDefinitionVersion, 0) + + resp, err := c.ListAllAtManagementGroup(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 = ListAllAtManagementGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitionversions/method_listallbuiltins.go b/resource-manager/resources/2025-03-01/policysetdefinitionversions/method_listallbuiltins.go new file mode 100644 index 00000000000..75dae956b27 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitionversions/method_listallbuiltins.go @@ -0,0 +1,105 @@ +package policysetdefinitionversions + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListAllBuiltinsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PolicySetDefinitionVersion +} + +type ListAllBuiltinsCompleteResult struct { + LatestHttpResponse *http.Response + Items []PolicySetDefinitionVersion +} + +type ListAllBuiltinsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListAllBuiltinsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListAllBuiltins ... +func (c PolicySetDefinitionVersionsClient) ListAllBuiltins(ctx context.Context) (result ListAllBuiltinsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ListAllBuiltinsCustomPager{}, + Path: "/providers/Microsoft.Authorization/listPolicySetDefinitionVersions", + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PolicySetDefinitionVersion `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAllBuiltinsComplete retrieves all the results into a single object +func (c PolicySetDefinitionVersionsClient) ListAllBuiltinsComplete(ctx context.Context) (ListAllBuiltinsCompleteResult, error) { + return c.ListAllBuiltinsCompleteMatchingPredicate(ctx, PolicySetDefinitionVersionOperationPredicate{}) +} + +// ListAllBuiltinsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PolicySetDefinitionVersionsClient) ListAllBuiltinsCompleteMatchingPredicate(ctx context.Context, predicate PolicySetDefinitionVersionOperationPredicate) (result ListAllBuiltinsCompleteResult, err error) { + items := make([]PolicySetDefinitionVersion, 0) + + resp, err := c.ListAllBuiltins(ctx) + 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 = ListAllBuiltinsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitionversions/method_listbuiltin.go b/resource-manager/resources/2025-03-01/policysetdefinitionversions/method_listbuiltin.go new file mode 100644 index 00000000000..a6e53bfba5d --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitionversions/method_listbuiltin.go @@ -0,0 +1,138 @@ +package policysetdefinitionversions + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListBuiltInOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PolicySetDefinitionVersion +} + +type ListBuiltInCompleteResult struct { + LatestHttpResponse *http.Response + Items []PolicySetDefinitionVersion +} + +type ListBuiltInOperationOptions struct { + Expand *string + Top *int64 +} + +func DefaultListBuiltInOperationOptions() ListBuiltInOperationOptions { + return ListBuiltInOperationOptions{} +} + +func (o ListBuiltInOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListBuiltInOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListBuiltInOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListBuiltInCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBuiltInCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBuiltIn ... +func (c PolicySetDefinitionVersionsClient) ListBuiltIn(ctx context.Context, id PolicySetDefinitionId, options ListBuiltInOperationOptions) (result ListBuiltInOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListBuiltInCustomPager{}, + Path: fmt.Sprintf("%s/versions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PolicySetDefinitionVersion `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBuiltInComplete retrieves all the results into a single object +func (c PolicySetDefinitionVersionsClient) ListBuiltInComplete(ctx context.Context, id PolicySetDefinitionId, options ListBuiltInOperationOptions) (ListBuiltInCompleteResult, error) { + return c.ListBuiltInCompleteMatchingPredicate(ctx, id, options, PolicySetDefinitionVersionOperationPredicate{}) +} + +// ListBuiltInCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PolicySetDefinitionVersionsClient) ListBuiltInCompleteMatchingPredicate(ctx context.Context, id PolicySetDefinitionId, options ListBuiltInOperationOptions, predicate PolicySetDefinitionVersionOperationPredicate) (result ListBuiltInCompleteResult, err error) { + items := make([]PolicySetDefinitionVersion, 0) + + resp, err := c.ListBuiltIn(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 = ListBuiltInCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitionversions/method_listbymanagementgroup.go b/resource-manager/resources/2025-03-01/policysetdefinitionversions/method_listbymanagementgroup.go new file mode 100644 index 00000000000..5ebc890d43c --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitionversions/method_listbymanagementgroup.go @@ -0,0 +1,138 @@ +package policysetdefinitionversions + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByManagementGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PolicySetDefinitionVersion +} + +type ListByManagementGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []PolicySetDefinitionVersion +} + +type ListByManagementGroupOperationOptions struct { + Expand *string + Top *int64 +} + +func DefaultListByManagementGroupOperationOptions() ListByManagementGroupOperationOptions { + return ListByManagementGroupOperationOptions{} +} + +func (o ListByManagementGroupOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByManagementGroupOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListByManagementGroupOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListByManagementGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByManagementGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByManagementGroup ... +func (c PolicySetDefinitionVersionsClient) ListByManagementGroup(ctx context.Context, id Providers2PolicySetDefinitionId, options ListByManagementGroupOperationOptions) (result ListByManagementGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListByManagementGroupCustomPager{}, + Path: fmt.Sprintf("%s/versions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PolicySetDefinitionVersion `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByManagementGroupComplete retrieves all the results into a single object +func (c PolicySetDefinitionVersionsClient) ListByManagementGroupComplete(ctx context.Context, id Providers2PolicySetDefinitionId, options ListByManagementGroupOperationOptions) (ListByManagementGroupCompleteResult, error) { + return c.ListByManagementGroupCompleteMatchingPredicate(ctx, id, options, PolicySetDefinitionVersionOperationPredicate{}) +} + +// ListByManagementGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PolicySetDefinitionVersionsClient) ListByManagementGroupCompleteMatchingPredicate(ctx context.Context, id Providers2PolicySetDefinitionId, options ListByManagementGroupOperationOptions, predicate PolicySetDefinitionVersionOperationPredicate) (result ListByManagementGroupCompleteResult, err error) { + items := make([]PolicySetDefinitionVersion, 0) + + resp, err := c.ListByManagementGroup(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 = ListByManagementGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitionversions/model_parameterdefinitionsvalue.go b/resource-manager/resources/2025-03-01/policysetdefinitionversions/model_parameterdefinitionsvalue.go new file mode 100644 index 00000000000..e66fac32e51 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitionversions/model_parameterdefinitionsvalue.go @@ -0,0 +1,12 @@ +package policysetdefinitionversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ParameterDefinitionsValue struct { + AllowedValues *[]interface{} `json:"allowedValues,omitempty"` + DefaultValue *interface{} `json:"defaultValue,omitempty"` + Metadata *ParameterDefinitionsValueMetadata `json:"metadata,omitempty"` + Schema *interface{} `json:"schema,omitempty"` + Type *ParameterType `json:"type,omitempty"` +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitionversions/model_parameterdefinitionsvaluemetadata.go b/resource-manager/resources/2025-03-01/policysetdefinitionversions/model_parameterdefinitionsvaluemetadata.go new file mode 100644 index 00000000000..617808b5fd3 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitionversions/model_parameterdefinitionsvaluemetadata.go @@ -0,0 +1,11 @@ +package policysetdefinitionversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ParameterDefinitionsValueMetadata struct { + AssignPermissions *bool `json:"assignPermissions,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + StrongType *string `json:"strongType,omitempty"` +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitionversions/model_parametervaluesvalue.go b/resource-manager/resources/2025-03-01/policysetdefinitionversions/model_parametervaluesvalue.go new file mode 100644 index 00000000000..ccd18a0607d --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitionversions/model_parametervaluesvalue.go @@ -0,0 +1,8 @@ +package policysetdefinitionversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ParameterValuesValue struct { + Value *interface{} `json:"value,omitempty"` +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitionversions/model_policydefinitiongroup.go b/resource-manager/resources/2025-03-01/policysetdefinitionversions/model_policydefinitiongroup.go new file mode 100644 index 00000000000..b62619dfb0f --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitionversions/model_policydefinitiongroup.go @@ -0,0 +1,12 @@ +package policysetdefinitionversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PolicyDefinitionGroup struct { + AdditionalMetadataId *string `json:"additionalMetadataId,omitempty"` + Category *string `json:"category,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + Name string `json:"name"` +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitionversions/model_policydefinitionreference.go b/resource-manager/resources/2025-03-01/policysetdefinitionversions/model_policydefinitionreference.go new file mode 100644 index 00000000000..a23bc5a66e3 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitionversions/model_policydefinitionreference.go @@ -0,0 +1,14 @@ +package policysetdefinitionversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PolicyDefinitionReference struct { + DefinitionVersion *string `json:"definitionVersion,omitempty"` + EffectiveDefinitionVersion *string `json:"effectiveDefinitionVersion,omitempty"` + GroupNames *[]string `json:"groupNames,omitempty"` + LatestDefinitionVersion *string `json:"latestDefinitionVersion,omitempty"` + Parameters *map[string]ParameterValuesValue `json:"parameters,omitempty"` + PolicyDefinitionId string `json:"policyDefinitionId"` + PolicyDefinitionReferenceId *string `json:"policyDefinitionReferenceId,omitempty"` +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitionversions/model_policysetdefinitionversion.go b/resource-manager/resources/2025-03-01/policysetdefinitionversions/model_policysetdefinitionversion.go new file mode 100644 index 00000000000..5b9419f46b6 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitionversions/model_policysetdefinitionversion.go @@ -0,0 +1,16 @@ +package policysetdefinitionversions + +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 PolicySetDefinitionVersion struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PolicySetDefinitionVersionProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitionversions/model_policysetdefinitionversionproperties.go b/resource-manager/resources/2025-03-01/policysetdefinitionversions/model_policysetdefinitionversionproperties.go new file mode 100644 index 00000000000..4409c5d5af5 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitionversions/model_policysetdefinitionversionproperties.go @@ -0,0 +1,15 @@ +package policysetdefinitionversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PolicySetDefinitionVersionProperties struct { + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + Metadata *interface{} `json:"metadata,omitempty"` + Parameters *map[string]ParameterDefinitionsValue `json:"parameters,omitempty"` + PolicyDefinitionGroups *[]PolicyDefinitionGroup `json:"policyDefinitionGroups,omitempty"` + PolicyDefinitions []PolicyDefinitionReference `json:"policyDefinitions"` + PolicyType *PolicyType `json:"policyType,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/resources/2025-03-01/policysetdefinitionversions/predicates.go b/resource-manager/resources/2025-03-01/policysetdefinitionversions/predicates.go new file mode 100644 index 00000000000..1d4d2380c9e --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitionversions/predicates.go @@ -0,0 +1,27 @@ +package policysetdefinitionversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PolicySetDefinitionVersionOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p PolicySetDefinitionVersionOperationPredicate) Matches(input PolicySetDefinitionVersion) 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/resources/2025-03-01/policysetdefinitionversions/version.go b/resource-manager/resources/2025-03-01/policysetdefinitionversions/version.go new file mode 100644 index 00000000000..11139bae492 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policysetdefinitionversions/version.go @@ -0,0 +1,10 @@ +package policysetdefinitionversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-03-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/policysetdefinitionversions/2025-03-01" +} diff --git a/resource-manager/resources/2025-03-01/policytokens/README.md b/resource-manager/resources/2025-03-01/policytokens/README.md new file mode 100644 index 00000000000..f2c4823bd74 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policytokens/README.md @@ -0,0 +1,38 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/resources/2025-03-01/policytokens` Documentation + +The `policytokens` SDK allows for interaction with Azure Resource Manager `resources` (API Version `2025-03-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/resources/2025-03-01/policytokens" +``` + + +### Client Initialization + +```go +client := policytokens.NewPolicyTokensClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PolicyTokensClient.Acquire` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +payload := policytokens.PolicyTokenRequest{ + // ... +} + + +if err := client.AcquireThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/logz/2020-10-01/singlesignon/client.go b/resource-manager/resources/2025-03-01/policytokens/client.go similarity index 58% rename from resource-manager/logz/2020-10-01/singlesignon/client.go rename to resource-manager/resources/2025-03-01/policytokens/client.go index 7e124666990..d72d5ab1c93 100644 --- a/resource-manager/logz/2020-10-01/singlesignon/client.go +++ b/resource-manager/resources/2025-03-01/policytokens/client.go @@ -1,4 +1,4 @@ -package singlesignon +package policytokens import ( "fmt" @@ -10,17 +10,17 @@ import ( // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. -type SingleSignOnClient struct { +type PolicyTokensClient struct { Client *resourcemanager.Client } -func NewSingleSignOnClientWithBaseURI(sdkApi sdkEnv.Api) (*SingleSignOnClient, error) { - client, err := resourcemanager.NewClient(sdkApi, "singlesignon", defaultApiVersion) +func NewPolicyTokensClientWithBaseURI(sdkApi sdkEnv.Api) (*PolicyTokensClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "policytokens", defaultApiVersion) if err != nil { - return nil, fmt.Errorf("instantiating SingleSignOnClient: %+v", err) + return nil, fmt.Errorf("instantiating PolicyTokensClient: %+v", err) } - return &SingleSignOnClient{ + return &PolicyTokensClient{ Client: client, }, nil } diff --git a/resource-manager/resources/2025-03-01/policytokens/constants.go b/resource-manager/resources/2025-03-01/policytokens/constants.go new file mode 100644 index 00000000000..e1a761c7278 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policytokens/constants.go @@ -0,0 +1,92 @@ +package policytokens + +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 ExternalEndpointResult string + +const ( + ExternalEndpointResultFailed ExternalEndpointResult = "Failed" + ExternalEndpointResultSucceeded ExternalEndpointResult = "Succeeded" +) + +func PossibleValuesForExternalEndpointResult() []string { + return []string{ + string(ExternalEndpointResultFailed), + string(ExternalEndpointResultSucceeded), + } +} + +func (s *ExternalEndpointResult) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExternalEndpointResult(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExternalEndpointResult(input string) (*ExternalEndpointResult, error) { + vals := map[string]ExternalEndpointResult{ + "failed": ExternalEndpointResultFailed, + "succeeded": ExternalEndpointResultSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExternalEndpointResult(input) + return &out, nil +} + +type PolicyTokenResult string + +const ( + PolicyTokenResultFailed PolicyTokenResult = "Failed" + PolicyTokenResultSucceeded PolicyTokenResult = "Succeeded" +) + +func PossibleValuesForPolicyTokenResult() []string { + return []string{ + string(PolicyTokenResultFailed), + string(PolicyTokenResultSucceeded), + } +} + +func (s *PolicyTokenResult) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePolicyTokenResult(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePolicyTokenResult(input string) (*PolicyTokenResult, error) { + vals := map[string]PolicyTokenResult{ + "failed": PolicyTokenResultFailed, + "succeeded": PolicyTokenResultSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PolicyTokenResult(input) + return &out, nil +} diff --git a/resource-manager/logz/2020-10-01/monitors/method_create.go b/resource-manager/resources/2025-03-01/policytokens/method_acquire.go similarity index 58% rename from resource-manager/logz/2020-10-01/monitors/method_create.go rename to resource-manager/resources/2025-03-01/policytokens/method_acquire.go index 0567f882584..0e8a01f0786 100644 --- a/resource-manager/logz/2020-10-01/monitors/method_create.go +++ b/resource-manager/resources/2025-03-01/policytokens/method_acquire.go @@ -1,10 +1,11 @@ -package monitors +package policytokens import ( "context" "fmt" "net/http" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "github.com/hashicorp/go-azure-sdk/sdk/client" "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" @@ -14,23 +15,23 @@ import ( // 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 { +type AcquireOperationResponse struct { Poller pollers.Poller HttpResponse *http.Response OData *odata.OData - Model *LogzMonitorResource + Model *PolicyTokenResponse } -// Create ... -func (c MonitorsClient) Create(ctx context.Context, id MonitorId, input LogzMonitorResource) (result CreateOperationResponse, err error) { +// Acquire ... +func (c PolicyTokensClient) Acquire(ctx context.Context, id commonids.SubscriptionId, input PolicyTokenRequest) (result AcquireOperationResponse, err error) { opts := client.RequestOptions{ ContentType: "application/json; charset=utf-8", ExpectedStatusCodes: []int{ - http.StatusCreated, + http.StatusAccepted, http.StatusOK, }, - HttpMethod: http.MethodPut, - Path: id.ID(), + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.Authorization/acquirePolicyToken", id.ID()), } req, err := c.Client.NewRequest(ctx, opts) @@ -60,15 +61,15 @@ func (c MonitorsClient) Create(ctx context.Context, id MonitorId, input LogzMoni return } -// CreateThenPoll performs Create then polls until it's completed -func (c MonitorsClient) CreateThenPoll(ctx context.Context, id MonitorId, input LogzMonitorResource) error { - result, err := c.Create(ctx, id, input) +// AcquireThenPoll performs Acquire then polls until it's completed +func (c PolicyTokensClient) AcquireThenPoll(ctx context.Context, id commonids.SubscriptionId, input PolicyTokenRequest) error { + result, err := c.Acquire(ctx, id, input) if err != nil { - return fmt.Errorf("performing Create: %+v", err) + return fmt.Errorf("performing Acquire: %+v", err) } if err := result.Poller.PollUntilDone(ctx); err != nil { - return fmt.Errorf("polling after Create: %+v", err) + return fmt.Errorf("polling after Acquire: %+v", err) } return nil diff --git a/resource-manager/resources/2025-03-01/policytokens/model_externalevaluationendpointinvocationresult.go b/resource-manager/resources/2025-03-01/policytokens/model_externalevaluationendpointinvocationresult.go new file mode 100644 index 00000000000..e05784b09a4 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policytokens/model_externalevaluationendpointinvocationresult.go @@ -0,0 +1,43 @@ +package policytokens + +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 ExternalEvaluationEndpointInvocationResult struct { + Claims *interface{} `json:"claims,omitempty"` + Expiration *string `json:"expiration,omitempty"` + Message *string `json:"message,omitempty"` + PolicyInfo *PolicyLogInfo `json:"policyInfo,omitempty"` + Result *ExternalEndpointResult `json:"result,omitempty"` + RetryAfter *string `json:"retryAfter,omitempty"` +} + +func (o *ExternalEvaluationEndpointInvocationResult) GetExpirationAsTime() (*time.Time, error) { + if o.Expiration == nil { + return nil, nil + } + return dates.ParseAsFormat(o.Expiration, "2006-01-02T15:04:05Z07:00") +} + +func (o *ExternalEvaluationEndpointInvocationResult) SetExpirationAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.Expiration = &formatted +} + +func (o *ExternalEvaluationEndpointInvocationResult) GetRetryAfterAsTime() (*time.Time, error) { + if o.RetryAfter == nil { + return nil, nil + } + return dates.ParseAsFormat(o.RetryAfter, "2006-01-02T15:04:05Z07:00") +} + +func (o *ExternalEvaluationEndpointInvocationResult) SetRetryAfterAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.RetryAfter = &formatted +} diff --git a/resource-manager/resources/2025-03-01/policytokens/model_policyloginfo.go b/resource-manager/resources/2025-03-01/policytokens/model_policyloginfo.go new file mode 100644 index 00000000000..035688f35e4 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policytokens/model_policyloginfo.go @@ -0,0 +1,28 @@ +package policytokens + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PolicyLogInfo struct { + Ancestors *string `json:"ancestors,omitempty"` + ComplianceReasonCode *string `json:"complianceReasonCode,omitempty"` + PolicyAssignmentDisplayName *string `json:"policyAssignmentDisplayName,omitempty"` + PolicyAssignmentId *string `json:"policyAssignmentId,omitempty"` + PolicyAssignmentName *string `json:"policyAssignmentName,omitempty"` + PolicyAssignmentScope *string `json:"policyAssignmentScope,omitempty"` + PolicyAssignmentVersion *string `json:"policyAssignmentVersion,omitempty"` + PolicyDefinitionDisplayName *string `json:"policyDefinitionDisplayName,omitempty"` + PolicyDefinitionEffect *string `json:"policyDefinitionEffect,omitempty"` + PolicyDefinitionGroupNames *[]string `json:"policyDefinitionGroupNames,omitempty"` + PolicyDefinitionId *string `json:"policyDefinitionId,omitempty"` + PolicyDefinitionName *string `json:"policyDefinitionName,omitempty"` + PolicyDefinitionReferenceId *string `json:"policyDefinitionReferenceId,omitempty"` + PolicyDefinitionVersion *string `json:"policyDefinitionVersion,omitempty"` + PolicyExemptionIds *[]string `json:"policyExemptionIds,omitempty"` + PolicySetDefinitionCategory *string `json:"policySetDefinitionCategory,omitempty"` + PolicySetDefinitionDisplayName *string `json:"policySetDefinitionDisplayName,omitempty"` + PolicySetDefinitionId *string `json:"policySetDefinitionId,omitempty"` + PolicySetDefinitionName *string `json:"policySetDefinitionName,omitempty"` + PolicySetDefinitionVersion *string `json:"policySetDefinitionVersion,omitempty"` + ResourceLocation *string `json:"resourceLocation,omitempty"` +} diff --git a/resource-manager/resources/2025-03-01/policytokens/model_policytokenoperation.go b/resource-manager/resources/2025-03-01/policytokens/model_policytokenoperation.go new file mode 100644 index 00000000000..2af5915b4cc --- /dev/null +++ b/resource-manager/resources/2025-03-01/policytokens/model_policytokenoperation.go @@ -0,0 +1,10 @@ +package policytokens + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PolicyTokenOperation struct { + Content *interface{} `json:"content,omitempty"` + HTTPMethod *string `json:"httpMethod,omitempty"` + Uri *string `json:"uri,omitempty"` +} diff --git a/resource-manager/resources/2025-03-01/policytokens/model_policytokenrequest.go b/resource-manager/resources/2025-03-01/policytokens/model_policytokenrequest.go new file mode 100644 index 00000000000..7f27f30e76b --- /dev/null +++ b/resource-manager/resources/2025-03-01/policytokens/model_policytokenrequest.go @@ -0,0 +1,9 @@ +package policytokens + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PolicyTokenRequest struct { + ChangeReference *string `json:"changeReference,omitempty"` + Operation *PolicyTokenOperation `json:"operation,omitempty"` +} diff --git a/resource-manager/resources/2025-03-01/policytokens/model_policytokenresponse.go b/resource-manager/resources/2025-03-01/policytokens/model_policytokenresponse.go new file mode 100644 index 00000000000..cfb6986d082 --- /dev/null +++ b/resource-manager/resources/2025-03-01/policytokens/model_policytokenresponse.go @@ -0,0 +1,45 @@ +package policytokens + +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 PolicyTokenResponse struct { + ChangeReference *string `json:"changeReference,omitempty"` + Expiration *string `json:"expiration,omitempty"` + Message *string `json:"message,omitempty"` + Result *PolicyTokenResult `json:"result,omitempty"` + Results *[]ExternalEvaluationEndpointInvocationResult `json:"results,omitempty"` + RetryAfter *string `json:"retryAfter,omitempty"` + Token *string `json:"token,omitempty"` + TokenId *string `json:"tokenId,omitempty"` +} + +func (o *PolicyTokenResponse) GetExpirationAsTime() (*time.Time, error) { + if o.Expiration == nil { + return nil, nil + } + return dates.ParseAsFormat(o.Expiration, "2006-01-02T15:04:05Z07:00") +} + +func (o *PolicyTokenResponse) SetExpirationAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.Expiration = &formatted +} + +func (o *PolicyTokenResponse) GetRetryAfterAsTime() (*time.Time, error) { + if o.RetryAfter == nil { + return nil, nil + } + return dates.ParseAsFormat(o.RetryAfter, "2006-01-02T15:04:05Z07:00") +} + +func (o *PolicyTokenResponse) SetRetryAfterAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.RetryAfter = &formatted +} diff --git a/resource-manager/logz/2020-10-01/singlesignon/version.go b/resource-manager/resources/2025-03-01/policytokens/version.go similarity index 61% rename from resource-manager/logz/2020-10-01/singlesignon/version.go rename to resource-manager/resources/2025-03-01/policytokens/version.go index 997667701c9..4cf850820e7 100644 --- a/resource-manager/logz/2020-10-01/singlesignon/version.go +++ b/resource-manager/resources/2025-03-01/policytokens/version.go @@ -1,10 +1,10 @@ -package singlesignon +package policytokens // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. -const defaultApiVersion = "2020-10-01" +const defaultApiVersion = "2025-03-01" func userAgent() string { - return "hashicorp/go-azure-sdk/singlesignon/2020-10-01" + return "hashicorp/go-azure-sdk/policytokens/2025-03-01" } diff --git a/resource-manager/standbypool/2025-03-01/client.go b/resource-manager/standbypool/2025-03-01/client.go new file mode 100644 index 00000000000..3a1b6c7bbba --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/client.go @@ -0,0 +1,64 @@ +package v2025_03_01 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews" + "github.com/hashicorp/go-azure-sdk/resource-manager/standbypool/2025-03-01/standbycontainergrouppools" + "github.com/hashicorp/go-azure-sdk/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews" + "github.com/hashicorp/go-azure-sdk/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools" + "github.com/hashicorp/go-azure-sdk/resource-manager/standbypool/2025-03-01/standbyvirtualmachines" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + StandbyContainerGroupPoolRuntimeViews *standbycontainergrouppoolruntimeviews.StandbyContainerGroupPoolRuntimeViewsClient + StandbyContainerGroupPools *standbycontainergrouppools.StandbyContainerGroupPoolsClient + StandbyVirtualMachinePoolRuntimeViews *standbyvirtualmachinepoolruntimeviews.StandbyVirtualMachinePoolRuntimeViewsClient + StandbyVirtualMachinePools *standbyvirtualmachinepools.StandbyVirtualMachinePoolsClient + StandbyVirtualMachines *standbyvirtualmachines.StandbyVirtualMachinesClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + standbyContainerGroupPoolRuntimeViewsClient, err := standbycontainergrouppoolruntimeviews.NewStandbyContainerGroupPoolRuntimeViewsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building StandbyContainerGroupPoolRuntimeViews client: %+v", err) + } + configureFunc(standbyContainerGroupPoolRuntimeViewsClient.Client) + + standbyContainerGroupPoolsClient, err := standbycontainergrouppools.NewStandbyContainerGroupPoolsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building StandbyContainerGroupPools client: %+v", err) + } + configureFunc(standbyContainerGroupPoolsClient.Client) + + standbyVirtualMachinePoolRuntimeViewsClient, err := standbyvirtualmachinepoolruntimeviews.NewStandbyVirtualMachinePoolRuntimeViewsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building StandbyVirtualMachinePoolRuntimeViews client: %+v", err) + } + configureFunc(standbyVirtualMachinePoolRuntimeViewsClient.Client) + + standbyVirtualMachinePoolsClient, err := standbyvirtualmachinepools.NewStandbyVirtualMachinePoolsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building StandbyVirtualMachinePools client: %+v", err) + } + configureFunc(standbyVirtualMachinePoolsClient.Client) + + standbyVirtualMachinesClient, err := standbyvirtualmachines.NewStandbyVirtualMachinesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building StandbyVirtualMachines client: %+v", err) + } + configureFunc(standbyVirtualMachinesClient.Client) + + return &Client{ + StandbyContainerGroupPoolRuntimeViews: standbyContainerGroupPoolRuntimeViewsClient, + StandbyContainerGroupPools: standbyContainerGroupPoolsClient, + StandbyVirtualMachinePoolRuntimeViews: standbyVirtualMachinePoolRuntimeViewsClient, + StandbyVirtualMachinePools: standbyVirtualMachinePoolsClient, + StandbyVirtualMachines: standbyVirtualMachinesClient, + }, nil +} diff --git a/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/README.md b/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/README.md new file mode 100644 index 00000000000..43dcf19ce30 --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews` Documentation + +The `standbycontainergrouppoolruntimeviews` SDK allows for interaction with Azure Resource Manager `standbypool` (API Version `2025-03-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews" +``` + + +### Client Initialization + +```go +client := standbycontainergrouppoolruntimeviews.NewStandbyContainerGroupPoolRuntimeViewsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `StandbyContainerGroupPoolRuntimeViewsClient.Get` + +```go +ctx := context.TODO() +id := standbycontainergrouppoolruntimeviews.NewRuntimeViewID("12345678-1234-9876-4563-123456789012", "example-resource-group", "standbyContainerGroupPoolName", "runtimeViewName") + +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: `StandbyContainerGroupPoolRuntimeViewsClient.ListByStandbyPool` + +```go +ctx := context.TODO() +id := standbycontainergrouppoolruntimeviews.NewStandbyContainerGroupPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "standbyContainerGroupPoolName") + +// alternatively `client.ListByStandbyPool(ctx, id)` can be used to do batched pagination +items, err := client.ListByStandbyPoolComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/client.go b/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/client.go new file mode 100644 index 00000000000..05b366cc702 --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/client.go @@ -0,0 +1,26 @@ +package standbycontainergrouppoolruntimeviews + +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 StandbyContainerGroupPoolRuntimeViewsClient struct { + Client *resourcemanager.Client +} + +func NewStandbyContainerGroupPoolRuntimeViewsClientWithBaseURI(sdkApi sdkEnv.Api) (*StandbyContainerGroupPoolRuntimeViewsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "standbycontainergrouppoolruntimeviews", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating StandbyContainerGroupPoolRuntimeViewsClient: %+v", err) + } + + return &StandbyContainerGroupPoolRuntimeViewsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/constants.go b/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/constants.go new file mode 100644 index 00000000000..573c91e1155 --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/constants.go @@ -0,0 +1,142 @@ +package standbycontainergrouppoolruntimeviews + +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 HealthStateCode string + +const ( + HealthStateCodeHealthStateDegraded HealthStateCode = "HealthState/degraded" + HealthStateCodeHealthStateHealthy HealthStateCode = "HealthState/healthy" +) + +func PossibleValuesForHealthStateCode() []string { + return []string{ + string(HealthStateCodeHealthStateDegraded), + string(HealthStateCodeHealthStateHealthy), + } +} + +func (s *HealthStateCode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHealthStateCode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHealthStateCode(input string) (*HealthStateCode, error) { + vals := map[string]HealthStateCode{ + "healthstate/degraded": HealthStateCodeHealthStateDegraded, + "healthstate/healthy": HealthStateCodeHealthStateHealthy, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HealthStateCode(input) + return &out, nil +} + +type PoolContainerGroupState string + +const ( + PoolContainerGroupStateCreating PoolContainerGroupState = "Creating" + PoolContainerGroupStateDeleting PoolContainerGroupState = "Deleting" + PoolContainerGroupStateRunning PoolContainerGroupState = "Running" +) + +func PossibleValuesForPoolContainerGroupState() []string { + return []string{ + string(PoolContainerGroupStateCreating), + string(PoolContainerGroupStateDeleting), + string(PoolContainerGroupStateRunning), + } +} + +func (s *PoolContainerGroupState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePoolContainerGroupState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePoolContainerGroupState(input string) (*PoolContainerGroupState, error) { + vals := map[string]PoolContainerGroupState{ + "creating": PoolContainerGroupStateCreating, + "deleting": PoolContainerGroupStateDeleting, + "running": PoolContainerGroupStateRunning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PoolContainerGroupState(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "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/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/id_runtimeview.go b/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/id_runtimeview.go new file mode 100644 index 00000000000..e71976f66f9 --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/id_runtimeview.go @@ -0,0 +1,139 @@ +package standbycontainergrouppoolruntimeviews + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RuntimeViewId{}) +} + +var _ resourceids.ResourceId = &RuntimeViewId{} + +// RuntimeViewId is a struct representing the Resource ID for a Runtime View +type RuntimeViewId struct { + SubscriptionId string + ResourceGroupName string + StandbyContainerGroupPoolName string + RuntimeViewName string +} + +// NewRuntimeViewID returns a new RuntimeViewId struct +func NewRuntimeViewID(subscriptionId string, resourceGroupName string, standbyContainerGroupPoolName string, runtimeViewName string) RuntimeViewId { + return RuntimeViewId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StandbyContainerGroupPoolName: standbyContainerGroupPoolName, + RuntimeViewName: runtimeViewName, + } +} + +// ParseRuntimeViewID parses 'input' into a RuntimeViewId +func ParseRuntimeViewID(input string) (*RuntimeViewId, error) { + parser := resourceids.NewParserFromResourceIdType(&RuntimeViewId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RuntimeViewId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRuntimeViewIDInsensitively parses 'input' case-insensitively into a RuntimeViewId +// note: this method should only be used for API response data and not user input +func ParseRuntimeViewIDInsensitively(input string) (*RuntimeViewId, error) { + parser := resourceids.NewParserFromResourceIdType(&RuntimeViewId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RuntimeViewId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RuntimeViewId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.StandbyContainerGroupPoolName, ok = input.Parsed["standbyContainerGroupPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "standbyContainerGroupPoolName", input) + } + + if id.RuntimeViewName, ok = input.Parsed["runtimeViewName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "runtimeViewName", input) + } + + return nil +} + +// ValidateRuntimeViewID checks that 'input' can be parsed as a Runtime View ID +func ValidateRuntimeViewID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRuntimeViewID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Runtime View ID +func (id RuntimeViewId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.StandbyPool/standbyContainerGroupPools/%s/runtimeViews/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StandbyContainerGroupPoolName, id.RuntimeViewName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Runtime View ID +func (id RuntimeViewId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftStandbyPool", "Microsoft.StandbyPool", "Microsoft.StandbyPool"), + resourceids.StaticSegment("staticStandbyContainerGroupPools", "standbyContainerGroupPools", "standbyContainerGroupPools"), + resourceids.UserSpecifiedSegment("standbyContainerGroupPoolName", "standbyContainerGroupPoolName"), + resourceids.StaticSegment("staticRuntimeViews", "runtimeViews", "runtimeViews"), + resourceids.UserSpecifiedSegment("runtimeViewName", "runtimeViewName"), + } +} + +// String returns a human-readable description of this Runtime View ID +func (id RuntimeViewId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Standby Container Group Pool Name: %q", id.StandbyContainerGroupPoolName), + fmt.Sprintf("Runtime View Name: %q", id.RuntimeViewName), + } + return fmt.Sprintf("Runtime View (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/logz/2020-10-01/singlesignon/id_singlesignonconfiguration_test.go b/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/id_runtimeview_test.go similarity index 59% rename from resource-manager/logz/2020-10-01/singlesignon/id_singlesignonconfiguration_test.go rename to resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/id_runtimeview_test.go index 29525909523..31adab7f166 100644 --- a/resource-manager/logz/2020-10-01/singlesignon/id_singlesignonconfiguration_test.go +++ b/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/id_runtimeview_test.go @@ -1,4 +1,4 @@ -package singlesignon +package standbycontainergrouppoolruntimeviews import ( "testing" @@ -9,10 +9,10 @@ import ( // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. -var _ resourceids.ResourceId = &SingleSignOnConfigurationId{} +var _ resourceids.ResourceId = &RuntimeViewId{} -func TestNewSingleSignOnConfigurationID(t *testing.T) { - id := NewSingleSignOnConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName", "singleSignOnConfigurationName") +func TestNewRuntimeViewID(t *testing.T) { + id := NewRuntimeViewID("12345678-1234-9876-4563-123456789012", "example-resource-group", "standbyContainerGroupPoolName", "runtimeViewName") if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") @@ -22,28 +22,28 @@ func TestNewSingleSignOnConfigurationID(t *testing.T) { t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") } - if id.MonitorName != "monitorName" { - t.Fatalf("Expected %q but got %q for Segment 'MonitorName'", id.MonitorName, "monitorName") + if id.StandbyContainerGroupPoolName != "standbyContainerGroupPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'StandbyContainerGroupPoolName'", id.StandbyContainerGroupPoolName, "standbyContainerGroupPoolName") } - if id.SingleSignOnConfigurationName != "singleSignOnConfigurationName" { - t.Fatalf("Expected %q but got %q for Segment 'SingleSignOnConfigurationName'", id.SingleSignOnConfigurationName, "singleSignOnConfigurationName") + if id.RuntimeViewName != "runtimeViewName" { + t.Fatalf("Expected %q but got %q for Segment 'RuntimeViewName'", id.RuntimeViewName, "runtimeViewName") } } -func TestFormatSingleSignOnConfigurationID(t *testing.T) { - actual := NewSingleSignOnConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName", "singleSignOnConfigurationName").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/singleSignOnConfigurations/singleSignOnConfigurationName" +func TestFormatRuntimeViewID(t *testing.T) { + actual := NewRuntimeViewID("12345678-1234-9876-4563-123456789012", "example-resource-group", "standbyContainerGroupPoolName", "runtimeViewName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyContainerGroupPools/standbyContainerGroupPoolName/runtimeViews/runtimeViewName" if actual != expected { t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) } } -func TestParseSingleSignOnConfigurationID(t *testing.T) { +func TestParseRuntimeViewID(t *testing.T) { testData := []struct { Input string Error bool - Expected *SingleSignOnConfigurationId + Expected *RuntimeViewId }{ { // Incomplete URI @@ -77,44 +77,44 @@ func TestParseSingleSignOnConfigurationID(t *testing.T) { }, { // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool", Error: true, }, { // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyContainerGroupPools", Error: true, }, { // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyContainerGroupPools/standbyContainerGroupPoolName", Error: true, }, { // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/singleSignOnConfigurations", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyContainerGroupPools/standbyContainerGroupPoolName/runtimeViews", Error: true, }, { // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/singleSignOnConfigurations/singleSignOnConfigurationName", - Expected: &SingleSignOnConfigurationId{ + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyContainerGroupPools/standbyContainerGroupPoolName/runtimeViews/runtimeViewName", + Expected: &RuntimeViewId{ SubscriptionId: "12345678-1234-9876-4563-123456789012", ResourceGroupName: "example-resource-group", - MonitorName: "monitorName", - SingleSignOnConfigurationName: "singleSignOnConfigurationName", + StandbyContainerGroupPoolName: "standbyContainerGroupPoolName", + RuntimeViewName: "runtimeViewName", }, }, { // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/singleSignOnConfigurations/singleSignOnConfigurationName/extra", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyContainerGroupPools/standbyContainerGroupPoolName/runtimeViews/runtimeViewName/extra", Error: true, }, } for _, v := range testData { t.Logf("[DEBUG] Testing %q", v.Input) - actual, err := ParseSingleSignOnConfigurationID(v.Input) + actual, err := ParseRuntimeViewID(v.Input) if err != nil { if v.Error { continue @@ -134,22 +134,22 @@ func TestParseSingleSignOnConfigurationID(t *testing.T) { t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) } - if actual.MonitorName != v.Expected.MonitorName { - t.Fatalf("Expected %q but got %q for MonitorName", v.Expected.MonitorName, actual.MonitorName) + if actual.StandbyContainerGroupPoolName != v.Expected.StandbyContainerGroupPoolName { + t.Fatalf("Expected %q but got %q for StandbyContainerGroupPoolName", v.Expected.StandbyContainerGroupPoolName, actual.StandbyContainerGroupPoolName) } - if actual.SingleSignOnConfigurationName != v.Expected.SingleSignOnConfigurationName { - t.Fatalf("Expected %q but got %q for SingleSignOnConfigurationName", v.Expected.SingleSignOnConfigurationName, actual.SingleSignOnConfigurationName) + if actual.RuntimeViewName != v.Expected.RuntimeViewName { + t.Fatalf("Expected %q but got %q for RuntimeViewName", v.Expected.RuntimeViewName, actual.RuntimeViewName) } } } -func TestParseSingleSignOnConfigurationIDInsensitively(t *testing.T) { +func TestParseRuntimeViewIDInsensitively(t *testing.T) { testData := []struct { Input string Error bool - Expected *SingleSignOnConfigurationId + Expected *RuntimeViewId }{ { // Incomplete URI @@ -208,79 +208,79 @@ func TestParseSingleSignOnConfigurationIDInsensitively(t *testing.T) { }, { // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool", Error: true, }, { // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ", + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sTaNdByPoOl", Error: true, }, { // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyContainerGroupPools", Error: true, }, { // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ/mOnItOrS", + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sTaNdByPoOl/sTaNdByCoNtAiNeRgRoUpPoOlS", Error: true, }, { // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyContainerGroupPools/standbyContainerGroupPoolName", Error: true, }, { // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ/mOnItOrS/mOnItOrNaMe", + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sTaNdByPoOl/sTaNdByCoNtAiNeRgRoUpPoOlS/sTaNdByCoNtAiNeRgRoUpPoOlNaMe", Error: true, }, { // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/singleSignOnConfigurations", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyContainerGroupPools/standbyContainerGroupPoolName/runtimeViews", Error: true, }, { // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ/mOnItOrS/mOnItOrNaMe/sInGlEsIgNoNcOnFiGuRaTiOnS", + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sTaNdByPoOl/sTaNdByCoNtAiNeRgRoUpPoOlS/sTaNdByCoNtAiNeRgRoUpPoOlNaMe/rUnTiMeViEwS", Error: true, }, { // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/singleSignOnConfigurations/singleSignOnConfigurationName", - Expected: &SingleSignOnConfigurationId{ + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyContainerGroupPools/standbyContainerGroupPoolName/runtimeViews/runtimeViewName", + Expected: &RuntimeViewId{ SubscriptionId: "12345678-1234-9876-4563-123456789012", ResourceGroupName: "example-resource-group", - MonitorName: "monitorName", - SingleSignOnConfigurationName: "singleSignOnConfigurationName", + StandbyContainerGroupPoolName: "standbyContainerGroupPoolName", + RuntimeViewName: "runtimeViewName", }, }, { // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/singleSignOnConfigurations/singleSignOnConfigurationName/extra", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyContainerGroupPools/standbyContainerGroupPoolName/runtimeViews/runtimeViewName/extra", Error: true, }, { // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ/mOnItOrS/mOnItOrNaMe/sInGlEsIgNoNcOnFiGuRaTiOnS/sInGlEsIgNoNcOnFiGuRaTiOnNaMe", - Expected: &SingleSignOnConfigurationId{ + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sTaNdByPoOl/sTaNdByCoNtAiNeRgRoUpPoOlS/sTaNdByCoNtAiNeRgRoUpPoOlNaMe/rUnTiMeViEwS/rUnTiMeViEwNaMe", + Expected: &RuntimeViewId{ SubscriptionId: "12345678-1234-9876-4563-123456789012", ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - MonitorName: "mOnItOrNaMe", - SingleSignOnConfigurationName: "sInGlEsIgNoNcOnFiGuRaTiOnNaMe", + StandbyContainerGroupPoolName: "sTaNdByCoNtAiNeRgRoUpPoOlNaMe", + RuntimeViewName: "rUnTiMeViEwNaMe", }, }, { // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ/mOnItOrS/mOnItOrNaMe/sInGlEsIgNoNcOnFiGuRaTiOnS/sInGlEsIgNoNcOnFiGuRaTiOnNaMe/extra", + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sTaNdByPoOl/sTaNdByCoNtAiNeRgRoUpPoOlS/sTaNdByCoNtAiNeRgRoUpPoOlNaMe/rUnTiMeViEwS/rUnTiMeViEwNaMe/extra", Error: true, }, } for _, v := range testData { t.Logf("[DEBUG] Testing %q", v.Input) - actual, err := ParseSingleSignOnConfigurationIDInsensitively(v.Input) + actual, err := ParseRuntimeViewIDInsensitively(v.Input) if err != nil { if v.Error { continue @@ -300,21 +300,21 @@ func TestParseSingleSignOnConfigurationIDInsensitively(t *testing.T) { t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) } - if actual.MonitorName != v.Expected.MonitorName { - t.Fatalf("Expected %q but got %q for MonitorName", v.Expected.MonitorName, actual.MonitorName) + if actual.StandbyContainerGroupPoolName != v.Expected.StandbyContainerGroupPoolName { + t.Fatalf("Expected %q but got %q for StandbyContainerGroupPoolName", v.Expected.StandbyContainerGroupPoolName, actual.StandbyContainerGroupPoolName) } - if actual.SingleSignOnConfigurationName != v.Expected.SingleSignOnConfigurationName { - t.Fatalf("Expected %q but got %q for SingleSignOnConfigurationName", v.Expected.SingleSignOnConfigurationName, actual.SingleSignOnConfigurationName) + if actual.RuntimeViewName != v.Expected.RuntimeViewName { + t.Fatalf("Expected %q but got %q for RuntimeViewName", v.Expected.RuntimeViewName, actual.RuntimeViewName) } } } -func TestSegmentsForSingleSignOnConfigurationId(t *testing.T) { - segments := SingleSignOnConfigurationId{}.Segments() +func TestSegmentsForRuntimeViewId(t *testing.T) { + segments := RuntimeViewId{}.Segments() if len(segments) == 0 { - t.Fatalf("SingleSignOnConfigurationId has no segments") + t.Fatalf("RuntimeViewId has no segments") } uniqueNames := make(map[string]struct{}, 0) diff --git a/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/id_standbycontainergrouppool.go b/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/id_standbycontainergrouppool.go new file mode 100644 index 00000000000..9003fcfc894 --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/id_standbycontainergrouppool.go @@ -0,0 +1,130 @@ +package standbycontainergrouppoolruntimeviews + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&StandbyContainerGroupPoolId{}) +} + +var _ resourceids.ResourceId = &StandbyContainerGroupPoolId{} + +// StandbyContainerGroupPoolId is a struct representing the Resource ID for a Standby Container Group Pool +type StandbyContainerGroupPoolId struct { + SubscriptionId string + ResourceGroupName string + StandbyContainerGroupPoolName string +} + +// NewStandbyContainerGroupPoolID returns a new StandbyContainerGroupPoolId struct +func NewStandbyContainerGroupPoolID(subscriptionId string, resourceGroupName string, standbyContainerGroupPoolName string) StandbyContainerGroupPoolId { + return StandbyContainerGroupPoolId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StandbyContainerGroupPoolName: standbyContainerGroupPoolName, + } +} + +// ParseStandbyContainerGroupPoolID parses 'input' into a StandbyContainerGroupPoolId +func ParseStandbyContainerGroupPoolID(input string) (*StandbyContainerGroupPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&StandbyContainerGroupPoolId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := StandbyContainerGroupPoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseStandbyContainerGroupPoolIDInsensitively parses 'input' case-insensitively into a StandbyContainerGroupPoolId +// note: this method should only be used for API response data and not user input +func ParseStandbyContainerGroupPoolIDInsensitively(input string) (*StandbyContainerGroupPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&StandbyContainerGroupPoolId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := StandbyContainerGroupPoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *StandbyContainerGroupPoolId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.StandbyContainerGroupPoolName, ok = input.Parsed["standbyContainerGroupPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "standbyContainerGroupPoolName", input) + } + + return nil +} + +// ValidateStandbyContainerGroupPoolID checks that 'input' can be parsed as a Standby Container Group Pool ID +func ValidateStandbyContainerGroupPoolID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseStandbyContainerGroupPoolID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Standby Container Group Pool ID +func (id StandbyContainerGroupPoolId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.StandbyPool/standbyContainerGroupPools/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StandbyContainerGroupPoolName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Standby Container Group Pool ID +func (id StandbyContainerGroupPoolId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftStandbyPool", "Microsoft.StandbyPool", "Microsoft.StandbyPool"), + resourceids.StaticSegment("staticStandbyContainerGroupPools", "standbyContainerGroupPools", "standbyContainerGroupPools"), + resourceids.UserSpecifiedSegment("standbyContainerGroupPoolName", "standbyContainerGroupPoolName"), + } +} + +// String returns a human-readable description of this Standby Container Group Pool ID +func (id StandbyContainerGroupPoolId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Standby Container Group Pool Name: %q", id.StandbyContainerGroupPoolName), + } + return fmt.Sprintf("Standby Container Group Pool (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/id_standbycontainergrouppool_test.go b/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/id_standbycontainergrouppool_test.go new file mode 100644 index 00000000000..13cdfc8e48d --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/id_standbycontainergrouppool_test.go @@ -0,0 +1,282 @@ +package standbycontainergrouppoolruntimeviews + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &StandbyContainerGroupPoolId{} + +func TestNewStandbyContainerGroupPoolID(t *testing.T) { + id := NewStandbyContainerGroupPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "standbyContainerGroupPoolName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.StandbyContainerGroupPoolName != "standbyContainerGroupPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'StandbyContainerGroupPoolName'", id.StandbyContainerGroupPoolName, "standbyContainerGroupPoolName") + } +} + +func TestFormatStandbyContainerGroupPoolID(t *testing.T) { + actual := NewStandbyContainerGroupPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "standbyContainerGroupPoolName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyContainerGroupPools/standbyContainerGroupPoolName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseStandbyContainerGroupPoolID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *StandbyContainerGroupPoolId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyContainerGroupPools", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyContainerGroupPools/standbyContainerGroupPoolName", + Expected: &StandbyContainerGroupPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StandbyContainerGroupPoolName: "standbyContainerGroupPoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyContainerGroupPools/standbyContainerGroupPoolName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseStandbyContainerGroupPoolID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StandbyContainerGroupPoolName != v.Expected.StandbyContainerGroupPoolName { + t.Fatalf("Expected %q but got %q for StandbyContainerGroupPoolName", v.Expected.StandbyContainerGroupPoolName, actual.StandbyContainerGroupPoolName) + } + + } +} + +func TestParseStandbyContainerGroupPoolIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *StandbyContainerGroupPoolId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sTaNdByPoOl", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyContainerGroupPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sTaNdByPoOl/sTaNdByCoNtAiNeRgRoUpPoOlS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyContainerGroupPools/standbyContainerGroupPoolName", + Expected: &StandbyContainerGroupPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StandbyContainerGroupPoolName: "standbyContainerGroupPoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyContainerGroupPools/standbyContainerGroupPoolName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sTaNdByPoOl/sTaNdByCoNtAiNeRgRoUpPoOlS/sTaNdByCoNtAiNeRgRoUpPoOlNaMe", + Expected: &StandbyContainerGroupPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + StandbyContainerGroupPoolName: "sTaNdByCoNtAiNeRgRoUpPoOlNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sTaNdByPoOl/sTaNdByCoNtAiNeRgRoUpPoOlS/sTaNdByCoNtAiNeRgRoUpPoOlNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseStandbyContainerGroupPoolIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StandbyContainerGroupPoolName != v.Expected.StandbyContainerGroupPoolName { + t.Fatalf("Expected %q but got %q for StandbyContainerGroupPoolName", v.Expected.StandbyContainerGroupPoolName, actual.StandbyContainerGroupPoolName) + } + + } +} + +func TestSegmentsForStandbyContainerGroupPoolId(t *testing.T) { + segments := StandbyContainerGroupPoolId{}.Segments() + if len(segments) == 0 { + t.Fatalf("StandbyContainerGroupPoolId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/method_get.go b/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/method_get.go new file mode 100644 index 00000000000..fe1bbb0becd --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/method_get.go @@ -0,0 +1,53 @@ +package standbycontainergrouppoolruntimeviews + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *StandbyContainerGroupPoolRuntimeViewResource +} + +// Get ... +func (c StandbyContainerGroupPoolRuntimeViewsClient) Get(ctx context.Context, id RuntimeViewId) (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 StandbyContainerGroupPoolRuntimeViewResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/method_listbystandbypool.go b/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/method_listbystandbypool.go new file mode 100644 index 00000000000..84612737fbc --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/method_listbystandbypool.go @@ -0,0 +1,105 @@ +package standbycontainergrouppoolruntimeviews + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByStandbyPoolOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StandbyContainerGroupPoolRuntimeViewResource +} + +type ListByStandbyPoolCompleteResult struct { + LatestHttpResponse *http.Response + Items []StandbyContainerGroupPoolRuntimeViewResource +} + +type ListByStandbyPoolCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByStandbyPoolCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByStandbyPool ... +func (c StandbyContainerGroupPoolRuntimeViewsClient) ListByStandbyPool(ctx context.Context, id StandbyContainerGroupPoolId) (result ListByStandbyPoolOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByStandbyPoolCustomPager{}, + Path: fmt.Sprintf("%s/runtimeViews", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]StandbyContainerGroupPoolRuntimeViewResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByStandbyPoolComplete retrieves all the results into a single object +func (c StandbyContainerGroupPoolRuntimeViewsClient) ListByStandbyPoolComplete(ctx context.Context, id StandbyContainerGroupPoolId) (ListByStandbyPoolCompleteResult, error) { + return c.ListByStandbyPoolCompleteMatchingPredicate(ctx, id, StandbyContainerGroupPoolRuntimeViewResourceOperationPredicate{}) +} + +// ListByStandbyPoolCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StandbyContainerGroupPoolRuntimeViewsClient) ListByStandbyPoolCompleteMatchingPredicate(ctx context.Context, id StandbyContainerGroupPoolId, predicate StandbyContainerGroupPoolRuntimeViewResourceOperationPredicate) (result ListByStandbyPoolCompleteResult, err error) { + items := make([]StandbyContainerGroupPoolRuntimeViewResource, 0) + + resp, err := c.ListByStandbyPool(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 = ListByStandbyPoolCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/model_containergroupinstancecountsummary.go b/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/model_containergroupinstancecountsummary.go new file mode 100644 index 00000000000..887ff199fa9 --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/model_containergroupinstancecountsummary.go @@ -0,0 +1,9 @@ +package standbycontainergrouppoolruntimeviews + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerGroupInstanceCountSummary struct { + InstanceCountsByState []PoolContainerGroupStateCount `json:"instanceCountsByState"` + Zone *int64 `json:"zone,omitempty"` +} diff --git a/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/model_poolcontainergroupstatecount.go b/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/model_poolcontainergroupstatecount.go new file mode 100644 index 00000000000..32cba36b593 --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/model_poolcontainergroupstatecount.go @@ -0,0 +1,9 @@ +package standbycontainergrouppoolruntimeviews + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PoolContainerGroupStateCount struct { + Count int64 `json:"count"` + State PoolContainerGroupState `json:"state"` +} diff --git a/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/model_poolstatus.go b/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/model_poolstatus.go new file mode 100644 index 00000000000..ae24e087ab8 --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/model_poolstatus.go @@ -0,0 +1,9 @@ +package standbycontainergrouppoolruntimeviews + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PoolStatus struct { + Code HealthStateCode `json:"code"` + Message *string `json:"message,omitempty"` +} diff --git a/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/model_standbycontainergrouppoolforecastvalues.go b/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/model_standbycontainergrouppoolforecastvalues.go new file mode 100644 index 00000000000..e8addfa7e96 --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/model_standbycontainergrouppoolforecastvalues.go @@ -0,0 +1,8 @@ +package standbycontainergrouppoolruntimeviews + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StandbyContainerGroupPoolForecastValues struct { + InstancesRequestedCount []int64 `json:"instancesRequestedCount"` +} diff --git a/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/model_standbycontainergrouppoolprediction.go b/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/model_standbycontainergrouppoolprediction.go new file mode 100644 index 00000000000..e70bb0d7517 --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/model_standbycontainergrouppoolprediction.go @@ -0,0 +1,25 @@ +package standbycontainergrouppoolruntimeviews + +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 StandbyContainerGroupPoolPrediction struct { + ForecastInfo string `json:"forecastInfo"` + ForecastStartTime string `json:"forecastStartTime"` + ForecastValues StandbyContainerGroupPoolForecastValues `json:"forecastValues"` +} + +func (o *StandbyContainerGroupPoolPrediction) GetForecastStartTimeAsTime() (*time.Time, error) { + return dates.ParseAsFormat(&o.ForecastStartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *StandbyContainerGroupPoolPrediction) SetForecastStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ForecastStartTime = formatted +} diff --git a/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/model_standbycontainergrouppoolruntimeviewresource.go b/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/model_standbycontainergrouppoolruntimeviewresource.go new file mode 100644 index 00000000000..cc129016a83 --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/model_standbycontainergrouppoolruntimeviewresource.go @@ -0,0 +1,16 @@ +package standbycontainergrouppoolruntimeviews + +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 StandbyContainerGroupPoolRuntimeViewResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StandbyContainerGroupPoolRuntimeViewResourceProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/model_standbycontainergrouppoolruntimeviewresourceproperties.go b/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/model_standbycontainergrouppoolruntimeviewresourceproperties.go new file mode 100644 index 00000000000..9aab7e04242 --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/model_standbycontainergrouppoolruntimeviewresourceproperties.go @@ -0,0 +1,11 @@ +package standbycontainergrouppoolruntimeviews + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StandbyContainerGroupPoolRuntimeViewResourceProperties struct { + InstanceCountSummary []ContainerGroupInstanceCountSummary `json:"instanceCountSummary"` + Prediction *StandbyContainerGroupPoolPrediction `json:"prediction,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Status *PoolStatus `json:"status,omitempty"` +} diff --git a/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/predicates.go b/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/predicates.go new file mode 100644 index 00000000000..8e0ee57c62e --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/predicates.go @@ -0,0 +1,27 @@ +package standbycontainergrouppoolruntimeviews + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StandbyContainerGroupPoolRuntimeViewResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p StandbyContainerGroupPoolRuntimeViewResourceOperationPredicate) Matches(input StandbyContainerGroupPoolRuntimeViewResource) 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/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/version.go b/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/version.go new file mode 100644 index 00000000000..a64074d5735 --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbycontainergrouppoolruntimeviews/version.go @@ -0,0 +1,10 @@ +package standbycontainergrouppoolruntimeviews + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-03-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/standbycontainergrouppoolruntimeviews/2025-03-01" +} diff --git a/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/README.md b/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/README.md new file mode 100644 index 00000000000..78170a6cba8 --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/README.md @@ -0,0 +1,121 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/standbypool/2025-03-01/standbycontainergrouppools` Documentation + +The `standbycontainergrouppools` SDK allows for interaction with Azure Resource Manager `standbypool` (API Version `2025-03-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/standbypool/2025-03-01/standbycontainergrouppools" +``` + + +### Client Initialization + +```go +client := standbycontainergrouppools.NewStandbyContainerGroupPoolsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `StandbyContainerGroupPoolsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := standbycontainergrouppools.NewStandbyContainerGroupPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "standbyContainerGroupPoolName") + +payload := standbycontainergrouppools.StandbyContainerGroupPoolResource{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `StandbyContainerGroupPoolsClient.Delete` + +```go +ctx := context.TODO() +id := standbycontainergrouppools.NewStandbyContainerGroupPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "standbyContainerGroupPoolName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `StandbyContainerGroupPoolsClient.Get` + +```go +ctx := context.TODO() +id := standbycontainergrouppools.NewStandbyContainerGroupPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "standbyContainerGroupPoolName") + +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: `StandbyContainerGroupPoolsClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StandbyContainerGroupPoolsClient.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: `StandbyContainerGroupPoolsClient.Update` + +```go +ctx := context.TODO() +id := standbycontainergrouppools.NewStandbyContainerGroupPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "standbyContainerGroupPoolName") + +payload := standbycontainergrouppools.StandbyContainerGroupPoolResourceUpdate{ + // ... +} + + +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/standbypool/2025-03-01/standbycontainergrouppools/client.go b/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/client.go new file mode 100644 index 00000000000..0674629580e --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/client.go @@ -0,0 +1,26 @@ +package standbycontainergrouppools + +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 StandbyContainerGroupPoolsClient struct { + Client *resourcemanager.Client +} + +func NewStandbyContainerGroupPoolsClientWithBaseURI(sdkApi sdkEnv.Api) (*StandbyContainerGroupPoolsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "standbycontainergrouppools", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating StandbyContainerGroupPoolsClient: %+v", err) + } + + return &StandbyContainerGroupPoolsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/constants.go b/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/constants.go new file mode 100644 index 00000000000..7e3b7a12e1b --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/constants.go @@ -0,0 +1,95 @@ +package standbycontainergrouppools + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type RefillPolicy string + +const ( + RefillPolicyAlways RefillPolicy = "always" +) + +func PossibleValuesForRefillPolicy() []string { + return []string{ + string(RefillPolicyAlways), + } +} + +func (s *RefillPolicy) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRefillPolicy(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRefillPolicy(input string) (*RefillPolicy, error) { + vals := map[string]RefillPolicy{ + "always": RefillPolicyAlways, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RefillPolicy(input) + return &out, nil +} diff --git a/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/id_standbycontainergrouppool.go b/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/id_standbycontainergrouppool.go new file mode 100644 index 00000000000..cd7d833ffc8 --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/id_standbycontainergrouppool.go @@ -0,0 +1,130 @@ +package standbycontainergrouppools + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&StandbyContainerGroupPoolId{}) +} + +var _ resourceids.ResourceId = &StandbyContainerGroupPoolId{} + +// StandbyContainerGroupPoolId is a struct representing the Resource ID for a Standby Container Group Pool +type StandbyContainerGroupPoolId struct { + SubscriptionId string + ResourceGroupName string + StandbyContainerGroupPoolName string +} + +// NewStandbyContainerGroupPoolID returns a new StandbyContainerGroupPoolId struct +func NewStandbyContainerGroupPoolID(subscriptionId string, resourceGroupName string, standbyContainerGroupPoolName string) StandbyContainerGroupPoolId { + return StandbyContainerGroupPoolId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StandbyContainerGroupPoolName: standbyContainerGroupPoolName, + } +} + +// ParseStandbyContainerGroupPoolID parses 'input' into a StandbyContainerGroupPoolId +func ParseStandbyContainerGroupPoolID(input string) (*StandbyContainerGroupPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&StandbyContainerGroupPoolId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := StandbyContainerGroupPoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseStandbyContainerGroupPoolIDInsensitively parses 'input' case-insensitively into a StandbyContainerGroupPoolId +// note: this method should only be used for API response data and not user input +func ParseStandbyContainerGroupPoolIDInsensitively(input string) (*StandbyContainerGroupPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&StandbyContainerGroupPoolId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := StandbyContainerGroupPoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *StandbyContainerGroupPoolId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.StandbyContainerGroupPoolName, ok = input.Parsed["standbyContainerGroupPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "standbyContainerGroupPoolName", input) + } + + return nil +} + +// ValidateStandbyContainerGroupPoolID checks that 'input' can be parsed as a Standby Container Group Pool ID +func ValidateStandbyContainerGroupPoolID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseStandbyContainerGroupPoolID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Standby Container Group Pool ID +func (id StandbyContainerGroupPoolId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.StandbyPool/standbyContainerGroupPools/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StandbyContainerGroupPoolName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Standby Container Group Pool ID +func (id StandbyContainerGroupPoolId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftStandbyPool", "Microsoft.StandbyPool", "Microsoft.StandbyPool"), + resourceids.StaticSegment("staticStandbyContainerGroupPools", "standbyContainerGroupPools", "standbyContainerGroupPools"), + resourceids.UserSpecifiedSegment("standbyContainerGroupPoolName", "standbyContainerGroupPoolName"), + } +} + +// String returns a human-readable description of this Standby Container Group Pool ID +func (id StandbyContainerGroupPoolId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Standby Container Group Pool Name: %q", id.StandbyContainerGroupPoolName), + } + return fmt.Sprintf("Standby Container Group Pool (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/logz/2020-10-01/subaccount/id_monitor_test.go b/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/id_standbycontainergrouppool_test.go similarity index 61% rename from resource-manager/logz/2020-10-01/subaccount/id_monitor_test.go rename to resource-manager/standbypool/2025-03-01/standbycontainergrouppools/id_standbycontainergrouppool_test.go index 17d362e86de..1c1695109b7 100644 --- a/resource-manager/logz/2020-10-01/subaccount/id_monitor_test.go +++ b/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/id_standbycontainergrouppool_test.go @@ -1,4 +1,4 @@ -package subaccount +package standbycontainergrouppools import ( "testing" @@ -9,10 +9,10 @@ import ( // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. -var _ resourceids.ResourceId = &MonitorId{} +var _ resourceids.ResourceId = &StandbyContainerGroupPoolId{} -func TestNewMonitorID(t *testing.T) { - id := NewMonitorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName") +func TestNewStandbyContainerGroupPoolID(t *testing.T) { + id := NewStandbyContainerGroupPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "standbyContainerGroupPoolName") if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") @@ -22,24 +22,24 @@ func TestNewMonitorID(t *testing.T) { t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") } - if id.MonitorName != "monitorName" { - t.Fatalf("Expected %q but got %q for Segment 'MonitorName'", id.MonitorName, "monitorName") + if id.StandbyContainerGroupPoolName != "standbyContainerGroupPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'StandbyContainerGroupPoolName'", id.StandbyContainerGroupPoolName, "standbyContainerGroupPoolName") } } -func TestFormatMonitorID(t *testing.T) { - actual := NewMonitorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName" +func TestFormatStandbyContainerGroupPoolID(t *testing.T) { + actual := NewStandbyContainerGroupPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "standbyContainerGroupPoolName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyContainerGroupPools/standbyContainerGroupPoolName" if actual != expected { t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) } } -func TestParseMonitorID(t *testing.T) { +func TestParseStandbyContainerGroupPoolID(t *testing.T) { testData := []struct { Input string Error bool - Expected *MonitorId + Expected *StandbyContainerGroupPoolId }{ { // Incomplete URI @@ -73,33 +73,33 @@ func TestParseMonitorID(t *testing.T) { }, { // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool", Error: true, }, { // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyContainerGroupPools", Error: true, }, { // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName", - Expected: &MonitorId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - MonitorName: "monitorName", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyContainerGroupPools/standbyContainerGroupPoolName", + Expected: &StandbyContainerGroupPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StandbyContainerGroupPoolName: "standbyContainerGroupPoolName", }, }, { // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/extra", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyContainerGroupPools/standbyContainerGroupPoolName/extra", Error: true, }, } for _, v := range testData { t.Logf("[DEBUG] Testing %q", v.Input) - actual, err := ParseMonitorID(v.Input) + actual, err := ParseStandbyContainerGroupPoolID(v.Input) if err != nil { if v.Error { continue @@ -119,18 +119,18 @@ func TestParseMonitorID(t *testing.T) { t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) } - if actual.MonitorName != v.Expected.MonitorName { - t.Fatalf("Expected %q but got %q for MonitorName", v.Expected.MonitorName, actual.MonitorName) + if actual.StandbyContainerGroupPoolName != v.Expected.StandbyContainerGroupPoolName { + t.Fatalf("Expected %q but got %q for StandbyContainerGroupPoolName", v.Expected.StandbyContainerGroupPoolName, actual.StandbyContainerGroupPoolName) } } } -func TestParseMonitorIDInsensitively(t *testing.T) { +func TestParseStandbyContainerGroupPoolIDInsensitively(t *testing.T) { testData := []struct { Input string Error bool - Expected *MonitorId + Expected *StandbyContainerGroupPoolId }{ { // Incomplete URI @@ -189,57 +189,57 @@ func TestParseMonitorIDInsensitively(t *testing.T) { }, { // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool", Error: true, }, { // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ", + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sTaNdByPoOl", Error: true, }, { // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyContainerGroupPools", Error: true, }, { // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ/mOnItOrS", + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sTaNdByPoOl/sTaNdByCoNtAiNeRgRoUpPoOlS", Error: true, }, { // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName", - Expected: &MonitorId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - MonitorName: "monitorName", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyContainerGroupPools/standbyContainerGroupPoolName", + Expected: &StandbyContainerGroupPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StandbyContainerGroupPoolName: "standbyContainerGroupPoolName", }, }, { // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/extra", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyContainerGroupPools/standbyContainerGroupPoolName/extra", Error: true, }, { // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ/mOnItOrS/mOnItOrNaMe", - Expected: &MonitorId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - MonitorName: "mOnItOrNaMe", + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sTaNdByPoOl/sTaNdByCoNtAiNeRgRoUpPoOlS/sTaNdByCoNtAiNeRgRoUpPoOlNaMe", + Expected: &StandbyContainerGroupPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + StandbyContainerGroupPoolName: "sTaNdByCoNtAiNeRgRoUpPoOlNaMe", }, }, { // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ/mOnItOrS/mOnItOrNaMe/extra", + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sTaNdByPoOl/sTaNdByCoNtAiNeRgRoUpPoOlS/sTaNdByCoNtAiNeRgRoUpPoOlNaMe/extra", Error: true, }, } for _, v := range testData { t.Logf("[DEBUG] Testing %q", v.Input) - actual, err := ParseMonitorIDInsensitively(v.Input) + actual, err := ParseStandbyContainerGroupPoolIDInsensitively(v.Input) if err != nil { if v.Error { continue @@ -259,17 +259,17 @@ func TestParseMonitorIDInsensitively(t *testing.T) { t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) } - if actual.MonitorName != v.Expected.MonitorName { - t.Fatalf("Expected %q but got %q for MonitorName", v.Expected.MonitorName, actual.MonitorName) + if actual.StandbyContainerGroupPoolName != v.Expected.StandbyContainerGroupPoolName { + t.Fatalf("Expected %q but got %q for StandbyContainerGroupPoolName", v.Expected.StandbyContainerGroupPoolName, actual.StandbyContainerGroupPoolName) } } } -func TestSegmentsForMonitorId(t *testing.T) { - segments := MonitorId{}.Segments() +func TestSegmentsForStandbyContainerGroupPoolId(t *testing.T) { + segments := StandbyContainerGroupPoolId{}.Segments() if len(segments) == 0 { - t.Fatalf("MonitorId has no segments") + t.Fatalf("StandbyContainerGroupPoolId has no segments") } uniqueNames := make(map[string]struct{}, 0) diff --git a/resource-manager/logz/2020-10-01/singlesignon/method_createorupdate.go b/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/method_createorupdate.go similarity index 77% rename from resource-manager/logz/2020-10-01/singlesignon/method_createorupdate.go rename to resource-manager/standbypool/2025-03-01/standbycontainergrouppools/method_createorupdate.go index 066229f56d8..c3d1e96f40a 100644 --- a/resource-manager/logz/2020-10-01/singlesignon/method_createorupdate.go +++ b/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/method_createorupdate.go @@ -1,4 +1,4 @@ -package singlesignon +package standbycontainergrouppools import ( "context" @@ -18,11 +18,11 @@ type CreateOrUpdateOperationResponse struct { Poller pollers.Poller HttpResponse *http.Response OData *odata.OData - Model *LogzSingleSignOnResource + Model *StandbyContainerGroupPoolResource } // CreateOrUpdate ... -func (c SingleSignOnClient) CreateOrUpdate(ctx context.Context, id SingleSignOnConfigurationId, input LogzSingleSignOnResource) (result CreateOrUpdateOperationResponse, err error) { +func (c StandbyContainerGroupPoolsClient) CreateOrUpdate(ctx context.Context, id StandbyContainerGroupPoolId, input StandbyContainerGroupPoolResource) (result CreateOrUpdateOperationResponse, err error) { opts := client.RequestOptions{ ContentType: "application/json; charset=utf-8", ExpectedStatusCodes: []int{ @@ -61,7 +61,7 @@ func (c SingleSignOnClient) CreateOrUpdate(ctx context.Context, id SingleSignOnC } // CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c SingleSignOnClient) CreateOrUpdateThenPoll(ctx context.Context, id SingleSignOnConfigurationId, input LogzSingleSignOnResource) error { +func (c StandbyContainerGroupPoolsClient) CreateOrUpdateThenPoll(ctx context.Context, id StandbyContainerGroupPoolId, input StandbyContainerGroupPoolResource) error { result, err := c.CreateOrUpdate(ctx, id, input) if err != nil { return fmt.Errorf("performing CreateOrUpdate: %+v", err) diff --git a/resource-manager/logz/2020-10-01/monitors/method_delete.go b/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/method_delete.go similarity index 82% rename from resource-manager/logz/2020-10-01/monitors/method_delete.go rename to resource-manager/standbypool/2025-03-01/standbycontainergrouppools/method_delete.go index ed121cfa76f..3549685c956 100644 --- a/resource-manager/logz/2020-10-01/monitors/method_delete.go +++ b/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/method_delete.go @@ -1,4 +1,4 @@ -package monitors +package standbycontainergrouppools import ( "context" @@ -21,13 +21,12 @@ type DeleteOperationResponse struct { } // Delete ... -func (c MonitorsClient) Delete(ctx context.Context, id MonitorId) (result DeleteOperationResponse, err error) { +func (c StandbyContainerGroupPoolsClient) Delete(ctx context.Context, id StandbyContainerGroupPoolId) (result DeleteOperationResponse, err error) { opts := client.RequestOptions{ ContentType: "application/json; charset=utf-8", ExpectedStatusCodes: []int{ http.StatusAccepted, http.StatusNoContent, - http.StatusOK, }, HttpMethod: http.MethodDelete, Path: id.ID(), @@ -57,7 +56,7 @@ func (c MonitorsClient) Delete(ctx context.Context, id MonitorId) (result Delete } // DeleteThenPoll performs Delete then polls until it's completed -func (c MonitorsClient) DeleteThenPoll(ctx context.Context, id MonitorId) error { +func (c StandbyContainerGroupPoolsClient) DeleteThenPoll(ctx context.Context, id StandbyContainerGroupPoolId) error { result, err := c.Delete(ctx, id) if err != nil { return fmt.Errorf("performing Delete: %+v", err) diff --git a/resource-manager/logz/2020-10-01/subaccount/method_get.go b/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/method_get.go similarity index 77% rename from resource-manager/logz/2020-10-01/subaccount/method_get.go rename to resource-manager/standbypool/2025-03-01/standbycontainergrouppools/method_get.go index c8bce5d37b1..6e0bf66e4db 100644 --- a/resource-manager/logz/2020-10-01/subaccount/method_get.go +++ b/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/method_get.go @@ -1,4 +1,4 @@ -package subaccount +package standbycontainergrouppools import ( "context" @@ -14,11 +14,11 @@ import ( type GetOperationResponse struct { HttpResponse *http.Response OData *odata.OData - Model *LogzMonitorResource + Model *StandbyContainerGroupPoolResource } // Get ... -func (c SubAccountClient) Get(ctx context.Context, id AccountId) (result GetOperationResponse, err error) { +func (c StandbyContainerGroupPoolsClient) Get(ctx context.Context, id StandbyContainerGroupPoolId) (result GetOperationResponse, err error) { opts := client.RequestOptions{ ContentType: "application/json; charset=utf-8", ExpectedStatusCodes: []int{ @@ -43,7 +43,7 @@ func (c SubAccountClient) Get(ctx context.Context, id AccountId) (result GetOper return } - var model LogzMonitorResource + var model StandbyContainerGroupPoolResource result.Model = &model if err = resp.Unmarshal(result.Model); err != nil { return diff --git a/resource-manager/logz/2020-10-01/monitors/method_listbyresourcegroup.go b/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/method_listbyresourcegroup.go similarity index 67% rename from resource-manager/logz/2020-10-01/monitors/method_listbyresourcegroup.go rename to resource-manager/standbypool/2025-03-01/standbycontainergrouppools/method_listbyresourcegroup.go index 4487a242b99..72e7005c06d 100644 --- a/resource-manager/logz/2020-10-01/monitors/method_listbyresourcegroup.go +++ b/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/method_listbyresourcegroup.go @@ -1,4 +1,4 @@ -package monitors +package standbycontainergrouppools import ( "context" @@ -16,12 +16,12 @@ import ( type ListByResourceGroupOperationResponse struct { HttpResponse *http.Response OData *odata.OData - Model *[]LogzMonitorResource + Model *[]StandbyContainerGroupPoolResource } type ListByResourceGroupCompleteResult struct { LatestHttpResponse *http.Response - Items []LogzMonitorResource + Items []StandbyContainerGroupPoolResource } type ListByResourceGroupCustomPager struct { @@ -37,7 +37,7 @@ func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { } // ListByResourceGroup ... -func (c MonitorsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { +func (c StandbyContainerGroupPoolsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { opts := client.RequestOptions{ ContentType: "application/json; charset=utf-8", ExpectedStatusCodes: []int{ @@ -45,7 +45,7 @@ func (c MonitorsClient) ListByResourceGroup(ctx context.Context, id commonids.Re }, HttpMethod: http.MethodGet, Pager: &ListByResourceGroupCustomPager{}, - Path: fmt.Sprintf("%s/providers/Microsoft.Logz/monitors", id.ID()), + Path: fmt.Sprintf("%s/providers/Microsoft.StandbyPool/standbyContainerGroupPools", id.ID()), } req, err := c.Client.NewRequest(ctx, opts) @@ -64,7 +64,7 @@ func (c MonitorsClient) ListByResourceGroup(ctx context.Context, id commonids.Re } var values struct { - Values *[]LogzMonitorResource `json:"value"` + Values *[]StandbyContainerGroupPoolResource `json:"value"` } if err = resp.Unmarshal(&values); err != nil { return @@ -76,13 +76,13 @@ func (c MonitorsClient) ListByResourceGroup(ctx context.Context, id commonids.Re } // ListByResourceGroupComplete retrieves all the results into a single object -func (c MonitorsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { - return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, LogzMonitorResourceOperationPredicate{}) +func (c StandbyContainerGroupPoolsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, StandbyContainerGroupPoolResourceOperationPredicate{}) } // ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate -func (c MonitorsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate LogzMonitorResourceOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { - items := make([]LogzMonitorResource, 0) +func (c StandbyContainerGroupPoolsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate StandbyContainerGroupPoolResourceOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]StandbyContainerGroupPoolResource, 0) resp, err := c.ListByResourceGroup(ctx, id) if err != nil { diff --git a/resource-manager/logz/2020-10-01/monitors/method_listbysubscription.go b/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/method_listbysubscription.go similarity index 65% rename from resource-manager/logz/2020-10-01/monitors/method_listbysubscription.go rename to resource-manager/standbypool/2025-03-01/standbycontainergrouppools/method_listbysubscription.go index c22f4eb5151..e9e5d92419e 100644 --- a/resource-manager/logz/2020-10-01/monitors/method_listbysubscription.go +++ b/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/method_listbysubscription.go @@ -1,4 +1,4 @@ -package monitors +package standbycontainergrouppools import ( "context" @@ -16,12 +16,12 @@ import ( type ListBySubscriptionOperationResponse struct { HttpResponse *http.Response OData *odata.OData - Model *[]LogzMonitorResource + Model *[]StandbyContainerGroupPoolResource } type ListBySubscriptionCompleteResult struct { LatestHttpResponse *http.Response - Items []LogzMonitorResource + Items []StandbyContainerGroupPoolResource } type ListBySubscriptionCustomPager struct { @@ -37,7 +37,7 @@ func (p *ListBySubscriptionCustomPager) NextPageLink() *odata.Link { } // ListBySubscription ... -func (c MonitorsClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { +func (c StandbyContainerGroupPoolsClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { opts := client.RequestOptions{ ContentType: "application/json; charset=utf-8", ExpectedStatusCodes: []int{ @@ -45,7 +45,7 @@ func (c MonitorsClient) ListBySubscription(ctx context.Context, id commonids.Sub }, HttpMethod: http.MethodGet, Pager: &ListBySubscriptionCustomPager{}, - Path: fmt.Sprintf("%s/providers/Microsoft.Logz/monitors", id.ID()), + Path: fmt.Sprintf("%s/providers/Microsoft.StandbyPool/standbyContainerGroupPools", id.ID()), } req, err := c.Client.NewRequest(ctx, opts) @@ -64,7 +64,7 @@ func (c MonitorsClient) ListBySubscription(ctx context.Context, id commonids.Sub } var values struct { - Values *[]LogzMonitorResource `json:"value"` + Values *[]StandbyContainerGroupPoolResource `json:"value"` } if err = resp.Unmarshal(&values); err != nil { return @@ -76,13 +76,13 @@ func (c MonitorsClient) ListBySubscription(ctx context.Context, id commonids.Sub } // ListBySubscriptionComplete retrieves all the results into a single object -func (c MonitorsClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { - return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, LogzMonitorResourceOperationPredicate{}) +func (c StandbyContainerGroupPoolsClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, StandbyContainerGroupPoolResourceOperationPredicate{}) } // ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate -func (c MonitorsClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate LogzMonitorResourceOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { - items := make([]LogzMonitorResource, 0) +func (c StandbyContainerGroupPoolsClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate StandbyContainerGroupPoolResourceOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]StandbyContainerGroupPoolResource, 0) resp, err := c.ListBySubscription(ctx, id) if err != nil { diff --git a/resource-manager/logz/2020-10-01/monitors/method_update.go b/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/method_update.go similarity index 75% rename from resource-manager/logz/2020-10-01/monitors/method_update.go rename to resource-manager/standbypool/2025-03-01/standbycontainergrouppools/method_update.go index 704c04585b8..e440146bc33 100644 --- a/resource-manager/logz/2020-10-01/monitors/method_update.go +++ b/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/method_update.go @@ -1,4 +1,4 @@ -package monitors +package standbycontainergrouppools import ( "context" @@ -14,11 +14,11 @@ import ( type UpdateOperationResponse struct { HttpResponse *http.Response OData *odata.OData - Model *LogzMonitorResource + Model *StandbyContainerGroupPoolResource } // Update ... -func (c MonitorsClient) Update(ctx context.Context, id MonitorId, input LogzMonitorResourceUpdateParameters) (result UpdateOperationResponse, err error) { +func (c StandbyContainerGroupPoolsClient) Update(ctx context.Context, id StandbyContainerGroupPoolId, input StandbyContainerGroupPoolResourceUpdate) (result UpdateOperationResponse, err error) { opts := client.RequestOptions{ ContentType: "application/json; charset=utf-8", ExpectedStatusCodes: []int{ @@ -47,7 +47,7 @@ func (c MonitorsClient) Update(ctx context.Context, id MonitorId, input LogzMoni return } - var model LogzMonitorResource + var model StandbyContainerGroupPoolResource result.Model = &model if err = resp.Unmarshal(result.Model); err != nil { return diff --git a/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/model_containergroupprofile.go b/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/model_containergroupprofile.go new file mode 100644 index 00000000000..03933f8dae5 --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/model_containergroupprofile.go @@ -0,0 +1,9 @@ +package standbycontainergrouppools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerGroupProfile struct { + Id string `json:"id"` + Revision *int64 `json:"revision,omitempty"` +} diff --git a/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/model_containergroupproperties.go b/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/model_containergroupproperties.go new file mode 100644 index 00000000000..1abe6ae2a42 --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/model_containergroupproperties.go @@ -0,0 +1,9 @@ +package standbycontainergrouppools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerGroupProperties struct { + ContainerGroupProfile ContainerGroupProfile `json:"containerGroupProfile"` + SubnetIds *[]Subnet `json:"subnetIds,omitempty"` +} diff --git a/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/model_standbycontainergrouppoolelasticityprofile.go b/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/model_standbycontainergrouppoolelasticityprofile.go new file mode 100644 index 00000000000..eb8a167738d --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/model_standbycontainergrouppoolelasticityprofile.go @@ -0,0 +1,9 @@ +package standbycontainergrouppools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StandbyContainerGroupPoolElasticityProfile struct { + MaxReadyCapacity int64 `json:"maxReadyCapacity"` + RefillPolicy *RefillPolicy `json:"refillPolicy,omitempty"` +} diff --git a/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/model_standbycontainergrouppoolresource.go b/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/model_standbycontainergrouppoolresource.go new file mode 100644 index 00000000000..823f1b55647 --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/model_standbycontainergrouppoolresource.go @@ -0,0 +1,18 @@ +package standbycontainergrouppools + +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 StandbyContainerGroupPoolResource struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *StandbyContainerGroupPoolResourceProperties `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/standbypool/2025-03-01/standbycontainergrouppools/model_standbycontainergrouppoolresourceproperties.go b/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/model_standbycontainergrouppoolresourceproperties.go new file mode 100644 index 00000000000..0377e51b948 --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/model_standbycontainergrouppoolresourceproperties.go @@ -0,0 +1,15 @@ +package standbycontainergrouppools + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StandbyContainerGroupPoolResourceProperties struct { + ContainerGroupProperties ContainerGroupProperties `json:"containerGroupProperties"` + ElasticityProfile StandbyContainerGroupPoolElasticityProfile `json:"elasticityProfile"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/model_standbycontainergrouppoolresourceupdate.go b/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/model_standbycontainergrouppoolresourceupdate.go new file mode 100644 index 00000000000..58928b2b07a --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/model_standbycontainergrouppoolresourceupdate.go @@ -0,0 +1,9 @@ +package standbycontainergrouppools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StandbyContainerGroupPoolResourceUpdate struct { + Properties *StandbyContainerGroupPoolResourceUpdateProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/model_standbycontainergrouppoolresourceupdateproperties.go b/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/model_standbycontainergrouppoolresourceupdateproperties.go new file mode 100644 index 00000000000..5239a75148c --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/model_standbycontainergrouppoolresourceupdateproperties.go @@ -0,0 +1,14 @@ +package standbycontainergrouppools + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StandbyContainerGroupPoolResourceUpdateProperties struct { + ContainerGroupProperties *ContainerGroupProperties `json:"containerGroupProperties,omitempty"` + ElasticityProfile *StandbyContainerGroupPoolElasticityProfile `json:"elasticityProfile,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/logz/2020-10-01/monitors/model_userroleresponse.go b/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/model_subnet.go similarity index 64% rename from resource-manager/logz/2020-10-01/monitors/model_userroleresponse.go rename to resource-manager/standbypool/2025-03-01/standbycontainergrouppools/model_subnet.go index 3b01f8b22aa..bdf6d353cf7 100644 --- a/resource-manager/logz/2020-10-01/monitors/model_userroleresponse.go +++ b/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/model_subnet.go @@ -1,8 +1,8 @@ -package monitors +package standbycontainergrouppools // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. -type UserRoleResponse struct { - Role *UserRole `json:"role,omitempty"` +type Subnet struct { + Id string `json:"id"` } diff --git a/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/predicates.go b/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/predicates.go new file mode 100644 index 00000000000..f083c997467 --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/predicates.go @@ -0,0 +1,32 @@ +package standbycontainergrouppools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StandbyContainerGroupPoolResourceOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p StandbyContainerGroupPoolResourceOperationPredicate) Matches(input StandbyContainerGroupPoolResource) 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/standbypool/2025-03-01/standbycontainergrouppools/version.go b/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/version.go new file mode 100644 index 00000000000..adb49f3de65 --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbycontainergrouppools/version.go @@ -0,0 +1,10 @@ +package standbycontainergrouppools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-03-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/standbycontainergrouppools/2025-03-01" +} diff --git a/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/README.md b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/README.md new file mode 100644 index 00000000000..3d4e019f934 --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews` Documentation + +The `standbyvirtualmachinepoolruntimeviews` SDK allows for interaction with Azure Resource Manager `standbypool` (API Version `2025-03-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews" +``` + + +### Client Initialization + +```go +client := standbyvirtualmachinepoolruntimeviews.NewStandbyVirtualMachinePoolRuntimeViewsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `StandbyVirtualMachinePoolRuntimeViewsClient.Get` + +```go +ctx := context.TODO() +id := standbyvirtualmachinepoolruntimeviews.NewStandbyVirtualMachinePoolRuntimeViewID("12345678-1234-9876-4563-123456789012", "example-resource-group", "standbyVirtualMachinePoolName", "runtimeViewName") + +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: `StandbyVirtualMachinePoolRuntimeViewsClient.ListByStandbyPool` + +```go +ctx := context.TODO() +id := standbyvirtualmachinepoolruntimeviews.NewStandbyVirtualMachinePoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "standbyVirtualMachinePoolName") + +// alternatively `client.ListByStandbyPool(ctx, id)` can be used to do batched pagination +items, err := client.ListByStandbyPoolComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/client.go b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/client.go new file mode 100644 index 00000000000..21932432464 --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/client.go @@ -0,0 +1,26 @@ +package standbyvirtualmachinepoolruntimeviews + +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 StandbyVirtualMachinePoolRuntimeViewsClient struct { + Client *resourcemanager.Client +} + +func NewStandbyVirtualMachinePoolRuntimeViewsClientWithBaseURI(sdkApi sdkEnv.Api) (*StandbyVirtualMachinePoolRuntimeViewsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "standbyvirtualmachinepoolruntimeviews", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating StandbyVirtualMachinePoolRuntimeViewsClient: %+v", err) + } + + return &StandbyVirtualMachinePoolRuntimeViewsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/constants.go b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/constants.go new file mode 100644 index 00000000000..0631d94a7b5 --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/constants.go @@ -0,0 +1,157 @@ +package standbyvirtualmachinepoolruntimeviews + +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 HealthStateCode string + +const ( + HealthStateCodeHealthStateDegraded HealthStateCode = "HealthState/degraded" + HealthStateCodeHealthStateHealthy HealthStateCode = "HealthState/healthy" +) + +func PossibleValuesForHealthStateCode() []string { + return []string{ + string(HealthStateCodeHealthStateDegraded), + string(HealthStateCodeHealthStateHealthy), + } +} + +func (s *HealthStateCode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHealthStateCode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHealthStateCode(input string) (*HealthStateCode, error) { + vals := map[string]HealthStateCode{ + "healthstate/degraded": HealthStateCodeHealthStateDegraded, + "healthstate/healthy": HealthStateCodeHealthStateHealthy, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HealthStateCode(input) + return &out, nil +} + +type PoolVirtualMachineState string + +const ( + PoolVirtualMachineStateCreating PoolVirtualMachineState = "Creating" + PoolVirtualMachineStateDeallocated PoolVirtualMachineState = "Deallocated" + PoolVirtualMachineStateDeallocating PoolVirtualMachineState = "Deallocating" + PoolVirtualMachineStateDeleting PoolVirtualMachineState = "Deleting" + PoolVirtualMachineStateHibernated PoolVirtualMachineState = "Hibernated" + PoolVirtualMachineStateHibernating PoolVirtualMachineState = "Hibernating" + PoolVirtualMachineStateRunning PoolVirtualMachineState = "Running" + PoolVirtualMachineStateStarting PoolVirtualMachineState = "Starting" +) + +func PossibleValuesForPoolVirtualMachineState() []string { + return []string{ + string(PoolVirtualMachineStateCreating), + string(PoolVirtualMachineStateDeallocated), + string(PoolVirtualMachineStateDeallocating), + string(PoolVirtualMachineStateDeleting), + string(PoolVirtualMachineStateHibernated), + string(PoolVirtualMachineStateHibernating), + string(PoolVirtualMachineStateRunning), + string(PoolVirtualMachineStateStarting), + } +} + +func (s *PoolVirtualMachineState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePoolVirtualMachineState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePoolVirtualMachineState(input string) (*PoolVirtualMachineState, error) { + vals := map[string]PoolVirtualMachineState{ + "creating": PoolVirtualMachineStateCreating, + "deallocated": PoolVirtualMachineStateDeallocated, + "deallocating": PoolVirtualMachineStateDeallocating, + "deleting": PoolVirtualMachineStateDeleting, + "hibernated": PoolVirtualMachineStateHibernated, + "hibernating": PoolVirtualMachineStateHibernating, + "running": PoolVirtualMachineStateRunning, + "starting": PoolVirtualMachineStateStarting, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PoolVirtualMachineState(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "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/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/id_standbyvirtualmachinepool.go b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/id_standbyvirtualmachinepool.go new file mode 100644 index 00000000000..edd114dccba --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/id_standbyvirtualmachinepool.go @@ -0,0 +1,130 @@ +package standbyvirtualmachinepoolruntimeviews + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&StandbyVirtualMachinePoolId{}) +} + +var _ resourceids.ResourceId = &StandbyVirtualMachinePoolId{} + +// StandbyVirtualMachinePoolId is a struct representing the Resource ID for a Standby Virtual Machine Pool +type StandbyVirtualMachinePoolId struct { + SubscriptionId string + ResourceGroupName string + StandbyVirtualMachinePoolName string +} + +// NewStandbyVirtualMachinePoolID returns a new StandbyVirtualMachinePoolId struct +func NewStandbyVirtualMachinePoolID(subscriptionId string, resourceGroupName string, standbyVirtualMachinePoolName string) StandbyVirtualMachinePoolId { + return StandbyVirtualMachinePoolId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StandbyVirtualMachinePoolName: standbyVirtualMachinePoolName, + } +} + +// ParseStandbyVirtualMachinePoolID parses 'input' into a StandbyVirtualMachinePoolId +func ParseStandbyVirtualMachinePoolID(input string) (*StandbyVirtualMachinePoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&StandbyVirtualMachinePoolId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := StandbyVirtualMachinePoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseStandbyVirtualMachinePoolIDInsensitively parses 'input' case-insensitively into a StandbyVirtualMachinePoolId +// note: this method should only be used for API response data and not user input +func ParseStandbyVirtualMachinePoolIDInsensitively(input string) (*StandbyVirtualMachinePoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&StandbyVirtualMachinePoolId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := StandbyVirtualMachinePoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *StandbyVirtualMachinePoolId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.StandbyVirtualMachinePoolName, ok = input.Parsed["standbyVirtualMachinePoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "standbyVirtualMachinePoolName", input) + } + + return nil +} + +// ValidateStandbyVirtualMachinePoolID checks that 'input' can be parsed as a Standby Virtual Machine Pool ID +func ValidateStandbyVirtualMachinePoolID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseStandbyVirtualMachinePoolID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Standby Virtual Machine Pool ID +func (id StandbyVirtualMachinePoolId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.StandbyPool/standbyVirtualMachinePools/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StandbyVirtualMachinePoolName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Standby Virtual Machine Pool ID +func (id StandbyVirtualMachinePoolId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftStandbyPool", "Microsoft.StandbyPool", "Microsoft.StandbyPool"), + resourceids.StaticSegment("staticStandbyVirtualMachinePools", "standbyVirtualMachinePools", "standbyVirtualMachinePools"), + resourceids.UserSpecifiedSegment("standbyVirtualMachinePoolName", "standbyVirtualMachinePoolName"), + } +} + +// String returns a human-readable description of this Standby Virtual Machine Pool ID +func (id StandbyVirtualMachinePoolId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Standby Virtual Machine Pool Name: %q", id.StandbyVirtualMachinePoolName), + } + return fmt.Sprintf("Standby Virtual Machine Pool (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/id_standbyvirtualmachinepool_test.go b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/id_standbyvirtualmachinepool_test.go new file mode 100644 index 00000000000..5a7eef993c3 --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/id_standbyvirtualmachinepool_test.go @@ -0,0 +1,282 @@ +package standbyvirtualmachinepoolruntimeviews + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &StandbyVirtualMachinePoolId{} + +func TestNewStandbyVirtualMachinePoolID(t *testing.T) { + id := NewStandbyVirtualMachinePoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "standbyVirtualMachinePoolName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.StandbyVirtualMachinePoolName != "standbyVirtualMachinePoolName" { + t.Fatalf("Expected %q but got %q for Segment 'StandbyVirtualMachinePoolName'", id.StandbyVirtualMachinePoolName, "standbyVirtualMachinePoolName") + } +} + +func TestFormatStandbyVirtualMachinePoolID(t *testing.T) { + actual := NewStandbyVirtualMachinePoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "standbyVirtualMachinePoolName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyVirtualMachinePools/standbyVirtualMachinePoolName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseStandbyVirtualMachinePoolID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *StandbyVirtualMachinePoolId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyVirtualMachinePools", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyVirtualMachinePools/standbyVirtualMachinePoolName", + Expected: &StandbyVirtualMachinePoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StandbyVirtualMachinePoolName: "standbyVirtualMachinePoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyVirtualMachinePools/standbyVirtualMachinePoolName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseStandbyVirtualMachinePoolID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StandbyVirtualMachinePoolName != v.Expected.StandbyVirtualMachinePoolName { + t.Fatalf("Expected %q but got %q for StandbyVirtualMachinePoolName", v.Expected.StandbyVirtualMachinePoolName, actual.StandbyVirtualMachinePoolName) + } + + } +} + +func TestParseStandbyVirtualMachinePoolIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *StandbyVirtualMachinePoolId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sTaNdByPoOl", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyVirtualMachinePools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sTaNdByPoOl/sTaNdByViRtUaLmAcHiNePoOlS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyVirtualMachinePools/standbyVirtualMachinePoolName", + Expected: &StandbyVirtualMachinePoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StandbyVirtualMachinePoolName: "standbyVirtualMachinePoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyVirtualMachinePools/standbyVirtualMachinePoolName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sTaNdByPoOl/sTaNdByViRtUaLmAcHiNePoOlS/sTaNdByViRtUaLmAcHiNePoOlNaMe", + Expected: &StandbyVirtualMachinePoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + StandbyVirtualMachinePoolName: "sTaNdByViRtUaLmAcHiNePoOlNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sTaNdByPoOl/sTaNdByViRtUaLmAcHiNePoOlS/sTaNdByViRtUaLmAcHiNePoOlNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseStandbyVirtualMachinePoolIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StandbyVirtualMachinePoolName != v.Expected.StandbyVirtualMachinePoolName { + t.Fatalf("Expected %q but got %q for StandbyVirtualMachinePoolName", v.Expected.StandbyVirtualMachinePoolName, actual.StandbyVirtualMachinePoolName) + } + + } +} + +func TestSegmentsForStandbyVirtualMachinePoolId(t *testing.T) { + segments := StandbyVirtualMachinePoolId{}.Segments() + if len(segments) == 0 { + t.Fatalf("StandbyVirtualMachinePoolId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/id_standbyvirtualmachinepoolruntimeview.go b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/id_standbyvirtualmachinepoolruntimeview.go new file mode 100644 index 00000000000..589029778e3 --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/id_standbyvirtualmachinepoolruntimeview.go @@ -0,0 +1,139 @@ +package standbyvirtualmachinepoolruntimeviews + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&StandbyVirtualMachinePoolRuntimeViewId{}) +} + +var _ resourceids.ResourceId = &StandbyVirtualMachinePoolRuntimeViewId{} + +// StandbyVirtualMachinePoolRuntimeViewId is a struct representing the Resource ID for a Standby Virtual Machine Pool Runtime View +type StandbyVirtualMachinePoolRuntimeViewId struct { + SubscriptionId string + ResourceGroupName string + StandbyVirtualMachinePoolName string + RuntimeViewName string +} + +// NewStandbyVirtualMachinePoolRuntimeViewID returns a new StandbyVirtualMachinePoolRuntimeViewId struct +func NewStandbyVirtualMachinePoolRuntimeViewID(subscriptionId string, resourceGroupName string, standbyVirtualMachinePoolName string, runtimeViewName string) StandbyVirtualMachinePoolRuntimeViewId { + return StandbyVirtualMachinePoolRuntimeViewId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StandbyVirtualMachinePoolName: standbyVirtualMachinePoolName, + RuntimeViewName: runtimeViewName, + } +} + +// ParseStandbyVirtualMachinePoolRuntimeViewID parses 'input' into a StandbyVirtualMachinePoolRuntimeViewId +func ParseStandbyVirtualMachinePoolRuntimeViewID(input string) (*StandbyVirtualMachinePoolRuntimeViewId, error) { + parser := resourceids.NewParserFromResourceIdType(&StandbyVirtualMachinePoolRuntimeViewId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := StandbyVirtualMachinePoolRuntimeViewId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseStandbyVirtualMachinePoolRuntimeViewIDInsensitively parses 'input' case-insensitively into a StandbyVirtualMachinePoolRuntimeViewId +// note: this method should only be used for API response data and not user input +func ParseStandbyVirtualMachinePoolRuntimeViewIDInsensitively(input string) (*StandbyVirtualMachinePoolRuntimeViewId, error) { + parser := resourceids.NewParserFromResourceIdType(&StandbyVirtualMachinePoolRuntimeViewId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := StandbyVirtualMachinePoolRuntimeViewId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *StandbyVirtualMachinePoolRuntimeViewId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.StandbyVirtualMachinePoolName, ok = input.Parsed["standbyVirtualMachinePoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "standbyVirtualMachinePoolName", input) + } + + if id.RuntimeViewName, ok = input.Parsed["runtimeViewName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "runtimeViewName", input) + } + + return nil +} + +// ValidateStandbyVirtualMachinePoolRuntimeViewID checks that 'input' can be parsed as a Standby Virtual Machine Pool Runtime View ID +func ValidateStandbyVirtualMachinePoolRuntimeViewID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseStandbyVirtualMachinePoolRuntimeViewID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Standby Virtual Machine Pool Runtime View ID +func (id StandbyVirtualMachinePoolRuntimeViewId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.StandbyPool/standbyVirtualMachinePools/%s/runtimeViews/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StandbyVirtualMachinePoolName, id.RuntimeViewName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Standby Virtual Machine Pool Runtime View ID +func (id StandbyVirtualMachinePoolRuntimeViewId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftStandbyPool", "Microsoft.StandbyPool", "Microsoft.StandbyPool"), + resourceids.StaticSegment("staticStandbyVirtualMachinePools", "standbyVirtualMachinePools", "standbyVirtualMachinePools"), + resourceids.UserSpecifiedSegment("standbyVirtualMachinePoolName", "standbyVirtualMachinePoolName"), + resourceids.StaticSegment("staticRuntimeViews", "runtimeViews", "runtimeViews"), + resourceids.UserSpecifiedSegment("runtimeViewName", "runtimeViewName"), + } +} + +// String returns a human-readable description of this Standby Virtual Machine Pool Runtime View ID +func (id StandbyVirtualMachinePoolRuntimeViewId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Standby Virtual Machine Pool Name: %q", id.StandbyVirtualMachinePoolName), + fmt.Sprintf("Runtime View Name: %q", id.RuntimeViewName), + } + return fmt.Sprintf("Standby Virtual Machine Pool Runtime View (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/logz/2020-10-01/tagrules/id_account_test.go b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/id_standbyvirtualmachinepoolruntimeview_test.go similarity index 54% rename from resource-manager/logz/2020-10-01/tagrules/id_account_test.go rename to resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/id_standbyvirtualmachinepoolruntimeview_test.go index d0ff486ad34..bd0f36a6b2f 100644 --- a/resource-manager/logz/2020-10-01/tagrules/id_account_test.go +++ b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/id_standbyvirtualmachinepoolruntimeview_test.go @@ -1,4 +1,4 @@ -package tagrules +package standbyvirtualmachinepoolruntimeviews import ( "testing" @@ -9,10 +9,10 @@ import ( // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. -var _ resourceids.ResourceId = &AccountId{} +var _ resourceids.ResourceId = &StandbyVirtualMachinePoolRuntimeViewId{} -func TestNewAccountID(t *testing.T) { - id := NewAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName", "accountName") +func TestNewStandbyVirtualMachinePoolRuntimeViewID(t *testing.T) { + id := NewStandbyVirtualMachinePoolRuntimeViewID("12345678-1234-9876-4563-123456789012", "example-resource-group", "standbyVirtualMachinePoolName", "runtimeViewName") if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") @@ -22,28 +22,28 @@ func TestNewAccountID(t *testing.T) { t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") } - if id.MonitorName != "monitorName" { - t.Fatalf("Expected %q but got %q for Segment 'MonitorName'", id.MonitorName, "monitorName") + if id.StandbyVirtualMachinePoolName != "standbyVirtualMachinePoolName" { + t.Fatalf("Expected %q but got %q for Segment 'StandbyVirtualMachinePoolName'", id.StandbyVirtualMachinePoolName, "standbyVirtualMachinePoolName") } - if id.AccountName != "accountName" { - t.Fatalf("Expected %q but got %q for Segment 'AccountName'", id.AccountName, "accountName") + if id.RuntimeViewName != "runtimeViewName" { + t.Fatalf("Expected %q but got %q for Segment 'RuntimeViewName'", id.RuntimeViewName, "runtimeViewName") } } -func TestFormatAccountID(t *testing.T) { - actual := NewAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName", "accountName").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/accounts/accountName" +func TestFormatStandbyVirtualMachinePoolRuntimeViewID(t *testing.T) { + actual := NewStandbyVirtualMachinePoolRuntimeViewID("12345678-1234-9876-4563-123456789012", "example-resource-group", "standbyVirtualMachinePoolName", "runtimeViewName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyVirtualMachinePools/standbyVirtualMachinePoolName/runtimeViews/runtimeViewName" if actual != expected { t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) } } -func TestParseAccountID(t *testing.T) { +func TestParseStandbyVirtualMachinePoolRuntimeViewID(t *testing.T) { testData := []struct { Input string Error bool - Expected *AccountId + Expected *StandbyVirtualMachinePoolRuntimeViewId }{ { // Incomplete URI @@ -77,44 +77,44 @@ func TestParseAccountID(t *testing.T) { }, { // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool", Error: true, }, { // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyVirtualMachinePools", Error: true, }, { // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyVirtualMachinePools/standbyVirtualMachinePoolName", Error: true, }, { // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/accounts", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyVirtualMachinePools/standbyVirtualMachinePoolName/runtimeViews", Error: true, }, { // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/accounts/accountName", - Expected: &AccountId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - MonitorName: "monitorName", - AccountName: "accountName", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyVirtualMachinePools/standbyVirtualMachinePoolName/runtimeViews/runtimeViewName", + Expected: &StandbyVirtualMachinePoolRuntimeViewId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StandbyVirtualMachinePoolName: "standbyVirtualMachinePoolName", + RuntimeViewName: "runtimeViewName", }, }, { // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/accounts/accountName/extra", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyVirtualMachinePools/standbyVirtualMachinePoolName/runtimeViews/runtimeViewName/extra", Error: true, }, } for _, v := range testData { t.Logf("[DEBUG] Testing %q", v.Input) - actual, err := ParseAccountID(v.Input) + actual, err := ParseStandbyVirtualMachinePoolRuntimeViewID(v.Input) if err != nil { if v.Error { continue @@ -134,22 +134,22 @@ func TestParseAccountID(t *testing.T) { t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) } - if actual.MonitorName != v.Expected.MonitorName { - t.Fatalf("Expected %q but got %q for MonitorName", v.Expected.MonitorName, actual.MonitorName) + if actual.StandbyVirtualMachinePoolName != v.Expected.StandbyVirtualMachinePoolName { + t.Fatalf("Expected %q but got %q for StandbyVirtualMachinePoolName", v.Expected.StandbyVirtualMachinePoolName, actual.StandbyVirtualMachinePoolName) } - if actual.AccountName != v.Expected.AccountName { - t.Fatalf("Expected %q but got %q for AccountName", v.Expected.AccountName, actual.AccountName) + if actual.RuntimeViewName != v.Expected.RuntimeViewName { + t.Fatalf("Expected %q but got %q for RuntimeViewName", v.Expected.RuntimeViewName, actual.RuntimeViewName) } } } -func TestParseAccountIDInsensitively(t *testing.T) { +func TestParseStandbyVirtualMachinePoolRuntimeViewIDInsensitively(t *testing.T) { testData := []struct { Input string Error bool - Expected *AccountId + Expected *StandbyVirtualMachinePoolRuntimeViewId }{ { // Incomplete URI @@ -208,79 +208,79 @@ func TestParseAccountIDInsensitively(t *testing.T) { }, { // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool", Error: true, }, { // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ", + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sTaNdByPoOl", Error: true, }, { // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyVirtualMachinePools", Error: true, }, { // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ/mOnItOrS", + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sTaNdByPoOl/sTaNdByViRtUaLmAcHiNePoOlS", Error: true, }, { // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyVirtualMachinePools/standbyVirtualMachinePoolName", Error: true, }, { // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ/mOnItOrS/mOnItOrNaMe", + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sTaNdByPoOl/sTaNdByViRtUaLmAcHiNePoOlS/sTaNdByViRtUaLmAcHiNePoOlNaMe", Error: true, }, { // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/accounts", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyVirtualMachinePools/standbyVirtualMachinePoolName/runtimeViews", Error: true, }, { // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ/mOnItOrS/mOnItOrNaMe/aCcOuNtS", + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sTaNdByPoOl/sTaNdByViRtUaLmAcHiNePoOlS/sTaNdByViRtUaLmAcHiNePoOlNaMe/rUnTiMeViEwS", Error: true, }, { // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/accounts/accountName", - Expected: &AccountId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - MonitorName: "monitorName", - AccountName: "accountName", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyVirtualMachinePools/standbyVirtualMachinePoolName/runtimeViews/runtimeViewName", + Expected: &StandbyVirtualMachinePoolRuntimeViewId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StandbyVirtualMachinePoolName: "standbyVirtualMachinePoolName", + RuntimeViewName: "runtimeViewName", }, }, { // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/accounts/accountName/extra", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyVirtualMachinePools/standbyVirtualMachinePoolName/runtimeViews/runtimeViewName/extra", Error: true, }, { // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ/mOnItOrS/mOnItOrNaMe/aCcOuNtS/aCcOuNtNaMe", - Expected: &AccountId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - MonitorName: "mOnItOrNaMe", - AccountName: "aCcOuNtNaMe", + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sTaNdByPoOl/sTaNdByViRtUaLmAcHiNePoOlS/sTaNdByViRtUaLmAcHiNePoOlNaMe/rUnTiMeViEwS/rUnTiMeViEwNaMe", + Expected: &StandbyVirtualMachinePoolRuntimeViewId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + StandbyVirtualMachinePoolName: "sTaNdByViRtUaLmAcHiNePoOlNaMe", + RuntimeViewName: "rUnTiMeViEwNaMe", }, }, { // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ/mOnItOrS/mOnItOrNaMe/aCcOuNtS/aCcOuNtNaMe/extra", + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sTaNdByPoOl/sTaNdByViRtUaLmAcHiNePoOlS/sTaNdByViRtUaLmAcHiNePoOlNaMe/rUnTiMeViEwS/rUnTiMeViEwNaMe/extra", Error: true, }, } for _, v := range testData { t.Logf("[DEBUG] Testing %q", v.Input) - actual, err := ParseAccountIDInsensitively(v.Input) + actual, err := ParseStandbyVirtualMachinePoolRuntimeViewIDInsensitively(v.Input) if err != nil { if v.Error { continue @@ -300,21 +300,21 @@ func TestParseAccountIDInsensitively(t *testing.T) { t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) } - if actual.MonitorName != v.Expected.MonitorName { - t.Fatalf("Expected %q but got %q for MonitorName", v.Expected.MonitorName, actual.MonitorName) + if actual.StandbyVirtualMachinePoolName != v.Expected.StandbyVirtualMachinePoolName { + t.Fatalf("Expected %q but got %q for StandbyVirtualMachinePoolName", v.Expected.StandbyVirtualMachinePoolName, actual.StandbyVirtualMachinePoolName) } - if actual.AccountName != v.Expected.AccountName { - t.Fatalf("Expected %q but got %q for AccountName", v.Expected.AccountName, actual.AccountName) + if actual.RuntimeViewName != v.Expected.RuntimeViewName { + t.Fatalf("Expected %q but got %q for RuntimeViewName", v.Expected.RuntimeViewName, actual.RuntimeViewName) } } } -func TestSegmentsForAccountId(t *testing.T) { - segments := AccountId{}.Segments() +func TestSegmentsForStandbyVirtualMachinePoolRuntimeViewId(t *testing.T) { + segments := StandbyVirtualMachinePoolRuntimeViewId{}.Segments() if len(segments) == 0 { - t.Fatalf("AccountId has no segments") + t.Fatalf("StandbyVirtualMachinePoolRuntimeViewId has no segments") } uniqueNames := make(map[string]struct{}, 0) diff --git a/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/method_get.go b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/method_get.go new file mode 100644 index 00000000000..32ddf1067ba --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/method_get.go @@ -0,0 +1,53 @@ +package standbyvirtualmachinepoolruntimeviews + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *StandbyVirtualMachinePoolRuntimeViewResource +} + +// Get ... +func (c StandbyVirtualMachinePoolRuntimeViewsClient) Get(ctx context.Context, id StandbyVirtualMachinePoolRuntimeViewId) (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 StandbyVirtualMachinePoolRuntimeViewResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/method_listbystandbypool.go b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/method_listbystandbypool.go new file mode 100644 index 00000000000..2c208af9494 --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/method_listbystandbypool.go @@ -0,0 +1,105 @@ +package standbyvirtualmachinepoolruntimeviews + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByStandbyPoolOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StandbyVirtualMachinePoolRuntimeViewResource +} + +type ListByStandbyPoolCompleteResult struct { + LatestHttpResponse *http.Response + Items []StandbyVirtualMachinePoolRuntimeViewResource +} + +type ListByStandbyPoolCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByStandbyPoolCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByStandbyPool ... +func (c StandbyVirtualMachinePoolRuntimeViewsClient) ListByStandbyPool(ctx context.Context, id StandbyVirtualMachinePoolId) (result ListByStandbyPoolOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByStandbyPoolCustomPager{}, + Path: fmt.Sprintf("%s/runtimeViews", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]StandbyVirtualMachinePoolRuntimeViewResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByStandbyPoolComplete retrieves all the results into a single object +func (c StandbyVirtualMachinePoolRuntimeViewsClient) ListByStandbyPoolComplete(ctx context.Context, id StandbyVirtualMachinePoolId) (ListByStandbyPoolCompleteResult, error) { + return c.ListByStandbyPoolCompleteMatchingPredicate(ctx, id, StandbyVirtualMachinePoolRuntimeViewResourceOperationPredicate{}) +} + +// ListByStandbyPoolCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StandbyVirtualMachinePoolRuntimeViewsClient) ListByStandbyPoolCompleteMatchingPredicate(ctx context.Context, id StandbyVirtualMachinePoolId, predicate StandbyVirtualMachinePoolRuntimeViewResourceOperationPredicate) (result ListByStandbyPoolCompleteResult, err error) { + items := make([]StandbyVirtualMachinePoolRuntimeViewResource, 0) + + resp, err := c.ListByStandbyPool(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 = ListByStandbyPoolCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/model_poolstatus.go b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/model_poolstatus.go new file mode 100644 index 00000000000..e81e1ebc5c6 --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/model_poolstatus.go @@ -0,0 +1,9 @@ +package standbyvirtualmachinepoolruntimeviews + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PoolStatus struct { + Code HealthStateCode `json:"code"` + Message *string `json:"message,omitempty"` +} diff --git a/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/model_poolvirtualmachinestatecount.go b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/model_poolvirtualmachinestatecount.go new file mode 100644 index 00000000000..6bed85d144c --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/model_poolvirtualmachinestatecount.go @@ -0,0 +1,9 @@ +package standbyvirtualmachinepoolruntimeviews + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PoolVirtualMachineStateCount struct { + Count int64 `json:"count"` + State PoolVirtualMachineState `json:"state"` +} diff --git a/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/model_standbyvirtualmachinepoolforecastvalues.go b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/model_standbyvirtualmachinepoolforecastvalues.go new file mode 100644 index 00000000000..54efcd9f8d0 --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/model_standbyvirtualmachinepoolforecastvalues.go @@ -0,0 +1,8 @@ +package standbyvirtualmachinepoolruntimeviews + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StandbyVirtualMachinePoolForecastValues struct { + InstancesRequestedCount []int64 `json:"instancesRequestedCount"` +} diff --git a/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/model_standbyvirtualmachinepoolprediction.go b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/model_standbyvirtualmachinepoolprediction.go new file mode 100644 index 00000000000..d7aabbb4442 --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/model_standbyvirtualmachinepoolprediction.go @@ -0,0 +1,25 @@ +package standbyvirtualmachinepoolruntimeviews + +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 StandbyVirtualMachinePoolPrediction struct { + ForecastInfo string `json:"forecastInfo"` + ForecastStartTime string `json:"forecastStartTime"` + ForecastValues StandbyVirtualMachinePoolForecastValues `json:"forecastValues"` +} + +func (o *StandbyVirtualMachinePoolPrediction) GetForecastStartTimeAsTime() (*time.Time, error) { + return dates.ParseAsFormat(&o.ForecastStartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *StandbyVirtualMachinePoolPrediction) SetForecastStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ForecastStartTime = formatted +} diff --git a/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/model_standbyvirtualmachinepoolruntimeviewresource.go b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/model_standbyvirtualmachinepoolruntimeviewresource.go new file mode 100644 index 00000000000..3f39def8584 --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/model_standbyvirtualmachinepoolruntimeviewresource.go @@ -0,0 +1,16 @@ +package standbyvirtualmachinepoolruntimeviews + +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 StandbyVirtualMachinePoolRuntimeViewResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StandbyVirtualMachinePoolRuntimeViewResourceProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/model_standbyvirtualmachinepoolruntimeviewresourceproperties.go b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/model_standbyvirtualmachinepoolruntimeviewresourceproperties.go new file mode 100644 index 00000000000..b41c2b12788 --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/model_standbyvirtualmachinepoolruntimeviewresourceproperties.go @@ -0,0 +1,11 @@ +package standbyvirtualmachinepoolruntimeviews + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StandbyVirtualMachinePoolRuntimeViewResourceProperties struct { + InstanceCountSummary []VirtualMachineInstanceCountSummary `json:"instanceCountSummary"` + Prediction *StandbyVirtualMachinePoolPrediction `json:"prediction,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Status *PoolStatus `json:"status,omitempty"` +} diff --git a/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/model_virtualmachineinstancecountsummary.go b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/model_virtualmachineinstancecountsummary.go new file mode 100644 index 00000000000..07c78988ece --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/model_virtualmachineinstancecountsummary.go @@ -0,0 +1,9 @@ +package standbyvirtualmachinepoolruntimeviews + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineInstanceCountSummary struct { + InstanceCountsByState []PoolVirtualMachineStateCount `json:"instanceCountsByState"` + Zone *int64 `json:"zone,omitempty"` +} diff --git a/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/predicates.go b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/predicates.go new file mode 100644 index 00000000000..8e1645affaf --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/predicates.go @@ -0,0 +1,27 @@ +package standbyvirtualmachinepoolruntimeviews + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StandbyVirtualMachinePoolRuntimeViewResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p StandbyVirtualMachinePoolRuntimeViewResourceOperationPredicate) Matches(input StandbyVirtualMachinePoolRuntimeViewResource) 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/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/version.go b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/version.go new file mode 100644 index 00000000000..b6b530e8ad4 --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepoolruntimeviews/version.go @@ -0,0 +1,10 @@ +package standbyvirtualmachinepoolruntimeviews + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-03-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/standbyvirtualmachinepoolruntimeviews/2025-03-01" +} diff --git a/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/README.md b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/README.md new file mode 100644 index 00000000000..39048609aa4 --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/README.md @@ -0,0 +1,121 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools` Documentation + +The `standbyvirtualmachinepools` SDK allows for interaction with Azure Resource Manager `standbypool` (API Version `2025-03-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools" +``` + + +### Client Initialization + +```go +client := standbyvirtualmachinepools.NewStandbyVirtualMachinePoolsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `StandbyVirtualMachinePoolsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := standbyvirtualmachinepools.NewStandbyVirtualMachinePoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "standbyVirtualMachinePoolName") + +payload := standbyvirtualmachinepools.StandbyVirtualMachinePoolResource{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `StandbyVirtualMachinePoolsClient.Delete` + +```go +ctx := context.TODO() +id := standbyvirtualmachinepools.NewStandbyVirtualMachinePoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "standbyVirtualMachinePoolName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `StandbyVirtualMachinePoolsClient.Get` + +```go +ctx := context.TODO() +id := standbyvirtualmachinepools.NewStandbyVirtualMachinePoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "standbyVirtualMachinePoolName") + +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: `StandbyVirtualMachinePoolsClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StandbyVirtualMachinePoolsClient.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: `StandbyVirtualMachinePoolsClient.Update` + +```go +ctx := context.TODO() +id := standbyvirtualmachinepools.NewStandbyVirtualMachinePoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "standbyVirtualMachinePoolName") + +payload := standbyvirtualmachinepools.StandbyVirtualMachinePoolResourceUpdate{ + // ... +} + + +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/standbypool/2025-03-01/standbyvirtualmachinepools/client.go b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/client.go new file mode 100644 index 00000000000..5cc450073f3 --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/client.go @@ -0,0 +1,26 @@ +package standbyvirtualmachinepools + +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 StandbyVirtualMachinePoolsClient struct { + Client *resourcemanager.Client +} + +func NewStandbyVirtualMachinePoolsClientWithBaseURI(sdkApi sdkEnv.Api) (*StandbyVirtualMachinePoolsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "standbyvirtualmachinepools", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating StandbyVirtualMachinePoolsClient: %+v", err) + } + + return &StandbyVirtualMachinePoolsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/constants.go b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/constants.go new file mode 100644 index 00000000000..fa12dcbad79 --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/constants.go @@ -0,0 +1,101 @@ +package standbyvirtualmachinepools + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type VirtualMachineState string + +const ( + VirtualMachineStateDeallocated VirtualMachineState = "Deallocated" + VirtualMachineStateHibernated VirtualMachineState = "Hibernated" + VirtualMachineStateRunning VirtualMachineState = "Running" +) + +func PossibleValuesForVirtualMachineState() []string { + return []string{ + string(VirtualMachineStateDeallocated), + string(VirtualMachineStateHibernated), + string(VirtualMachineStateRunning), + } +} + +func (s *VirtualMachineState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualMachineState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualMachineState(input string) (*VirtualMachineState, error) { + vals := map[string]VirtualMachineState{ + "deallocated": VirtualMachineStateDeallocated, + "hibernated": VirtualMachineStateHibernated, + "running": VirtualMachineStateRunning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualMachineState(input) + return &out, nil +} diff --git a/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/id_standbyvirtualmachinepool.go b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/id_standbyvirtualmachinepool.go new file mode 100644 index 00000000000..21ce39183a9 --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/id_standbyvirtualmachinepool.go @@ -0,0 +1,130 @@ +package standbyvirtualmachinepools + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&StandbyVirtualMachinePoolId{}) +} + +var _ resourceids.ResourceId = &StandbyVirtualMachinePoolId{} + +// StandbyVirtualMachinePoolId is a struct representing the Resource ID for a Standby Virtual Machine Pool +type StandbyVirtualMachinePoolId struct { + SubscriptionId string + ResourceGroupName string + StandbyVirtualMachinePoolName string +} + +// NewStandbyVirtualMachinePoolID returns a new StandbyVirtualMachinePoolId struct +func NewStandbyVirtualMachinePoolID(subscriptionId string, resourceGroupName string, standbyVirtualMachinePoolName string) StandbyVirtualMachinePoolId { + return StandbyVirtualMachinePoolId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StandbyVirtualMachinePoolName: standbyVirtualMachinePoolName, + } +} + +// ParseStandbyVirtualMachinePoolID parses 'input' into a StandbyVirtualMachinePoolId +func ParseStandbyVirtualMachinePoolID(input string) (*StandbyVirtualMachinePoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&StandbyVirtualMachinePoolId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := StandbyVirtualMachinePoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseStandbyVirtualMachinePoolIDInsensitively parses 'input' case-insensitively into a StandbyVirtualMachinePoolId +// note: this method should only be used for API response data and not user input +func ParseStandbyVirtualMachinePoolIDInsensitively(input string) (*StandbyVirtualMachinePoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&StandbyVirtualMachinePoolId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := StandbyVirtualMachinePoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *StandbyVirtualMachinePoolId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.StandbyVirtualMachinePoolName, ok = input.Parsed["standbyVirtualMachinePoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "standbyVirtualMachinePoolName", input) + } + + return nil +} + +// ValidateStandbyVirtualMachinePoolID checks that 'input' can be parsed as a Standby Virtual Machine Pool ID +func ValidateStandbyVirtualMachinePoolID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseStandbyVirtualMachinePoolID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Standby Virtual Machine Pool ID +func (id StandbyVirtualMachinePoolId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.StandbyPool/standbyVirtualMachinePools/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StandbyVirtualMachinePoolName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Standby Virtual Machine Pool ID +func (id StandbyVirtualMachinePoolId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftStandbyPool", "Microsoft.StandbyPool", "Microsoft.StandbyPool"), + resourceids.StaticSegment("staticStandbyVirtualMachinePools", "standbyVirtualMachinePools", "standbyVirtualMachinePools"), + resourceids.UserSpecifiedSegment("standbyVirtualMachinePoolName", "standbyVirtualMachinePoolName"), + } +} + +// String returns a human-readable description of this Standby Virtual Machine Pool ID +func (id StandbyVirtualMachinePoolId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Standby Virtual Machine Pool Name: %q", id.StandbyVirtualMachinePoolName), + } + return fmt.Sprintf("Standby Virtual Machine Pool (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/id_standbyvirtualmachinepool_test.go b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/id_standbyvirtualmachinepool_test.go new file mode 100644 index 00000000000..1c56a7516be --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/id_standbyvirtualmachinepool_test.go @@ -0,0 +1,282 @@ +package standbyvirtualmachinepools + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &StandbyVirtualMachinePoolId{} + +func TestNewStandbyVirtualMachinePoolID(t *testing.T) { + id := NewStandbyVirtualMachinePoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "standbyVirtualMachinePoolName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.StandbyVirtualMachinePoolName != "standbyVirtualMachinePoolName" { + t.Fatalf("Expected %q but got %q for Segment 'StandbyVirtualMachinePoolName'", id.StandbyVirtualMachinePoolName, "standbyVirtualMachinePoolName") + } +} + +func TestFormatStandbyVirtualMachinePoolID(t *testing.T) { + actual := NewStandbyVirtualMachinePoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "standbyVirtualMachinePoolName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyVirtualMachinePools/standbyVirtualMachinePoolName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseStandbyVirtualMachinePoolID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *StandbyVirtualMachinePoolId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyVirtualMachinePools", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyVirtualMachinePools/standbyVirtualMachinePoolName", + Expected: &StandbyVirtualMachinePoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StandbyVirtualMachinePoolName: "standbyVirtualMachinePoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyVirtualMachinePools/standbyVirtualMachinePoolName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseStandbyVirtualMachinePoolID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StandbyVirtualMachinePoolName != v.Expected.StandbyVirtualMachinePoolName { + t.Fatalf("Expected %q but got %q for StandbyVirtualMachinePoolName", v.Expected.StandbyVirtualMachinePoolName, actual.StandbyVirtualMachinePoolName) + } + + } +} + +func TestParseStandbyVirtualMachinePoolIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *StandbyVirtualMachinePoolId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sTaNdByPoOl", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyVirtualMachinePools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sTaNdByPoOl/sTaNdByViRtUaLmAcHiNePoOlS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyVirtualMachinePools/standbyVirtualMachinePoolName", + Expected: &StandbyVirtualMachinePoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StandbyVirtualMachinePoolName: "standbyVirtualMachinePoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyVirtualMachinePools/standbyVirtualMachinePoolName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sTaNdByPoOl/sTaNdByViRtUaLmAcHiNePoOlS/sTaNdByViRtUaLmAcHiNePoOlNaMe", + Expected: &StandbyVirtualMachinePoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + StandbyVirtualMachinePoolName: "sTaNdByViRtUaLmAcHiNePoOlNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sTaNdByPoOl/sTaNdByViRtUaLmAcHiNePoOlS/sTaNdByViRtUaLmAcHiNePoOlNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseStandbyVirtualMachinePoolIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StandbyVirtualMachinePoolName != v.Expected.StandbyVirtualMachinePoolName { + t.Fatalf("Expected %q but got %q for StandbyVirtualMachinePoolName", v.Expected.StandbyVirtualMachinePoolName, actual.StandbyVirtualMachinePoolName) + } + + } +} + +func TestSegmentsForStandbyVirtualMachinePoolId(t *testing.T) { + segments := StandbyVirtualMachinePoolId{}.Segments() + if len(segments) == 0 { + t.Fatalf("StandbyVirtualMachinePoolId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/logz/2020-10-01/subaccount/method_create.go b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/method_createorupdate.go similarity index 62% rename from resource-manager/logz/2020-10-01/subaccount/method_create.go rename to resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/method_createorupdate.go index 985e102e3af..95f8487d7f9 100644 --- a/resource-manager/logz/2020-10-01/subaccount/method_create.go +++ b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/method_createorupdate.go @@ -1,4 +1,4 @@ -package subaccount +package standbyvirtualmachinepools import ( "context" @@ -14,15 +14,15 @@ import ( // 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 { +type CreateOrUpdateOperationResponse struct { Poller pollers.Poller HttpResponse *http.Response OData *odata.OData - Model *LogzMonitorResource + Model *StandbyVirtualMachinePoolResource } -// Create ... -func (c SubAccountClient) Create(ctx context.Context, id AccountId, input LogzMonitorResource) (result CreateOperationResponse, err error) { +// CreateOrUpdate ... +func (c StandbyVirtualMachinePoolsClient) CreateOrUpdate(ctx context.Context, id StandbyVirtualMachinePoolId, input StandbyVirtualMachinePoolResource) (result CreateOrUpdateOperationResponse, err error) { opts := client.RequestOptions{ ContentType: "application/json; charset=utf-8", ExpectedStatusCodes: []int{ @@ -60,15 +60,15 @@ func (c SubAccountClient) Create(ctx context.Context, id AccountId, input LogzMo return } -// CreateThenPoll performs Create then polls until it's completed -func (c SubAccountClient) CreateThenPoll(ctx context.Context, id AccountId, input LogzMonitorResource) error { - result, err := c.Create(ctx, id, input) +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c StandbyVirtualMachinePoolsClient) CreateOrUpdateThenPoll(ctx context.Context, id StandbyVirtualMachinePoolId, input StandbyVirtualMachinePoolResource) error { + result, err := c.CreateOrUpdate(ctx, id, input) if err != nil { - return fmt.Errorf("performing Create: %+v", err) + return fmt.Errorf("performing CreateOrUpdate: %+v", err) } if err := result.Poller.PollUntilDone(ctx); err != nil { - return fmt.Errorf("polling after Create: %+v", err) + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) } return nil diff --git a/resource-manager/logz/2020-10-01/subaccount/method_delete.go b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/method_delete.go similarity index 82% rename from resource-manager/logz/2020-10-01/subaccount/method_delete.go rename to resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/method_delete.go index 884cb2dcaaa..2166eb6c1d1 100644 --- a/resource-manager/logz/2020-10-01/subaccount/method_delete.go +++ b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/method_delete.go @@ -1,4 +1,4 @@ -package subaccount +package standbyvirtualmachinepools import ( "context" @@ -21,13 +21,12 @@ type DeleteOperationResponse struct { } // Delete ... -func (c SubAccountClient) Delete(ctx context.Context, id AccountId) (result DeleteOperationResponse, err error) { +func (c StandbyVirtualMachinePoolsClient) Delete(ctx context.Context, id StandbyVirtualMachinePoolId) (result DeleteOperationResponse, err error) { opts := client.RequestOptions{ ContentType: "application/json; charset=utf-8", ExpectedStatusCodes: []int{ http.StatusAccepted, http.StatusNoContent, - http.StatusOK, }, HttpMethod: http.MethodDelete, Path: id.ID(), @@ -57,7 +56,7 @@ func (c SubAccountClient) Delete(ctx context.Context, id AccountId) (result Dele } // DeleteThenPoll performs Delete then polls until it's completed -func (c SubAccountClient) DeleteThenPoll(ctx context.Context, id AccountId) error { +func (c StandbyVirtualMachinePoolsClient) DeleteThenPoll(ctx context.Context, id StandbyVirtualMachinePoolId) error { result, err := c.Delete(ctx, id) if err != nil { return fmt.Errorf("performing Delete: %+v", err) diff --git a/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/method_get.go b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/method_get.go new file mode 100644 index 00000000000..f0c6e16ef01 --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/method_get.go @@ -0,0 +1,53 @@ +package standbyvirtualmachinepools + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *StandbyVirtualMachinePoolResource +} + +// Get ... +func (c StandbyVirtualMachinePoolsClient) Get(ctx context.Context, id StandbyVirtualMachinePoolId) (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 StandbyVirtualMachinePoolResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/method_listbyresourcegroup.go b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/method_listbyresourcegroup.go new file mode 100644 index 00000000000..18ac9c91c83 --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package standbyvirtualmachinepools + +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 *[]StandbyVirtualMachinePoolResource +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []StandbyVirtualMachinePoolResource +} + +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 StandbyVirtualMachinePoolsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.StandbyPool/standbyVirtualMachinePools", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]StandbyVirtualMachinePoolResource `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 StandbyVirtualMachinePoolsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, StandbyVirtualMachinePoolResourceOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StandbyVirtualMachinePoolsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate StandbyVirtualMachinePoolResourceOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]StandbyVirtualMachinePoolResource, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/method_listbysubscription.go b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/method_listbysubscription.go new file mode 100644 index 00000000000..18859d5e0e2 --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/method_listbysubscription.go @@ -0,0 +1,106 @@ +package standbyvirtualmachinepools + +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 *[]StandbyVirtualMachinePoolResource +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []StandbyVirtualMachinePoolResource +} + +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 StandbyVirtualMachinePoolsClient) 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.StandbyPool/standbyVirtualMachinePools", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]StandbyVirtualMachinePoolResource `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 StandbyVirtualMachinePoolsClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, StandbyVirtualMachinePoolResourceOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StandbyVirtualMachinePoolsClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate StandbyVirtualMachinePoolResourceOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]StandbyVirtualMachinePoolResource, 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/standbypool/2025-03-01/standbyvirtualmachinepools/method_update.go b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/method_update.go new file mode 100644 index 00000000000..b4d470798de --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/method_update.go @@ -0,0 +1,57 @@ +package standbyvirtualmachinepools + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *StandbyVirtualMachinePoolResource +} + +// Update ... +func (c StandbyVirtualMachinePoolsClient) Update(ctx context.Context, id StandbyVirtualMachinePoolId, input StandbyVirtualMachinePoolResourceUpdate) (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 StandbyVirtualMachinePoolResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/model_standbyvirtualmachinepoolelasticityprofile.go b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/model_standbyvirtualmachinepoolelasticityprofile.go new file mode 100644 index 00000000000..9214ec79b5f --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/model_standbyvirtualmachinepoolelasticityprofile.go @@ -0,0 +1,9 @@ +package standbyvirtualmachinepools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StandbyVirtualMachinePoolElasticityProfile struct { + MaxReadyCapacity int64 `json:"maxReadyCapacity"` + MinReadyCapacity *int64 `json:"minReadyCapacity,omitempty"` +} diff --git a/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/model_standbyvirtualmachinepoolresource.go b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/model_standbyvirtualmachinepoolresource.go new file mode 100644 index 00000000000..f7126f48397 --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/model_standbyvirtualmachinepoolresource.go @@ -0,0 +1,18 @@ +package standbyvirtualmachinepools + +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 StandbyVirtualMachinePoolResource struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *StandbyVirtualMachinePoolResourceProperties `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/standbypool/2025-03-01/standbyvirtualmachinepools/model_standbyvirtualmachinepoolresourceproperties.go b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/model_standbyvirtualmachinepoolresourceproperties.go new file mode 100644 index 00000000000..4ae4ea48f7e --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/model_standbyvirtualmachinepoolresourceproperties.go @@ -0,0 +1,11 @@ +package standbyvirtualmachinepools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StandbyVirtualMachinePoolResourceProperties struct { + AttachedVirtualMachineScaleSetId *string `json:"attachedVirtualMachineScaleSetId,omitempty"` + ElasticityProfile *StandbyVirtualMachinePoolElasticityProfile `json:"elasticityProfile,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + VirtualMachineState VirtualMachineState `json:"virtualMachineState"` +} diff --git a/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/model_standbyvirtualmachinepoolresourceupdate.go b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/model_standbyvirtualmachinepoolresourceupdate.go new file mode 100644 index 00000000000..dc5d7c116c9 --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/model_standbyvirtualmachinepoolresourceupdate.go @@ -0,0 +1,9 @@ +package standbyvirtualmachinepools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StandbyVirtualMachinePoolResourceUpdate struct { + Properties *StandbyVirtualMachinePoolResourceUpdateProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/model_standbyvirtualmachinepoolresourceupdateproperties.go b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/model_standbyvirtualmachinepoolresourceupdateproperties.go new file mode 100644 index 00000000000..1f535491838 --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/model_standbyvirtualmachinepoolresourceupdateproperties.go @@ -0,0 +1,10 @@ +package standbyvirtualmachinepools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StandbyVirtualMachinePoolResourceUpdateProperties struct { + AttachedVirtualMachineScaleSetId *string `json:"attachedVirtualMachineScaleSetId,omitempty"` + ElasticityProfile *StandbyVirtualMachinePoolElasticityProfile `json:"elasticityProfile,omitempty"` + VirtualMachineState *VirtualMachineState `json:"virtualMachineState,omitempty"` +} diff --git a/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/predicates.go b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/predicates.go new file mode 100644 index 00000000000..3ada540e573 --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/predicates.go @@ -0,0 +1,32 @@ +package standbyvirtualmachinepools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StandbyVirtualMachinePoolResourceOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p StandbyVirtualMachinePoolResourceOperationPredicate) Matches(input StandbyVirtualMachinePoolResource) 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/standbypool/2025-03-01/standbyvirtualmachinepools/version.go b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/version.go new file mode 100644 index 00000000000..fcacdc43fdc --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbyvirtualmachinepools/version.go @@ -0,0 +1,10 @@ +package standbyvirtualmachinepools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-03-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/standbyvirtualmachinepools/2025-03-01" +} diff --git a/resource-manager/standbypool/2025-03-01/standbyvirtualmachines/README.md b/resource-manager/standbypool/2025-03-01/standbyvirtualmachines/README.md new file mode 100644 index 00000000000..0ef3f26f32f --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbyvirtualmachines/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/standbypool/2025-03-01/standbyvirtualmachines` Documentation + +The `standbyvirtualmachines` SDK allows for interaction with Azure Resource Manager `standbypool` (API Version `2025-03-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/standbypool/2025-03-01/standbyvirtualmachines" +``` + + +### Client Initialization + +```go +client := standbyvirtualmachines.NewStandbyVirtualMachinesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `StandbyVirtualMachinesClient.Get` + +```go +ctx := context.TODO() +id := standbyvirtualmachines.NewStandbyVirtualMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "standbyVirtualMachinePoolName", "standbyVirtualMachineName") + +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: `StandbyVirtualMachinesClient.ListByStandbyVirtualMachinePoolResource` + +```go +ctx := context.TODO() +id := standbyvirtualmachines.NewStandbyVirtualMachinePoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "standbyVirtualMachinePoolName") + +// alternatively `client.ListByStandbyVirtualMachinePoolResource(ctx, id)` can be used to do batched pagination +items, err := client.ListByStandbyVirtualMachinePoolResourceComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/standbypool/2025-03-01/standbyvirtualmachines/client.go b/resource-manager/standbypool/2025-03-01/standbyvirtualmachines/client.go new file mode 100644 index 00000000000..967c173b53e --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbyvirtualmachines/client.go @@ -0,0 +1,26 @@ +package standbyvirtualmachines + +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 StandbyVirtualMachinesClient struct { + Client *resourcemanager.Client +} + +func NewStandbyVirtualMachinesClientWithBaseURI(sdkApi sdkEnv.Api) (*StandbyVirtualMachinesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "standbyvirtualmachines", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating StandbyVirtualMachinesClient: %+v", err) + } + + return &StandbyVirtualMachinesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/standbypool/2025-03-01/standbyvirtualmachines/constants.go b/resource-manager/standbypool/2025-03-01/standbyvirtualmachines/constants.go new file mode 100644 index 00000000000..6f95f23b354 --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbyvirtualmachines/constants.go @@ -0,0 +1,57 @@ +package standbyvirtualmachines + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "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/standbypool/2025-03-01/standbyvirtualmachines/id_standbyvirtualmachine.go b/resource-manager/standbypool/2025-03-01/standbyvirtualmachines/id_standbyvirtualmachine.go new file mode 100644 index 00000000000..0efe13707ad --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbyvirtualmachines/id_standbyvirtualmachine.go @@ -0,0 +1,139 @@ +package standbyvirtualmachines + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&StandbyVirtualMachineId{}) +} + +var _ resourceids.ResourceId = &StandbyVirtualMachineId{} + +// StandbyVirtualMachineId is a struct representing the Resource ID for a Standby Virtual Machine +type StandbyVirtualMachineId struct { + SubscriptionId string + ResourceGroupName string + StandbyVirtualMachinePoolName string + StandbyVirtualMachineName string +} + +// NewStandbyVirtualMachineID returns a new StandbyVirtualMachineId struct +func NewStandbyVirtualMachineID(subscriptionId string, resourceGroupName string, standbyVirtualMachinePoolName string, standbyVirtualMachineName string) StandbyVirtualMachineId { + return StandbyVirtualMachineId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StandbyVirtualMachinePoolName: standbyVirtualMachinePoolName, + StandbyVirtualMachineName: standbyVirtualMachineName, + } +} + +// ParseStandbyVirtualMachineID parses 'input' into a StandbyVirtualMachineId +func ParseStandbyVirtualMachineID(input string) (*StandbyVirtualMachineId, error) { + parser := resourceids.NewParserFromResourceIdType(&StandbyVirtualMachineId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := StandbyVirtualMachineId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseStandbyVirtualMachineIDInsensitively parses 'input' case-insensitively into a StandbyVirtualMachineId +// note: this method should only be used for API response data and not user input +func ParseStandbyVirtualMachineIDInsensitively(input string) (*StandbyVirtualMachineId, error) { + parser := resourceids.NewParserFromResourceIdType(&StandbyVirtualMachineId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := StandbyVirtualMachineId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *StandbyVirtualMachineId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.StandbyVirtualMachinePoolName, ok = input.Parsed["standbyVirtualMachinePoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "standbyVirtualMachinePoolName", input) + } + + if id.StandbyVirtualMachineName, ok = input.Parsed["standbyVirtualMachineName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "standbyVirtualMachineName", input) + } + + return nil +} + +// ValidateStandbyVirtualMachineID checks that 'input' can be parsed as a Standby Virtual Machine ID +func ValidateStandbyVirtualMachineID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseStandbyVirtualMachineID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Standby Virtual Machine ID +func (id StandbyVirtualMachineId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.StandbyPool/standbyVirtualMachinePools/%s/standbyVirtualMachines/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StandbyVirtualMachinePoolName, id.StandbyVirtualMachineName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Standby Virtual Machine ID +func (id StandbyVirtualMachineId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftStandbyPool", "Microsoft.StandbyPool", "Microsoft.StandbyPool"), + resourceids.StaticSegment("staticStandbyVirtualMachinePools", "standbyVirtualMachinePools", "standbyVirtualMachinePools"), + resourceids.UserSpecifiedSegment("standbyVirtualMachinePoolName", "standbyVirtualMachinePoolName"), + resourceids.StaticSegment("staticStandbyVirtualMachines", "standbyVirtualMachines", "standbyVirtualMachines"), + resourceids.UserSpecifiedSegment("standbyVirtualMachineName", "standbyVirtualMachineName"), + } +} + +// String returns a human-readable description of this Standby Virtual Machine ID +func (id StandbyVirtualMachineId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Standby Virtual Machine Pool Name: %q", id.StandbyVirtualMachinePoolName), + fmt.Sprintf("Standby Virtual Machine Name: %q", id.StandbyVirtualMachineName), + } + return fmt.Sprintf("Standby Virtual Machine (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/logz/2020-10-01/tagrules/id_tagrule_test.go b/resource-manager/standbypool/2025-03-01/standbyvirtualmachines/id_standbyvirtualmachine_test.go similarity index 54% rename from resource-manager/logz/2020-10-01/tagrules/id_tagrule_test.go rename to resource-manager/standbypool/2025-03-01/standbyvirtualmachines/id_standbyvirtualmachine_test.go index 24ad4c79ca0..8f0a3df7e70 100644 --- a/resource-manager/logz/2020-10-01/tagrules/id_tagrule_test.go +++ b/resource-manager/standbypool/2025-03-01/standbyvirtualmachines/id_standbyvirtualmachine_test.go @@ -1,4 +1,4 @@ -package tagrules +package standbyvirtualmachines import ( "testing" @@ -9,10 +9,10 @@ import ( // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. -var _ resourceids.ResourceId = &TagRuleId{} +var _ resourceids.ResourceId = &StandbyVirtualMachineId{} -func TestNewTagRuleID(t *testing.T) { - id := NewTagRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName", "tagRuleName") +func TestNewStandbyVirtualMachineID(t *testing.T) { + id := NewStandbyVirtualMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "standbyVirtualMachinePoolName", "standbyVirtualMachineName") if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") @@ -22,28 +22,28 @@ func TestNewTagRuleID(t *testing.T) { t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") } - if id.MonitorName != "monitorName" { - t.Fatalf("Expected %q but got %q for Segment 'MonitorName'", id.MonitorName, "monitorName") + if id.StandbyVirtualMachinePoolName != "standbyVirtualMachinePoolName" { + t.Fatalf("Expected %q but got %q for Segment 'StandbyVirtualMachinePoolName'", id.StandbyVirtualMachinePoolName, "standbyVirtualMachinePoolName") } - if id.TagRuleName != "tagRuleName" { - t.Fatalf("Expected %q but got %q for Segment 'TagRuleName'", id.TagRuleName, "tagRuleName") + if id.StandbyVirtualMachineName != "standbyVirtualMachineName" { + t.Fatalf("Expected %q but got %q for Segment 'StandbyVirtualMachineName'", id.StandbyVirtualMachineName, "standbyVirtualMachineName") } } -func TestFormatTagRuleID(t *testing.T) { - actual := NewTagRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName", "tagRuleName").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/tagRules/tagRuleName" +func TestFormatStandbyVirtualMachineID(t *testing.T) { + actual := NewStandbyVirtualMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "standbyVirtualMachinePoolName", "standbyVirtualMachineName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyVirtualMachinePools/standbyVirtualMachinePoolName/standbyVirtualMachines/standbyVirtualMachineName" if actual != expected { t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) } } -func TestParseTagRuleID(t *testing.T) { +func TestParseStandbyVirtualMachineID(t *testing.T) { testData := []struct { Input string Error bool - Expected *TagRuleId + Expected *StandbyVirtualMachineId }{ { // Incomplete URI @@ -77,44 +77,44 @@ func TestParseTagRuleID(t *testing.T) { }, { // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool", Error: true, }, { // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyVirtualMachinePools", Error: true, }, { // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyVirtualMachinePools/standbyVirtualMachinePoolName", Error: true, }, { // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/tagRules", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyVirtualMachinePools/standbyVirtualMachinePoolName/standbyVirtualMachines", Error: true, }, { // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/tagRules/tagRuleName", - Expected: &TagRuleId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - MonitorName: "monitorName", - TagRuleName: "tagRuleName", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyVirtualMachinePools/standbyVirtualMachinePoolName/standbyVirtualMachines/standbyVirtualMachineName", + Expected: &StandbyVirtualMachineId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StandbyVirtualMachinePoolName: "standbyVirtualMachinePoolName", + StandbyVirtualMachineName: "standbyVirtualMachineName", }, }, { // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/tagRules/tagRuleName/extra", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyVirtualMachinePools/standbyVirtualMachinePoolName/standbyVirtualMachines/standbyVirtualMachineName/extra", Error: true, }, } for _, v := range testData { t.Logf("[DEBUG] Testing %q", v.Input) - actual, err := ParseTagRuleID(v.Input) + actual, err := ParseStandbyVirtualMachineID(v.Input) if err != nil { if v.Error { continue @@ -134,22 +134,22 @@ func TestParseTagRuleID(t *testing.T) { t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) } - if actual.MonitorName != v.Expected.MonitorName { - t.Fatalf("Expected %q but got %q for MonitorName", v.Expected.MonitorName, actual.MonitorName) + if actual.StandbyVirtualMachinePoolName != v.Expected.StandbyVirtualMachinePoolName { + t.Fatalf("Expected %q but got %q for StandbyVirtualMachinePoolName", v.Expected.StandbyVirtualMachinePoolName, actual.StandbyVirtualMachinePoolName) } - if actual.TagRuleName != v.Expected.TagRuleName { - t.Fatalf("Expected %q but got %q for TagRuleName", v.Expected.TagRuleName, actual.TagRuleName) + if actual.StandbyVirtualMachineName != v.Expected.StandbyVirtualMachineName { + t.Fatalf("Expected %q but got %q for StandbyVirtualMachineName", v.Expected.StandbyVirtualMachineName, actual.StandbyVirtualMachineName) } } } -func TestParseTagRuleIDInsensitively(t *testing.T) { +func TestParseStandbyVirtualMachineIDInsensitively(t *testing.T) { testData := []struct { Input string Error bool - Expected *TagRuleId + Expected *StandbyVirtualMachineId }{ { // Incomplete URI @@ -208,79 +208,79 @@ func TestParseTagRuleIDInsensitively(t *testing.T) { }, { // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool", Error: true, }, { // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ", + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sTaNdByPoOl", Error: true, }, { // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyVirtualMachinePools", Error: true, }, { // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ/mOnItOrS", + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sTaNdByPoOl/sTaNdByViRtUaLmAcHiNePoOlS", Error: true, }, { // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyVirtualMachinePools/standbyVirtualMachinePoolName", Error: true, }, { // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ/mOnItOrS/mOnItOrNaMe", + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sTaNdByPoOl/sTaNdByViRtUaLmAcHiNePoOlS/sTaNdByViRtUaLmAcHiNePoOlNaMe", Error: true, }, { // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/tagRules", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyVirtualMachinePools/standbyVirtualMachinePoolName/standbyVirtualMachines", Error: true, }, { // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ/mOnItOrS/mOnItOrNaMe/tAgRuLeS", + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sTaNdByPoOl/sTaNdByViRtUaLmAcHiNePoOlS/sTaNdByViRtUaLmAcHiNePoOlNaMe/sTaNdByViRtUaLmAcHiNeS", Error: true, }, { // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/tagRules/tagRuleName", - Expected: &TagRuleId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - MonitorName: "monitorName", - TagRuleName: "tagRuleName", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyVirtualMachinePools/standbyVirtualMachinePoolName/standbyVirtualMachines/standbyVirtualMachineName", + Expected: &StandbyVirtualMachineId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StandbyVirtualMachinePoolName: "standbyVirtualMachinePoolName", + StandbyVirtualMachineName: "standbyVirtualMachineName", }, }, { // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/tagRules/tagRuleName/extra", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyVirtualMachinePools/standbyVirtualMachinePoolName/standbyVirtualMachines/standbyVirtualMachineName/extra", Error: true, }, { // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ/mOnItOrS/mOnItOrNaMe/tAgRuLeS/tAgRuLeNaMe", - Expected: &TagRuleId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - MonitorName: "mOnItOrNaMe", - TagRuleName: "tAgRuLeNaMe", + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sTaNdByPoOl/sTaNdByViRtUaLmAcHiNePoOlS/sTaNdByViRtUaLmAcHiNePoOlNaMe/sTaNdByViRtUaLmAcHiNeS/sTaNdByViRtUaLmAcHiNeNaMe", + Expected: &StandbyVirtualMachineId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + StandbyVirtualMachinePoolName: "sTaNdByViRtUaLmAcHiNePoOlNaMe", + StandbyVirtualMachineName: "sTaNdByViRtUaLmAcHiNeNaMe", }, }, { // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ/mOnItOrS/mOnItOrNaMe/tAgRuLeS/tAgRuLeNaMe/extra", + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sTaNdByPoOl/sTaNdByViRtUaLmAcHiNePoOlS/sTaNdByViRtUaLmAcHiNePoOlNaMe/sTaNdByViRtUaLmAcHiNeS/sTaNdByViRtUaLmAcHiNeNaMe/extra", Error: true, }, } for _, v := range testData { t.Logf("[DEBUG] Testing %q", v.Input) - actual, err := ParseTagRuleIDInsensitively(v.Input) + actual, err := ParseStandbyVirtualMachineIDInsensitively(v.Input) if err != nil { if v.Error { continue @@ -300,21 +300,21 @@ func TestParseTagRuleIDInsensitively(t *testing.T) { t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) } - if actual.MonitorName != v.Expected.MonitorName { - t.Fatalf("Expected %q but got %q for MonitorName", v.Expected.MonitorName, actual.MonitorName) + if actual.StandbyVirtualMachinePoolName != v.Expected.StandbyVirtualMachinePoolName { + t.Fatalf("Expected %q but got %q for StandbyVirtualMachinePoolName", v.Expected.StandbyVirtualMachinePoolName, actual.StandbyVirtualMachinePoolName) } - if actual.TagRuleName != v.Expected.TagRuleName { - t.Fatalf("Expected %q but got %q for TagRuleName", v.Expected.TagRuleName, actual.TagRuleName) + if actual.StandbyVirtualMachineName != v.Expected.StandbyVirtualMachineName { + t.Fatalf("Expected %q but got %q for StandbyVirtualMachineName", v.Expected.StandbyVirtualMachineName, actual.StandbyVirtualMachineName) } } } -func TestSegmentsForTagRuleId(t *testing.T) { - segments := TagRuleId{}.Segments() +func TestSegmentsForStandbyVirtualMachineId(t *testing.T) { + segments := StandbyVirtualMachineId{}.Segments() if len(segments) == 0 { - t.Fatalf("TagRuleId has no segments") + t.Fatalf("StandbyVirtualMachineId has no segments") } uniqueNames := make(map[string]struct{}, 0) diff --git a/resource-manager/standbypool/2025-03-01/standbyvirtualmachines/id_standbyvirtualmachinepool.go b/resource-manager/standbypool/2025-03-01/standbyvirtualmachines/id_standbyvirtualmachinepool.go new file mode 100644 index 00000000000..c10ec28e374 --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbyvirtualmachines/id_standbyvirtualmachinepool.go @@ -0,0 +1,130 @@ +package standbyvirtualmachines + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&StandbyVirtualMachinePoolId{}) +} + +var _ resourceids.ResourceId = &StandbyVirtualMachinePoolId{} + +// StandbyVirtualMachinePoolId is a struct representing the Resource ID for a Standby Virtual Machine Pool +type StandbyVirtualMachinePoolId struct { + SubscriptionId string + ResourceGroupName string + StandbyVirtualMachinePoolName string +} + +// NewStandbyVirtualMachinePoolID returns a new StandbyVirtualMachinePoolId struct +func NewStandbyVirtualMachinePoolID(subscriptionId string, resourceGroupName string, standbyVirtualMachinePoolName string) StandbyVirtualMachinePoolId { + return StandbyVirtualMachinePoolId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StandbyVirtualMachinePoolName: standbyVirtualMachinePoolName, + } +} + +// ParseStandbyVirtualMachinePoolID parses 'input' into a StandbyVirtualMachinePoolId +func ParseStandbyVirtualMachinePoolID(input string) (*StandbyVirtualMachinePoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&StandbyVirtualMachinePoolId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := StandbyVirtualMachinePoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseStandbyVirtualMachinePoolIDInsensitively parses 'input' case-insensitively into a StandbyVirtualMachinePoolId +// note: this method should only be used for API response data and not user input +func ParseStandbyVirtualMachinePoolIDInsensitively(input string) (*StandbyVirtualMachinePoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&StandbyVirtualMachinePoolId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := StandbyVirtualMachinePoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *StandbyVirtualMachinePoolId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.StandbyVirtualMachinePoolName, ok = input.Parsed["standbyVirtualMachinePoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "standbyVirtualMachinePoolName", input) + } + + return nil +} + +// ValidateStandbyVirtualMachinePoolID checks that 'input' can be parsed as a Standby Virtual Machine Pool ID +func ValidateStandbyVirtualMachinePoolID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseStandbyVirtualMachinePoolID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Standby Virtual Machine Pool ID +func (id StandbyVirtualMachinePoolId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.StandbyPool/standbyVirtualMachinePools/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StandbyVirtualMachinePoolName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Standby Virtual Machine Pool ID +func (id StandbyVirtualMachinePoolId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftStandbyPool", "Microsoft.StandbyPool", "Microsoft.StandbyPool"), + resourceids.StaticSegment("staticStandbyVirtualMachinePools", "standbyVirtualMachinePools", "standbyVirtualMachinePools"), + resourceids.UserSpecifiedSegment("standbyVirtualMachinePoolName", "standbyVirtualMachinePoolName"), + } +} + +// String returns a human-readable description of this Standby Virtual Machine Pool ID +func (id StandbyVirtualMachinePoolId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Standby Virtual Machine Pool Name: %q", id.StandbyVirtualMachinePoolName), + } + return fmt.Sprintf("Standby Virtual Machine Pool (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/logz/2020-10-01/tagrules/id_monitor_test.go b/resource-manager/standbypool/2025-03-01/standbyvirtualmachines/id_standbyvirtualmachinepool_test.go similarity index 61% rename from resource-manager/logz/2020-10-01/tagrules/id_monitor_test.go rename to resource-manager/standbypool/2025-03-01/standbyvirtualmachines/id_standbyvirtualmachinepool_test.go index 3188a25e3ae..96a20bcb405 100644 --- a/resource-manager/logz/2020-10-01/tagrules/id_monitor_test.go +++ b/resource-manager/standbypool/2025-03-01/standbyvirtualmachines/id_standbyvirtualmachinepool_test.go @@ -1,4 +1,4 @@ -package tagrules +package standbyvirtualmachines import ( "testing" @@ -9,10 +9,10 @@ import ( // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. -var _ resourceids.ResourceId = &MonitorId{} +var _ resourceids.ResourceId = &StandbyVirtualMachinePoolId{} -func TestNewMonitorID(t *testing.T) { - id := NewMonitorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName") +func TestNewStandbyVirtualMachinePoolID(t *testing.T) { + id := NewStandbyVirtualMachinePoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "standbyVirtualMachinePoolName") if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") @@ -22,24 +22,24 @@ func TestNewMonitorID(t *testing.T) { t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") } - if id.MonitorName != "monitorName" { - t.Fatalf("Expected %q but got %q for Segment 'MonitorName'", id.MonitorName, "monitorName") + if id.StandbyVirtualMachinePoolName != "standbyVirtualMachinePoolName" { + t.Fatalf("Expected %q but got %q for Segment 'StandbyVirtualMachinePoolName'", id.StandbyVirtualMachinePoolName, "standbyVirtualMachinePoolName") } } -func TestFormatMonitorID(t *testing.T) { - actual := NewMonitorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName" +func TestFormatStandbyVirtualMachinePoolID(t *testing.T) { + actual := NewStandbyVirtualMachinePoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "standbyVirtualMachinePoolName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyVirtualMachinePools/standbyVirtualMachinePoolName" if actual != expected { t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) } } -func TestParseMonitorID(t *testing.T) { +func TestParseStandbyVirtualMachinePoolID(t *testing.T) { testData := []struct { Input string Error bool - Expected *MonitorId + Expected *StandbyVirtualMachinePoolId }{ { // Incomplete URI @@ -73,33 +73,33 @@ func TestParseMonitorID(t *testing.T) { }, { // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool", Error: true, }, { // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyVirtualMachinePools", Error: true, }, { // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName", - Expected: &MonitorId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - MonitorName: "monitorName", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyVirtualMachinePools/standbyVirtualMachinePoolName", + Expected: &StandbyVirtualMachinePoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StandbyVirtualMachinePoolName: "standbyVirtualMachinePoolName", }, }, { // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/extra", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyVirtualMachinePools/standbyVirtualMachinePoolName/extra", Error: true, }, } for _, v := range testData { t.Logf("[DEBUG] Testing %q", v.Input) - actual, err := ParseMonitorID(v.Input) + actual, err := ParseStandbyVirtualMachinePoolID(v.Input) if err != nil { if v.Error { continue @@ -119,18 +119,18 @@ func TestParseMonitorID(t *testing.T) { t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) } - if actual.MonitorName != v.Expected.MonitorName { - t.Fatalf("Expected %q but got %q for MonitorName", v.Expected.MonitorName, actual.MonitorName) + if actual.StandbyVirtualMachinePoolName != v.Expected.StandbyVirtualMachinePoolName { + t.Fatalf("Expected %q but got %q for StandbyVirtualMachinePoolName", v.Expected.StandbyVirtualMachinePoolName, actual.StandbyVirtualMachinePoolName) } } } -func TestParseMonitorIDInsensitively(t *testing.T) { +func TestParseStandbyVirtualMachinePoolIDInsensitively(t *testing.T) { testData := []struct { Input string Error bool - Expected *MonitorId + Expected *StandbyVirtualMachinePoolId }{ { // Incomplete URI @@ -189,57 +189,57 @@ func TestParseMonitorIDInsensitively(t *testing.T) { }, { // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool", Error: true, }, { // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ", + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sTaNdByPoOl", Error: true, }, { // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyVirtualMachinePools", Error: true, }, { // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ/mOnItOrS", + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sTaNdByPoOl/sTaNdByViRtUaLmAcHiNePoOlS", Error: true, }, { // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName", - Expected: &MonitorId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - MonitorName: "monitorName", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyVirtualMachinePools/standbyVirtualMachinePoolName", + Expected: &StandbyVirtualMachinePoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StandbyVirtualMachinePoolName: "standbyVirtualMachinePoolName", }, }, { // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Logz/monitors/monitorName/extra", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StandbyPool/standbyVirtualMachinePools/standbyVirtualMachinePoolName/extra", Error: true, }, { // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ/mOnItOrS/mOnItOrNaMe", - Expected: &MonitorId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - MonitorName: "mOnItOrNaMe", + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sTaNdByPoOl/sTaNdByViRtUaLmAcHiNePoOlS/sTaNdByViRtUaLmAcHiNePoOlNaMe", + Expected: &StandbyVirtualMachinePoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + StandbyVirtualMachinePoolName: "sTaNdByViRtUaLmAcHiNePoOlNaMe", }, }, { // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.lOgZ/mOnItOrS/mOnItOrNaMe/extra", + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sTaNdByPoOl/sTaNdByViRtUaLmAcHiNePoOlS/sTaNdByViRtUaLmAcHiNePoOlNaMe/extra", Error: true, }, } for _, v := range testData { t.Logf("[DEBUG] Testing %q", v.Input) - actual, err := ParseMonitorIDInsensitively(v.Input) + actual, err := ParseStandbyVirtualMachinePoolIDInsensitively(v.Input) if err != nil { if v.Error { continue @@ -259,17 +259,17 @@ func TestParseMonitorIDInsensitively(t *testing.T) { t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) } - if actual.MonitorName != v.Expected.MonitorName { - t.Fatalf("Expected %q but got %q for MonitorName", v.Expected.MonitorName, actual.MonitorName) + if actual.StandbyVirtualMachinePoolName != v.Expected.StandbyVirtualMachinePoolName { + t.Fatalf("Expected %q but got %q for StandbyVirtualMachinePoolName", v.Expected.StandbyVirtualMachinePoolName, actual.StandbyVirtualMachinePoolName) } } } -func TestSegmentsForMonitorId(t *testing.T) { - segments := MonitorId{}.Segments() +func TestSegmentsForStandbyVirtualMachinePoolId(t *testing.T) { + segments := StandbyVirtualMachinePoolId{}.Segments() if len(segments) == 0 { - t.Fatalf("MonitorId has no segments") + t.Fatalf("StandbyVirtualMachinePoolId has no segments") } uniqueNames := make(map[string]struct{}, 0) diff --git a/resource-manager/logz/2020-10-01/tagrules/method_get.go b/resource-manager/standbypool/2025-03-01/standbyvirtualmachines/method_get.go similarity index 78% rename from resource-manager/logz/2020-10-01/tagrules/method_get.go rename to resource-manager/standbypool/2025-03-01/standbyvirtualmachines/method_get.go index 9906af3f453..8a63a04d3a9 100644 --- a/resource-manager/logz/2020-10-01/tagrules/method_get.go +++ b/resource-manager/standbypool/2025-03-01/standbyvirtualmachines/method_get.go @@ -1,4 +1,4 @@ -package tagrules +package standbyvirtualmachines import ( "context" @@ -14,11 +14,11 @@ import ( type GetOperationResponse struct { HttpResponse *http.Response OData *odata.OData - Model *MonitoringTagRules + Model *StandbyVirtualMachineResource } // Get ... -func (c TagRulesClient) Get(ctx context.Context, id TagRuleId) (result GetOperationResponse, err error) { +func (c StandbyVirtualMachinesClient) Get(ctx context.Context, id StandbyVirtualMachineId) (result GetOperationResponse, err error) { opts := client.RequestOptions{ ContentType: "application/json; charset=utf-8", ExpectedStatusCodes: []int{ @@ -43,7 +43,7 @@ func (c TagRulesClient) Get(ctx context.Context, id TagRuleId) (result GetOperat return } - var model MonitoringTagRules + var model StandbyVirtualMachineResource result.Model = &model if err = resp.Unmarshal(result.Model); err != nil { return diff --git a/resource-manager/standbypool/2025-03-01/standbyvirtualmachines/method_listbystandbyvirtualmachinepoolresource.go b/resource-manager/standbypool/2025-03-01/standbyvirtualmachines/method_listbystandbyvirtualmachinepoolresource.go new file mode 100644 index 00000000000..d2b762a36fe --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbyvirtualmachines/method_listbystandbyvirtualmachinepoolresource.go @@ -0,0 +1,105 @@ +package standbyvirtualmachines + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByStandbyVirtualMachinePoolResourceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StandbyVirtualMachineResource +} + +type ListByStandbyVirtualMachinePoolResourceCompleteResult struct { + LatestHttpResponse *http.Response + Items []StandbyVirtualMachineResource +} + +type ListByStandbyVirtualMachinePoolResourceCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByStandbyVirtualMachinePoolResourceCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByStandbyVirtualMachinePoolResource ... +func (c StandbyVirtualMachinesClient) ListByStandbyVirtualMachinePoolResource(ctx context.Context, id StandbyVirtualMachinePoolId) (result ListByStandbyVirtualMachinePoolResourceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByStandbyVirtualMachinePoolResourceCustomPager{}, + Path: fmt.Sprintf("%s/standbyVirtualMachines", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]StandbyVirtualMachineResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByStandbyVirtualMachinePoolResourceComplete retrieves all the results into a single object +func (c StandbyVirtualMachinesClient) ListByStandbyVirtualMachinePoolResourceComplete(ctx context.Context, id StandbyVirtualMachinePoolId) (ListByStandbyVirtualMachinePoolResourceCompleteResult, error) { + return c.ListByStandbyVirtualMachinePoolResourceCompleteMatchingPredicate(ctx, id, StandbyVirtualMachineResourceOperationPredicate{}) +} + +// ListByStandbyVirtualMachinePoolResourceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StandbyVirtualMachinesClient) ListByStandbyVirtualMachinePoolResourceCompleteMatchingPredicate(ctx context.Context, id StandbyVirtualMachinePoolId, predicate StandbyVirtualMachineResourceOperationPredicate) (result ListByStandbyVirtualMachinePoolResourceCompleteResult, err error) { + items := make([]StandbyVirtualMachineResource, 0) + + resp, err := c.ListByStandbyVirtualMachinePoolResource(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 = ListByStandbyVirtualMachinePoolResourceCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/standbypool/2025-03-01/standbyvirtualmachines/model_standbyvirtualmachineresource.go b/resource-manager/standbypool/2025-03-01/standbyvirtualmachines/model_standbyvirtualmachineresource.go new file mode 100644 index 00000000000..e7d0e76d0ff --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbyvirtualmachines/model_standbyvirtualmachineresource.go @@ -0,0 +1,16 @@ +package standbyvirtualmachines + +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 StandbyVirtualMachineResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StandbyVirtualMachineResourceProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/standbypool/2025-03-01/standbyvirtualmachines/model_standbyvirtualmachineresourceproperties.go b/resource-manager/standbypool/2025-03-01/standbyvirtualmachines/model_standbyvirtualmachineresourceproperties.go new file mode 100644 index 00000000000..48492a9e5b6 --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbyvirtualmachines/model_standbyvirtualmachineresourceproperties.go @@ -0,0 +1,9 @@ +package standbyvirtualmachines + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StandbyVirtualMachineResourceProperties struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + VirtualMachineResourceId string `json:"virtualMachineResourceId"` +} diff --git a/resource-manager/standbypool/2025-03-01/standbyvirtualmachines/predicates.go b/resource-manager/standbypool/2025-03-01/standbyvirtualmachines/predicates.go new file mode 100644 index 00000000000..c067a7dc6c3 --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbyvirtualmachines/predicates.go @@ -0,0 +1,27 @@ +package standbyvirtualmachines + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StandbyVirtualMachineResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p StandbyVirtualMachineResourceOperationPredicate) Matches(input StandbyVirtualMachineResource) 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/standbypool/2025-03-01/standbyvirtualmachines/version.go b/resource-manager/standbypool/2025-03-01/standbyvirtualmachines/version.go new file mode 100644 index 00000000000..1d88648447a --- /dev/null +++ b/resource-manager/standbypool/2025-03-01/standbyvirtualmachines/version.go @@ -0,0 +1,10 @@ +package standbyvirtualmachines + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-03-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/standbyvirtualmachines/2025-03-01" +} diff --git a/resource-manager/storage/2024-01-01/fileshares/model_fileshareproperties.go b/resource-manager/storage/2024-01-01/fileshares/model_fileshareproperties.go index 40411e619da..1b31ebcd1b9 100644 --- a/resource-manager/storage/2024-01-01/fileshares/model_fileshareproperties.go +++ b/resource-manager/storage/2024-01-01/fileshares/model_fileshareproperties.go @@ -74,42 +74,6 @@ func (o *FileShareProperties) SetLastModifiedTimeAsTime(input time.Time) { o.LastModifiedTime = &formatted } -func (o *FileShareProperties) GetNextAllowedProvisionedBandwidthDowngradeTimeAsTime() (*time.Time, error) { - if o.NextAllowedProvisionedBandwidthDowngradeTime == nil { - return nil, nil - } - return dates.ParseAsFormat(o.NextAllowedProvisionedBandwidthDowngradeTime, "2006-01-02T15:04:05Z07:00") -} - -func (o *FileShareProperties) SetNextAllowedProvisionedBandwidthDowngradeTimeAsTime(input time.Time) { - formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.NextAllowedProvisionedBandwidthDowngradeTime = &formatted -} - -func (o *FileShareProperties) GetNextAllowedProvisionedIopsDowngradeTimeAsTime() (*time.Time, error) { - if o.NextAllowedProvisionedIopsDowngradeTime == nil { - return nil, nil - } - return dates.ParseAsFormat(o.NextAllowedProvisionedIopsDowngradeTime, "2006-01-02T15:04:05Z07:00") -} - -func (o *FileShareProperties) SetNextAllowedProvisionedIopsDowngradeTimeAsTime(input time.Time) { - formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.NextAllowedProvisionedIopsDowngradeTime = &formatted -} - -func (o *FileShareProperties) GetNextAllowedQuotaDowngradeTimeAsTime() (*time.Time, error) { - if o.NextAllowedQuotaDowngradeTime == nil { - return nil, nil - } - return dates.ParseAsFormat(o.NextAllowedQuotaDowngradeTime, "2006-01-02T15:04:05Z07:00") -} - -func (o *FileShareProperties) SetNextAllowedQuotaDowngradeTimeAsTime(input time.Time) { - formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.NextAllowedQuotaDowngradeTime = &formatted -} - func (o *FileShareProperties) GetSnapshotTimeAsTime() (*time.Time, error) { if o.SnapshotTime == nil { return nil, nil