From f43011dd1fc9a07c251a39f293cc4399ebe3cdc6 Mon Sep 17 00:00:00 2001 From: hc-github-team-tf-azure <> Date: Tue, 23 Jan 2024 10:39:12 +0000 Subject: [PATCH] Updating based on 0479564e0 --- .../keyvault/2021-10-01/client.go | 71 -- .../keyvault/2021-10-01/keys/README.md | 107 --- .../keyvault/2021-10-01/keys/client.go | 18 - .../keyvault/2021-10-01/keys/constants.go | 151 ---- .../keys/method_createifnotexist_autorest.go | 70 -- .../2021-10-01/keys/method_get_autorest.go | 69 -- .../keys/method_getversion_autorest.go | 69 -- .../2021-10-01/keys/method_list_autorest.go | 187 ----- .../keys/method_listversions_autorest.go | 187 ----- .../keyvault/2021-10-01/keys/model_key.go | 13 - .../2021-10-01/keys/model_keyattributes.go | 14 - .../keys/model_keycreateparameters.go | 9 - .../2021-10-01/keys/model_keyproperties.go | 14 - .../keyvault/2021-10-01/keys/predicates.go | 32 - .../keyvault/2021-10-01/keys/version.go | 12 - .../keyvault/2021-10-01/managedhsms/README.md | 161 ----- .../keyvault/2021-10-01/managedhsms/client.go | 18 - .../2021-10-01/managedhsms/constants.go | 319 --------- .../managedhsms/id_deletedmanagedhsm.go | 125 ---- .../managedhsms/id_deletedmanagedhsm_test.go | 282 -------- .../2021-10-01/managedhsms/id_managedhsm.go | 125 ---- .../managedhsms/id_managedhsm_test.go | 282 -------- .../method_createorupdate_autorest.go | 80 --- .../managedhsms/method_delete_autorest.go | 78 --- .../managedhsms/method_get_autorest.go | 68 -- .../managedhsms/method_getdeleted_autorest.go | 68 -- .../method_listbyresourcegroup_autorest.go | 216 ------ .../method_listbysubscription_autorest.go | 216 ------ .../method_listdeleted_autorest.go | 187 ----- .../method_purgedeleted_autorest.go | 78 --- .../managedhsms/method_update_autorest.go | 80 --- .../managedhsms/model_deletedmanagedhsm.go | 11 - .../model_deletedmanagedhsmproperties.go | 43 -- .../managedhsms/model_managedhsm.go | 19 - .../managedhsms/model_managedhsmproperties.go | 38 - .../managedhsms/model_managedhsmsku.go | 9 - .../managedhsms/model_mhsmiprule.go | 8 - .../managedhsms/model_mhsmnetworkruleset.go | 11 - .../managedhsms/model_mhsmprivateendpoint.go | 8 - ...model_mhsmprivateendpointconnectionitem.go | 10 - ...mhsmprivateendpointconnectionproperties.go | 10 - ...l_mhsmprivatelinkserviceconnectionstate.go | 10 - .../model_mhsmvirtualnetworkrule.go | 8 - .../2021-10-01/managedhsms/predicates.go | 55 -- .../2021-10-01/managedhsms/version.go | 12 - .../README.md | 37 - .../client.go | 18 - .../constants.go | 161 ----- .../id_managedhsm.go | 125 ---- .../id_managedhsm_test.go | 282 -------- ...pointconnectionslistbyresource_autorest.go | 186 ----- .../model_managedhsmsku.go | 9 - .../model_mhsmprivateendpoint.go | 8 - .../model_mhsmprivateendpointconnection.go | 20 - ...mhsmprivateendpointconnectionproperties.go | 10 - ...l_mhsmprivatelinkserviceconnectionstate.go | 10 - .../predicates.go | 37 - .../version.go | 12 - .../mhsmprivateendpointconnections/README.md | 69 -- .../mhsmprivateendpointconnections/client.go | 18 - .../constants.go | 161 ----- .../id_privateendpointconnection.go | 134 ---- .../id_privateendpointconnection_test.go | 327 --------- .../method_delete_autorest.go | 79 --- .../method_get_autorest.go | 68 -- .../method_put_autorest.go | 69 -- .../model_managedhsmsku.go | 9 - .../model_mhsmprivateendpoint.go | 8 - .../model_mhsmprivateendpointconnection.go | 20 - ...mhsmprivateendpointconnectionproperties.go | 10 - ...l_mhsmprivatelinkserviceconnectionstate.go | 10 - .../mhsmprivateendpointconnections/version.go | 12 - .../mhsmprivatelinkresources/README.md | 36 - .../mhsmprivatelinkresources/client.go | 18 - .../mhsmprivatelinkresources/constants.go | 62 -- .../mhsmprivatelinkresources/id_managedhsm.go | 125 ---- .../id_managedhsm_test.go | 282 -------- .../method_listbymhsmresource_autorest.go | 69 -- .../model_managedhsmsku.go | 9 - .../model_mhsmprivatelinkresource.go | 19 - ...model_mhsmprivatelinkresourcelistresult.go | 8 - ...model_mhsmprivatelinkresourceproperties.go | 10 - .../mhsmprivatelinkresources/version.go | 12 - .../privateendpointconnections/README.md | 86 --- .../privateendpointconnections/client.go | 18 - .../privateendpointconnections/constants.go | 105 --- .../method_delete_autorest.go | 80 --- .../method_get_autorest.go | 69 -- .../method_listbyresource_autorest.go | 187 ----- .../method_put_autorest.go | 70 -- .../model_privateendpoint.go | 8 - .../model_privateendpointconnection.go | 14 - ...del_privateendpointconnectionproperties.go | 10 - ...model_privatelinkserviceconnectionstate.go | 10 - .../privateendpointconnections/predicates.go | 37 - .../privateendpointconnections/version.go | 12 - .../2021-10-01/privatelinkresources/README.md | 36 - .../2021-10-01/privatelinkresources/client.go | 18 - .../method_listbyvault_autorest.go | 70 -- .../model_privatelinkresource.go | 13 - .../model_privatelinkresourcelistresult.go | 8 - .../model_privatelinkresourceproperties.go | 10 - .../privatelinkresources/version.go | 12 - .../keyvault/2021-10-01/secrets/README.md | 95 --- .../keyvault/2021-10-01/secrets/client.go | 18 - .../keyvault/2021-10-01/secrets/id_secret.go | 134 ---- .../2021-10-01/secrets/id_secret_test.go | 327 --------- .../secrets/method_createorupdate_autorest.go | 69 -- .../2021-10-01/secrets/method_get_autorest.go | 68 -- .../secrets/method_list_autorest.go | 216 ------ .../secrets/method_update_autorest.go | 69 -- .../2021-10-01/secrets/model_attributes.go | 12 - .../2021-10-01/secrets/model_secret.go | 13 - .../model_secretcreateorupdateparameters.go | 9 - .../secrets/model_secretpatchparameters.go | 9 - .../secrets/model_secretpatchproperties.go | 10 - .../secrets/model_secretproperties.go | 12 - .../keyvault/2021-10-01/secrets/predicates.go | 32 - .../keyvault/2021-10-01/secrets/version.go | 12 - .../keyvault/2021-10-01/vaults/README.md | 228 ------ .../keyvault/2021-10-01/vaults/client.go | 18 - .../keyvault/2021-10-01/vaults/constants.go | 641 ----------------- .../2021-10-01/vaults/id_deletedvault.go | 125 ---- .../2021-10-01/vaults/id_deletedvault_test.go | 282 -------- .../2021-10-01/vaults/id_operationkind.go | 142 ---- .../vaults/id_operationkind_test.go | 327 --------- .../method_checknameavailability_autorest.go | 71 -- .../vaults/method_createorupdate_autorest.go | 81 --- .../vaults/method_delete_autorest.go | 67 -- .../2021-10-01/vaults/method_get_autorest.go | 69 -- .../vaults/method_getdeleted_autorest.go | 68 -- .../2021-10-01/vaults/method_list_autorest.go | 221 ------ .../method_listbyresourcegroup_autorest.go | 216 ------ .../method_listbysubscription_autorest.go | 216 ------ .../vaults/method_listdeleted_autorest.go | 187 ----- .../vaults/method_purgedeleted_autorest.go | 78 --- .../vaults/method_update_autorest.go | 70 -- .../method_updateaccesspolicy_autorest.go | 69 -- .../vaults/model_accesspolicyentry.go | 11 - .../model_checknameavailabilityresult.go | 10 - .../2021-10-01/vaults/model_deletedvault.go | 11 - .../vaults/model_deletedvaultproperties.go | 43 -- .../2021-10-01/vaults/model_iprule.go | 8 - .../2021-10-01/vaults/model_networkruleset.go | 11 - .../2021-10-01/vaults/model_permissions.go | 11 - .../vaults/model_privateendpoint.go | 8 - .../model_privateendpointconnectionitem.go | 10 - ...del_privateendpointconnectionproperties.go | 10 - ...model_privatelinkserviceconnectionstate.go | 10 - .../2021-10-01/vaults/model_resource.go | 12 - .../keyvault/2021-10-01/vaults/model_sku.go | 9 - .../keyvault/2021-10-01/vaults/model_vault.go | 18 - .../model_vaultaccesspolicyparameters.go | 12 - .../model_vaultaccesspolicyproperties.go | 8 - ...el_vaultchecknameavailabilityparameters.go | 9 - .../model_vaultcreateorupdateparameters.go | 10 - .../vaults/model_vaultpatchparameters.go | 9 - .../vaults/model_vaultpatchproperties.go | 20 - .../vaults/model_vaultproperties.go | 24 - .../vaults/model_virtualnetworkrule.go | 9 - .../keyvault/2021-10-01/vaults/predicates.go | 83 --- .../keyvault/2021-10-01/vaults/version.go | 12 - .../keyvault/2022-11-01/client.go | 77 --- .../keyvault/2022-11-01/keys/README.md | 107 --- .../keyvault/2022-11-01/keys/client.go | 18 - .../keyvault/2022-11-01/keys/constants.go | 182 ----- .../keys/method_createifnotexist_autorest.go | 70 -- .../2022-11-01/keys/method_get_autorest.go | 69 -- .../keys/method_getversion_autorest.go | 69 -- .../2022-11-01/keys/method_list_autorest.go | 187 ----- .../keys/method_listversions_autorest.go | 187 ----- .../keyvault/2022-11-01/keys/model_action.go | 8 - .../keyvault/2022-11-01/keys/model_key.go | 13 - .../2022-11-01/keys/model_keyattributes.go | 14 - .../keys/model_keycreateparameters.go | 9 - .../2022-11-01/keys/model_keyproperties.go | 16 - .../2022-11-01/keys/model_keyreleasepolicy.go | 9 - .../keys/model_keyrotationpolicyattributes.go | 10 - .../2022-11-01/keys/model_lifetimeaction.go | 9 - .../2022-11-01/keys/model_rotationpolicy.go | 9 - .../keyvault/2022-11-01/keys/model_trigger.go | 9 - .../keyvault/2022-11-01/keys/predicates.go | 32 - .../keyvault/2022-11-01/keys/version.go | 12 - .../2022-11-01/managedhsmkeys/README.md | 107 --- .../2022-11-01/managedhsmkeys/client.go | 18 - .../2022-11-01/managedhsmkeys/constants.go | 182 ----- .../2022-11-01/managedhsmkeys/id_key.go | 134 ---- .../2022-11-01/managedhsmkeys/id_key_test.go | 327 --------- .../managedhsmkeys/id_managedhsm.go | 125 ---- .../managedhsmkeys/id_managedhsm_test.go | 282 -------- .../2022-11-01/managedhsmkeys/id_version.go | 143 ---- .../managedhsmkeys/id_version_test.go | 372 ---------- .../method_createifnotexist_autorest.go | 69 -- .../managedhsmkeys/method_get_autorest.go | 68 -- .../method_getversion_autorest.go | 68 -- .../managedhsmkeys/method_list_autorest.go | 186 ----- .../method_listversions_autorest.go | 186 ----- .../managedhsmkeys/model_managedhsmaction.go | 8 - .../managedhsmkeys/model_managedhsmkey.go | 12 - .../model_managedhsmkeyattributes.go | 14 - .../model_managedhsmkeycreateparameters.go | 9 - .../model_managedhsmkeyproperties.go | 16 - .../model_managedhsmkeyreleasepolicy.go | 9 - ...l_managedhsmkeyrotationpolicyattributes.go | 10 - .../model_managedhsmlifetimeaction.go | 9 - .../model_managedhsmrotationpolicy.go | 9 - .../managedhsmkeys/model_managedhsmtrigger.go | 9 - .../2022-11-01/managedhsmkeys/predicates.go | 27 - .../2022-11-01/managedhsmkeys/version.go | 12 - .../keyvault/2022-11-01/managedhsms/README.md | 182 ----- .../keyvault/2022-11-01/managedhsms/client.go | 18 - .../2022-11-01/managedhsms/constants.go | 381 ---------- .../managedhsms/id_deletedmanagedhsm.go | 125 ---- .../managedhsms/id_deletedmanagedhsm_test.go | 282 -------- .../2022-11-01/managedhsms/id_managedhsm.go | 125 ---- .../managedhsms/id_managedhsm_test.go | 282 -------- ...thod_checkmhsmnameavailability_autorest.go | 71 -- .../method_createorupdate_autorest.go | 80 --- .../managedhsms/method_delete_autorest.go | 78 --- .../managedhsms/method_get_autorest.go | 68 -- .../managedhsms/method_getdeleted_autorest.go | 68 -- .../method_listbyresourcegroup_autorest.go | 216 ------ .../method_listbysubscription_autorest.go | 216 ------ .../method_listdeleted_autorest.go | 187 ----- .../method_purgedeleted_autorest.go | 78 --- .../managedhsms/method_update_autorest.go | 80 --- ...del_checkmhsmnameavailabilityparameters.go | 8 - .../model_checkmhsmnameavailabilityresult.go | 10 - .../managedhsms/model_deletedmanagedhsm.go | 11 - .../model_deletedmanagedhsmproperties.go | 43 -- .../managedhsms/model_managedhsm.go | 19 - .../managedhsms/model_managedhsmproperties.go | 39 -- ...odel_managedhsmsecuritydomainproperties.go | 9 - .../managedhsms/model_managedhsmsku.go | 9 - .../managedhsms/model_mhsmiprule.go | 8 - .../managedhsms/model_mhsmnetworkruleset.go | 11 - .../managedhsms/model_mhsmprivateendpoint.go | 8 - ...model_mhsmprivateendpointconnectionitem.go | 10 - ...mhsmprivateendpointconnectionproperties.go | 10 - ...l_mhsmprivatelinkserviceconnectionstate.go | 10 - .../model_mhsmvirtualnetworkrule.go | 8 - .../2022-11-01/managedhsms/predicates.go | 55 -- .../2022-11-01/managedhsms/version.go | 12 - .../README.md | 37 - .../client.go | 18 - .../constants.go | 161 ----- .../id_managedhsm.go | 125 ---- .../id_managedhsm_test.go | 282 -------- ...pointconnectionslistbyresource_autorest.go | 186 ----- .../model_managedhsmsku.go | 9 - .../model_mhsmprivateendpoint.go | 8 - .../model_mhsmprivateendpointconnection.go | 20 - ...mhsmprivateendpointconnectionproperties.go | 10 - ...l_mhsmprivatelinkserviceconnectionstate.go | 10 - .../predicates.go | 37 - .../version.go | 12 - .../mhsmprivateendpointconnections/README.md | 69 -- .../mhsmprivateendpointconnections/client.go | 18 - .../constants.go | 161 ----- .../id_privateendpointconnection.go | 134 ---- .../id_privateendpointconnection_test.go | 327 --------- .../method_delete_autorest.go | 79 --- .../method_get_autorest.go | 68 -- .../method_put_autorest.go | 69 -- .../model_managedhsmsku.go | 9 - .../model_mhsmprivateendpoint.go | 8 - .../model_mhsmprivateendpointconnection.go | 20 - ...mhsmprivateendpointconnectionproperties.go | 10 - ...l_mhsmprivatelinkserviceconnectionstate.go | 10 - .../mhsmprivateendpointconnections/version.go | 12 - .../mhsmprivatelinkresources/README.md | 36 - .../mhsmprivatelinkresources/client.go | 18 - .../mhsmprivatelinkresources/constants.go | 62 -- .../mhsmprivatelinkresources/id_managedhsm.go | 125 ---- .../id_managedhsm_test.go | 282 -------- .../method_listbymhsmresource_autorest.go | 69 -- .../model_managedhsmsku.go | 9 - .../model_mhsmprivatelinkresource.go | 19 - ...model_mhsmprivatelinkresourcelistresult.go | 8 - ...model_mhsmprivatelinkresourceproperties.go | 10 - .../mhsmprivatelinkresources/version.go | 12 - .../privateendpointconnections/README.md | 86 --- .../privateendpointconnections/client.go | 18 - .../privateendpointconnections/constants.go | 105 --- .../method_delete_autorest.go | 80 --- .../method_get_autorest.go | 69 -- .../method_listbyresource_autorest.go | 187 ----- .../method_put_autorest.go | 70 -- .../model_privateendpoint.go | 8 - .../model_privateendpointconnection.go | 14 - ...del_privateendpointconnectionproperties.go | 10 - ...model_privatelinkserviceconnectionstate.go | 10 - .../privateendpointconnections/predicates.go | 37 - .../privateendpointconnections/version.go | 12 - .../2022-11-01/privatelinkresources/README.md | 36 - .../2022-11-01/privatelinkresources/client.go | 18 - .../method_listbyvault_autorest.go | 70 -- .../model_privatelinkresource.go | 13 - .../model_privatelinkresourcelistresult.go | 8 - .../model_privatelinkresourceproperties.go | 10 - .../privatelinkresources/version.go | 12 - .../keyvault/2022-11-01/secrets/README.md | 95 --- .../keyvault/2022-11-01/secrets/client.go | 18 - .../keyvault/2022-11-01/secrets/id_secret.go | 134 ---- .../2022-11-01/secrets/id_secret_test.go | 327 --------- .../secrets/method_createorupdate_autorest.go | 69 -- .../2022-11-01/secrets/method_get_autorest.go | 68 -- .../secrets/method_list_autorest.go | 216 ------ .../secrets/method_update_autorest.go | 69 -- .../2022-11-01/secrets/model_attributes.go | 12 - .../2022-11-01/secrets/model_secret.go | 13 - .../model_secretcreateorupdateparameters.go | 9 - .../secrets/model_secretpatchparameters.go | 9 - .../secrets/model_secretpatchproperties.go | 10 - .../secrets/model_secretproperties.go | 12 - .../keyvault/2022-11-01/secrets/predicates.go | 32 - .../keyvault/2022-11-01/secrets/version.go | 12 - .../keyvault/2022-11-01/vaults/README.md | 228 ------ .../keyvault/2022-11-01/vaults/client.go | 18 - .../keyvault/2022-11-01/vaults/constants.go | 653 ------------------ .../2022-11-01/vaults/id_deletedvault.go | 125 ---- .../2022-11-01/vaults/id_deletedvault_test.go | 282 -------- .../2022-11-01/vaults/id_operationkind.go | 142 ---- .../vaults/id_operationkind_test.go | 327 --------- .../method_checknameavailability_autorest.go | 71 -- .../vaults/method_createorupdate_autorest.go | 81 --- .../vaults/method_delete_autorest.go | 67 -- .../2022-11-01/vaults/method_get_autorest.go | 69 -- .../vaults/method_getdeleted_autorest.go | 68 -- .../2022-11-01/vaults/method_list_autorest.go | 221 ------ .../method_listbyresourcegroup_autorest.go | 216 ------ .../method_listbysubscription_autorest.go | 216 ------ .../vaults/method_listdeleted_autorest.go | 187 ----- .../vaults/method_purgedeleted_autorest.go | 78 --- .../vaults/method_update_autorest.go | 70 -- .../method_updateaccesspolicy_autorest.go | 69 -- .../vaults/model_accesspolicyentry.go | 11 - .../model_checknameavailabilityresult.go | 10 - .../2022-11-01/vaults/model_deletedvault.go | 11 - .../vaults/model_deletedvaultproperties.go | 43 -- .../2022-11-01/vaults/model_iprule.go | 8 - .../2022-11-01/vaults/model_networkruleset.go | 11 - .../2022-11-01/vaults/model_permissions.go | 11 - .../vaults/model_privateendpoint.go | 8 - .../model_privateendpointconnectionitem.go | 10 - ...del_privateendpointconnectionproperties.go | 10 - ...model_privatelinkserviceconnectionstate.go | 10 - .../2022-11-01/vaults/model_resource.go | 12 - .../keyvault/2022-11-01/vaults/model_sku.go | 9 - .../keyvault/2022-11-01/vaults/model_vault.go | 18 - .../model_vaultaccesspolicyparameters.go | 12 - .../model_vaultaccesspolicyproperties.go | 8 - ...el_vaultchecknameavailabilityparameters.go | 9 - .../model_vaultcreateorupdateparameters.go | 10 - .../vaults/model_vaultpatchparameters.go | 9 - .../vaults/model_vaultpatchproperties.go | 20 - .../vaults/model_vaultproperties.go | 24 - .../vaults/model_virtualnetworkrule.go | 9 - .../keyvault/2022-11-01/vaults/predicates.go | 83 --- .../keyvault/2022-11-01/vaults/version.go | 12 - .../keyvault/2023-07-01/client.go | 111 ++- .../keyvault/2023-07-01/keys/client.go | 22 +- .../keyvault/2023-07-01/keys/constants.go | 71 +- .../keys/method_createifnotexist.go | 56 ++ .../keys/method_createifnotexist_autorest.go | 70 -- .../keyvault/2023-07-01/keys/method_get.go | 52 ++ .../2023-07-01/keys/method_get_autorest.go | 69 -- .../2023-07-01/keys/method_getversion.go | 52 ++ .../keys/method_getversion_autorest.go | 69 -- .../keyvault/2023-07-01/keys/method_list.go | 92 +++ .../2023-07-01/keys/method_list_autorest.go | 187 ----- .../2023-07-01/keys/method_listversions.go | 92 +++ .../keys/method_listversions_autorest.go | 187 ----- .../2023-07-01/managedhsmkeys/client.go | 22 +- .../2023-07-01/managedhsmkeys/constants.go | 71 +- .../managedhsmkeys/method_createifnotexist.go | 55 ++ .../method_createifnotexist_autorest.go | 69 -- .../2023-07-01/managedhsmkeys/method_get.go | 51 ++ .../managedhsmkeys/method_get_autorest.go | 68 -- .../managedhsmkeys/method_getversion.go | 51 ++ .../method_getversion_autorest.go | 68 -- .../2023-07-01/managedhsmkeys/method_list.go | 91 +++ .../managedhsmkeys/method_list_autorest.go | 186 ----- .../managedhsmkeys/method_listversions.go | 91 +++ .../method_listversions_autorest.go | 186 ----- .../keyvault/2023-07-01/managedhsms/client.go | 22 +- .../2023-07-01/managedhsms/constants.go | 175 ++++- .../method_checkmhsmnameavailability.go | 57 ++ ...thod_checkmhsmnameavailability_autorest.go | 71 -- .../managedhsms/method_createorupdate.go | 79 +++ .../method_createorupdate_autorest.go | 80 --- .../2023-07-01/managedhsms/method_delete.go | 71 ++ .../managedhsms/method_delete_autorest.go | 78 --- .../2023-07-01/managedhsms/method_get.go | 52 ++ .../managedhsms/method_get_autorest.go | 68 -- .../managedhsms/method_getdeleted.go | 51 ++ .../managedhsms/method_getdeleted_autorest.go | 68 -- .../managedhsms/method_listbyresourcegroup.go | 120 ++++ .../method_listbyresourcegroup_autorest.go | 216 ------ .../managedhsms/method_listbysubscription.go | 120 ++++ .../method_listbysubscription_autorest.go | 216 ------ .../managedhsms/method_listdeleted.go | 92 +++ .../method_listdeleted_autorest.go | 187 ----- .../managedhsms/method_purgedeleted.go | 69 ++ .../method_purgedeleted_autorest.go | 78 --- .../2023-07-01/managedhsms/method_update.go | 79 +++ .../managedhsms/method_update_autorest.go | 80 --- .../client.go | 22 +- .../constants.go | 71 +- ...rivateendpointconnectionslistbyresource.go | 91 +++ ...pointconnectionslistbyresource_autorest.go | 186 ----- .../2023-07-01/mhsmlistregions/client.go | 22 +- .../2023-07-01/mhsmlistregions/constants.go | 19 +- .../method_mhsmregionslistbyresource.go | 91 +++ ...thod_mhsmregionslistbyresource_autorest.go | 186 ----- .../mhsmprivateendpointconnections/client.go | 22 +- .../constants.go | 71 +- .../method_delete.go | 76 ++ .../method_delete_autorest.go | 79 --- .../method_get.go | 51 ++ .../method_get_autorest.go | 68 -- .../method_put.go | 55 ++ .../method_put_autorest.go | 69 -- .../mhsmprivatelinkresources/client.go | 22 +- .../mhsmprivatelinkresources/constants.go | 32 +- .../method_listbymhsmresource.go | 52 ++ .../method_listbymhsmresource_autorest.go | 69 -- .../privateendpointconnections/client.go | 22 +- .../privateendpointconnections/constants.go | 45 +- .../method_delete.go | 77 +++ .../method_delete_autorest.go | 80 --- .../privateendpointconnections/method_get.go | 53 ++ .../method_get_autorest.go | 69 -- .../method_listbyresource.go | 92 +++ .../method_listbyresource_autorest.go | 187 ----- .../privateendpointconnections/method_put.go | 56 ++ .../method_put_autorest.go | 70 -- .../2023-07-01/privatelinkresources/client.go | 22 +- .../method_listbyvault.go | 53 ++ .../method_listbyvault_autorest.go | 70 -- .../keyvault/2023-07-01/secrets/client.go | 22 +- .../secrets/method_createorupdate.go | 56 ++ .../secrets/method_createorupdate_autorest.go | 69 -- .../keyvault/2023-07-01/secrets/method_get.go | 51 ++ .../2023-07-01/secrets/method_get_autorest.go | 68 -- .../2023-07-01/secrets/method_list.go | 120 ++++ .../secrets/method_list_autorest.go | 216 ------ .../2023-07-01/secrets/method_update.go | 56 ++ .../secrets/method_update_autorest.go | 69 -- .../keyvault/2023-07-01/vaults/client.go | 22 +- .../keyvault/2023-07-01/vaults/constants.go | 227 +++++- .../vaults/method_checknameavailability.go | 57 ++ .../method_checknameavailability_autorest.go | 71 -- .../vaults/method_createorupdate.go | 80 +++ .../vaults/method_createorupdate_autorest.go | 81 --- .../2023-07-01/vaults/method_delete.go | 48 ++ .../vaults/method_delete_autorest.go | 67 -- .../keyvault/2023-07-01/vaults/method_get.go | 52 ++ .../2023-07-01/vaults/method_get_autorest.go | 69 -- .../2023-07-01/vaults/method_getdeleted.go | 51 ++ .../vaults/method_getdeleted_autorest.go | 68 -- .../keyvault/2023-07-01/vaults/method_list.go | 124 ++++ .../2023-07-01/vaults/method_list_autorest.go | 221 ------ .../vaults/method_listbyresourcegroup.go | 120 ++++ .../method_listbyresourcegroup_autorest.go | 216 ------ .../vaults/method_listbysubscription.go | 120 ++++ .../method_listbysubscription_autorest.go | 216 ------ .../2023-07-01/vaults/method_listdeleted.go | 92 +++ .../vaults/method_listdeleted_autorest.go | 187 ----- .../2023-07-01/vaults/method_purgedeleted.go | 70 ++ .../vaults/method_purgedeleted_autorest.go | 78 --- .../2023-07-01/vaults/method_update.go | 57 ++ .../vaults/method_update_autorest.go | 70 -- .../vaults/method_updateaccesspolicy.go | 56 ++ .../method_updateaccesspolicy_autorest.go | 69 -- 475 files changed, 4441 insertions(+), 31589 deletions(-) delete mode 100644 resource-manager/keyvault/2021-10-01/client.go delete mode 100644 resource-manager/keyvault/2021-10-01/keys/README.md delete mode 100644 resource-manager/keyvault/2021-10-01/keys/client.go delete mode 100644 resource-manager/keyvault/2021-10-01/keys/constants.go delete mode 100644 resource-manager/keyvault/2021-10-01/keys/method_createifnotexist_autorest.go delete mode 100644 resource-manager/keyvault/2021-10-01/keys/method_get_autorest.go delete mode 100644 resource-manager/keyvault/2021-10-01/keys/method_getversion_autorest.go delete mode 100644 resource-manager/keyvault/2021-10-01/keys/method_list_autorest.go delete mode 100644 resource-manager/keyvault/2021-10-01/keys/method_listversions_autorest.go delete mode 100644 resource-manager/keyvault/2021-10-01/keys/model_key.go delete mode 100644 resource-manager/keyvault/2021-10-01/keys/model_keyattributes.go delete mode 100644 resource-manager/keyvault/2021-10-01/keys/model_keycreateparameters.go delete mode 100644 resource-manager/keyvault/2021-10-01/keys/model_keyproperties.go delete mode 100644 resource-manager/keyvault/2021-10-01/keys/predicates.go delete mode 100644 resource-manager/keyvault/2021-10-01/keys/version.go delete mode 100644 resource-manager/keyvault/2021-10-01/managedhsms/README.md delete mode 100644 resource-manager/keyvault/2021-10-01/managedhsms/client.go delete mode 100644 resource-manager/keyvault/2021-10-01/managedhsms/constants.go delete mode 100644 resource-manager/keyvault/2021-10-01/managedhsms/id_deletedmanagedhsm.go delete mode 100644 resource-manager/keyvault/2021-10-01/managedhsms/id_deletedmanagedhsm_test.go delete mode 100644 resource-manager/keyvault/2021-10-01/managedhsms/id_managedhsm.go delete mode 100644 resource-manager/keyvault/2021-10-01/managedhsms/id_managedhsm_test.go delete mode 100644 resource-manager/keyvault/2021-10-01/managedhsms/method_createorupdate_autorest.go delete mode 100644 resource-manager/keyvault/2021-10-01/managedhsms/method_delete_autorest.go delete mode 100644 resource-manager/keyvault/2021-10-01/managedhsms/method_get_autorest.go delete mode 100644 resource-manager/keyvault/2021-10-01/managedhsms/method_getdeleted_autorest.go delete mode 100644 resource-manager/keyvault/2021-10-01/managedhsms/method_listbyresourcegroup_autorest.go delete mode 100644 resource-manager/keyvault/2021-10-01/managedhsms/method_listbysubscription_autorest.go delete mode 100644 resource-manager/keyvault/2021-10-01/managedhsms/method_listdeleted_autorest.go delete mode 100644 resource-manager/keyvault/2021-10-01/managedhsms/method_purgedeleted_autorest.go delete mode 100644 resource-manager/keyvault/2021-10-01/managedhsms/method_update_autorest.go delete mode 100644 resource-manager/keyvault/2021-10-01/managedhsms/model_deletedmanagedhsm.go delete mode 100644 resource-manager/keyvault/2021-10-01/managedhsms/model_deletedmanagedhsmproperties.go delete mode 100644 resource-manager/keyvault/2021-10-01/managedhsms/model_managedhsm.go delete mode 100644 resource-manager/keyvault/2021-10-01/managedhsms/model_managedhsmproperties.go delete mode 100644 resource-manager/keyvault/2021-10-01/managedhsms/model_managedhsmsku.go delete mode 100644 resource-manager/keyvault/2021-10-01/managedhsms/model_mhsmiprule.go delete mode 100644 resource-manager/keyvault/2021-10-01/managedhsms/model_mhsmnetworkruleset.go delete mode 100644 resource-manager/keyvault/2021-10-01/managedhsms/model_mhsmprivateendpoint.go delete mode 100644 resource-manager/keyvault/2021-10-01/managedhsms/model_mhsmprivateendpointconnectionitem.go delete mode 100644 resource-manager/keyvault/2021-10-01/managedhsms/model_mhsmprivateendpointconnectionproperties.go delete mode 100644 resource-manager/keyvault/2021-10-01/managedhsms/model_mhsmprivatelinkserviceconnectionstate.go delete mode 100644 resource-manager/keyvault/2021-10-01/managedhsms/model_mhsmvirtualnetworkrule.go delete mode 100644 resource-manager/keyvault/2021-10-01/managedhsms/predicates.go delete mode 100644 resource-manager/keyvault/2021-10-01/managedhsms/version.go delete mode 100644 resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/README.md delete mode 100644 resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/client.go delete mode 100644 resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/constants.go delete mode 100644 resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/id_managedhsm.go delete mode 100644 resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/id_managedhsm_test.go delete mode 100644 resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/method_mhsmprivateendpointconnectionslistbyresource_autorest.go delete mode 100644 resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/model_managedhsmsku.go delete mode 100644 resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/model_mhsmprivateendpoint.go delete mode 100644 resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/model_mhsmprivateendpointconnection.go delete mode 100644 resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/model_mhsmprivateendpointconnectionproperties.go delete mode 100644 resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/model_mhsmprivatelinkserviceconnectionstate.go delete mode 100644 resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/predicates.go delete mode 100644 resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/version.go delete mode 100644 resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/README.md delete mode 100644 resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/client.go delete mode 100644 resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/constants.go delete mode 100644 resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/id_privateendpointconnection.go delete mode 100644 resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/id_privateendpointconnection_test.go delete mode 100644 resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/method_delete_autorest.go delete mode 100644 resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/method_get_autorest.go delete mode 100644 resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/method_put_autorest.go delete mode 100644 resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/model_managedhsmsku.go delete mode 100644 resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/model_mhsmprivateendpoint.go delete mode 100644 resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/model_mhsmprivateendpointconnection.go delete mode 100644 resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/model_mhsmprivateendpointconnectionproperties.go delete mode 100644 resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/model_mhsmprivatelinkserviceconnectionstate.go delete mode 100644 resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/version.go delete mode 100644 resource-manager/keyvault/2021-10-01/mhsmprivatelinkresources/README.md delete mode 100644 resource-manager/keyvault/2021-10-01/mhsmprivatelinkresources/client.go delete mode 100644 resource-manager/keyvault/2021-10-01/mhsmprivatelinkresources/constants.go delete mode 100644 resource-manager/keyvault/2021-10-01/mhsmprivatelinkresources/id_managedhsm.go delete mode 100644 resource-manager/keyvault/2021-10-01/mhsmprivatelinkresources/id_managedhsm_test.go delete mode 100644 resource-manager/keyvault/2021-10-01/mhsmprivatelinkresources/method_listbymhsmresource_autorest.go delete mode 100644 resource-manager/keyvault/2021-10-01/mhsmprivatelinkresources/model_managedhsmsku.go delete mode 100644 resource-manager/keyvault/2021-10-01/mhsmprivatelinkresources/model_mhsmprivatelinkresource.go delete mode 100644 resource-manager/keyvault/2021-10-01/mhsmprivatelinkresources/model_mhsmprivatelinkresourcelistresult.go delete mode 100644 resource-manager/keyvault/2021-10-01/mhsmprivatelinkresources/model_mhsmprivatelinkresourceproperties.go delete mode 100644 resource-manager/keyvault/2021-10-01/mhsmprivatelinkresources/version.go delete mode 100644 resource-manager/keyvault/2021-10-01/privateendpointconnections/README.md delete mode 100644 resource-manager/keyvault/2021-10-01/privateendpointconnections/client.go delete mode 100644 resource-manager/keyvault/2021-10-01/privateendpointconnections/constants.go delete mode 100644 resource-manager/keyvault/2021-10-01/privateendpointconnections/method_delete_autorest.go delete mode 100644 resource-manager/keyvault/2021-10-01/privateendpointconnections/method_get_autorest.go delete mode 100644 resource-manager/keyvault/2021-10-01/privateendpointconnections/method_listbyresource_autorest.go delete mode 100644 resource-manager/keyvault/2021-10-01/privateendpointconnections/method_put_autorest.go delete mode 100644 resource-manager/keyvault/2021-10-01/privateendpointconnections/model_privateendpoint.go delete mode 100644 resource-manager/keyvault/2021-10-01/privateendpointconnections/model_privateendpointconnection.go delete mode 100644 resource-manager/keyvault/2021-10-01/privateendpointconnections/model_privateendpointconnectionproperties.go delete mode 100644 resource-manager/keyvault/2021-10-01/privateendpointconnections/model_privatelinkserviceconnectionstate.go delete mode 100644 resource-manager/keyvault/2021-10-01/privateendpointconnections/predicates.go delete mode 100644 resource-manager/keyvault/2021-10-01/privateendpointconnections/version.go delete mode 100644 resource-manager/keyvault/2021-10-01/privatelinkresources/README.md delete mode 100644 resource-manager/keyvault/2021-10-01/privatelinkresources/client.go delete mode 100644 resource-manager/keyvault/2021-10-01/privatelinkresources/method_listbyvault_autorest.go delete mode 100644 resource-manager/keyvault/2021-10-01/privatelinkresources/model_privatelinkresource.go delete mode 100644 resource-manager/keyvault/2021-10-01/privatelinkresources/model_privatelinkresourcelistresult.go delete mode 100644 resource-manager/keyvault/2021-10-01/privatelinkresources/model_privatelinkresourceproperties.go delete mode 100644 resource-manager/keyvault/2021-10-01/privatelinkresources/version.go delete mode 100644 resource-manager/keyvault/2021-10-01/secrets/README.md delete mode 100644 resource-manager/keyvault/2021-10-01/secrets/client.go delete mode 100644 resource-manager/keyvault/2021-10-01/secrets/id_secret.go delete mode 100644 resource-manager/keyvault/2021-10-01/secrets/id_secret_test.go delete mode 100644 resource-manager/keyvault/2021-10-01/secrets/method_createorupdate_autorest.go delete mode 100644 resource-manager/keyvault/2021-10-01/secrets/method_get_autorest.go delete mode 100644 resource-manager/keyvault/2021-10-01/secrets/method_list_autorest.go delete mode 100644 resource-manager/keyvault/2021-10-01/secrets/method_update_autorest.go delete mode 100644 resource-manager/keyvault/2021-10-01/secrets/model_attributes.go delete mode 100644 resource-manager/keyvault/2021-10-01/secrets/model_secret.go delete mode 100644 resource-manager/keyvault/2021-10-01/secrets/model_secretcreateorupdateparameters.go delete mode 100644 resource-manager/keyvault/2021-10-01/secrets/model_secretpatchparameters.go delete mode 100644 resource-manager/keyvault/2021-10-01/secrets/model_secretpatchproperties.go delete mode 100644 resource-manager/keyvault/2021-10-01/secrets/model_secretproperties.go delete mode 100644 resource-manager/keyvault/2021-10-01/secrets/predicates.go delete mode 100644 resource-manager/keyvault/2021-10-01/secrets/version.go delete mode 100644 resource-manager/keyvault/2021-10-01/vaults/README.md delete mode 100644 resource-manager/keyvault/2021-10-01/vaults/client.go delete mode 100644 resource-manager/keyvault/2021-10-01/vaults/constants.go delete mode 100644 resource-manager/keyvault/2021-10-01/vaults/id_deletedvault.go delete mode 100644 resource-manager/keyvault/2021-10-01/vaults/id_deletedvault_test.go delete mode 100644 resource-manager/keyvault/2021-10-01/vaults/id_operationkind.go delete mode 100644 resource-manager/keyvault/2021-10-01/vaults/id_operationkind_test.go delete mode 100644 resource-manager/keyvault/2021-10-01/vaults/method_checknameavailability_autorest.go delete mode 100644 resource-manager/keyvault/2021-10-01/vaults/method_createorupdate_autorest.go delete mode 100644 resource-manager/keyvault/2021-10-01/vaults/method_delete_autorest.go delete mode 100644 resource-manager/keyvault/2021-10-01/vaults/method_get_autorest.go delete mode 100644 resource-manager/keyvault/2021-10-01/vaults/method_getdeleted_autorest.go delete mode 100644 resource-manager/keyvault/2021-10-01/vaults/method_list_autorest.go delete mode 100644 resource-manager/keyvault/2021-10-01/vaults/method_listbyresourcegroup_autorest.go delete mode 100644 resource-manager/keyvault/2021-10-01/vaults/method_listbysubscription_autorest.go delete mode 100644 resource-manager/keyvault/2021-10-01/vaults/method_listdeleted_autorest.go delete mode 100644 resource-manager/keyvault/2021-10-01/vaults/method_purgedeleted_autorest.go delete mode 100644 resource-manager/keyvault/2021-10-01/vaults/method_update_autorest.go delete mode 100644 resource-manager/keyvault/2021-10-01/vaults/method_updateaccesspolicy_autorest.go delete mode 100644 resource-manager/keyvault/2021-10-01/vaults/model_accesspolicyentry.go delete mode 100644 resource-manager/keyvault/2021-10-01/vaults/model_checknameavailabilityresult.go delete mode 100644 resource-manager/keyvault/2021-10-01/vaults/model_deletedvault.go delete mode 100644 resource-manager/keyvault/2021-10-01/vaults/model_deletedvaultproperties.go delete mode 100644 resource-manager/keyvault/2021-10-01/vaults/model_iprule.go delete mode 100644 resource-manager/keyvault/2021-10-01/vaults/model_networkruleset.go delete mode 100644 resource-manager/keyvault/2021-10-01/vaults/model_permissions.go delete mode 100644 resource-manager/keyvault/2021-10-01/vaults/model_privateendpoint.go delete mode 100644 resource-manager/keyvault/2021-10-01/vaults/model_privateendpointconnectionitem.go delete mode 100644 resource-manager/keyvault/2021-10-01/vaults/model_privateendpointconnectionproperties.go delete mode 100644 resource-manager/keyvault/2021-10-01/vaults/model_privatelinkserviceconnectionstate.go delete mode 100644 resource-manager/keyvault/2021-10-01/vaults/model_resource.go delete mode 100644 resource-manager/keyvault/2021-10-01/vaults/model_sku.go delete mode 100644 resource-manager/keyvault/2021-10-01/vaults/model_vault.go delete mode 100644 resource-manager/keyvault/2021-10-01/vaults/model_vaultaccesspolicyparameters.go delete mode 100644 resource-manager/keyvault/2021-10-01/vaults/model_vaultaccesspolicyproperties.go delete mode 100644 resource-manager/keyvault/2021-10-01/vaults/model_vaultchecknameavailabilityparameters.go delete mode 100644 resource-manager/keyvault/2021-10-01/vaults/model_vaultcreateorupdateparameters.go delete mode 100644 resource-manager/keyvault/2021-10-01/vaults/model_vaultpatchparameters.go delete mode 100644 resource-manager/keyvault/2021-10-01/vaults/model_vaultpatchproperties.go delete mode 100644 resource-manager/keyvault/2021-10-01/vaults/model_vaultproperties.go delete mode 100644 resource-manager/keyvault/2021-10-01/vaults/model_virtualnetworkrule.go delete mode 100644 resource-manager/keyvault/2021-10-01/vaults/predicates.go delete mode 100644 resource-manager/keyvault/2021-10-01/vaults/version.go delete mode 100644 resource-manager/keyvault/2022-11-01/client.go delete mode 100644 resource-manager/keyvault/2022-11-01/keys/README.md delete mode 100644 resource-manager/keyvault/2022-11-01/keys/client.go delete mode 100644 resource-manager/keyvault/2022-11-01/keys/constants.go delete mode 100644 resource-manager/keyvault/2022-11-01/keys/method_createifnotexist_autorest.go delete mode 100644 resource-manager/keyvault/2022-11-01/keys/method_get_autorest.go delete mode 100644 resource-manager/keyvault/2022-11-01/keys/method_getversion_autorest.go delete mode 100644 resource-manager/keyvault/2022-11-01/keys/method_list_autorest.go delete mode 100644 resource-manager/keyvault/2022-11-01/keys/method_listversions_autorest.go delete mode 100644 resource-manager/keyvault/2022-11-01/keys/model_action.go delete mode 100644 resource-manager/keyvault/2022-11-01/keys/model_key.go delete mode 100644 resource-manager/keyvault/2022-11-01/keys/model_keyattributes.go delete mode 100644 resource-manager/keyvault/2022-11-01/keys/model_keycreateparameters.go delete mode 100644 resource-manager/keyvault/2022-11-01/keys/model_keyproperties.go delete mode 100644 resource-manager/keyvault/2022-11-01/keys/model_keyreleasepolicy.go delete mode 100644 resource-manager/keyvault/2022-11-01/keys/model_keyrotationpolicyattributes.go delete mode 100644 resource-manager/keyvault/2022-11-01/keys/model_lifetimeaction.go delete mode 100644 resource-manager/keyvault/2022-11-01/keys/model_rotationpolicy.go delete mode 100644 resource-manager/keyvault/2022-11-01/keys/model_trigger.go delete mode 100644 resource-manager/keyvault/2022-11-01/keys/predicates.go delete mode 100644 resource-manager/keyvault/2022-11-01/keys/version.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsmkeys/README.md delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsmkeys/client.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsmkeys/constants.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsmkeys/id_key.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsmkeys/id_key_test.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsmkeys/id_managedhsm.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsmkeys/id_managedhsm_test.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsmkeys/id_version.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsmkeys/id_version_test.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsmkeys/method_createifnotexist_autorest.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsmkeys/method_get_autorest.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsmkeys/method_getversion_autorest.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsmkeys/method_list_autorest.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsmkeys/method_listversions_autorest.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsmkeys/model_managedhsmaction.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsmkeys/model_managedhsmkey.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsmkeys/model_managedhsmkeyattributes.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsmkeys/model_managedhsmkeycreateparameters.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsmkeys/model_managedhsmkeyproperties.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsmkeys/model_managedhsmkeyreleasepolicy.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsmkeys/model_managedhsmkeyrotationpolicyattributes.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsmkeys/model_managedhsmlifetimeaction.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsmkeys/model_managedhsmrotationpolicy.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsmkeys/model_managedhsmtrigger.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsmkeys/predicates.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsmkeys/version.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsms/README.md delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsms/client.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsms/constants.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsms/id_deletedmanagedhsm.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsms/id_deletedmanagedhsm_test.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsms/id_managedhsm.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsms/id_managedhsm_test.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsms/method_checkmhsmnameavailability_autorest.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsms/method_createorupdate_autorest.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsms/method_delete_autorest.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsms/method_get_autorest.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsms/method_getdeleted_autorest.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsms/method_listbyresourcegroup_autorest.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsms/method_listbysubscription_autorest.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsms/method_listdeleted_autorest.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsms/method_purgedeleted_autorest.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsms/method_update_autorest.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsms/model_checkmhsmnameavailabilityparameters.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsms/model_checkmhsmnameavailabilityresult.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsms/model_deletedmanagedhsm.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsms/model_deletedmanagedhsmproperties.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsms/model_managedhsm.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsms/model_managedhsmproperties.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsms/model_managedhsmsecuritydomainproperties.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsms/model_managedhsmsku.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsms/model_mhsmiprule.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsms/model_mhsmnetworkruleset.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsms/model_mhsmprivateendpoint.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsms/model_mhsmprivateendpointconnectionitem.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsms/model_mhsmprivateendpointconnectionproperties.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsms/model_mhsmprivatelinkserviceconnectionstate.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsms/model_mhsmvirtualnetworkrule.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsms/predicates.go delete mode 100644 resource-manager/keyvault/2022-11-01/managedhsms/version.go delete mode 100644 resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/README.md delete mode 100644 resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/client.go delete mode 100644 resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/constants.go delete mode 100644 resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/id_managedhsm.go delete mode 100644 resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/id_managedhsm_test.go delete mode 100644 resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/method_mhsmprivateendpointconnectionslistbyresource_autorest.go delete mode 100644 resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/model_managedhsmsku.go delete mode 100644 resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/model_mhsmprivateendpoint.go delete mode 100644 resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/model_mhsmprivateendpointconnection.go delete mode 100644 resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/model_mhsmprivateendpointconnectionproperties.go delete mode 100644 resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/model_mhsmprivatelinkserviceconnectionstate.go delete mode 100644 resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/predicates.go delete mode 100644 resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/version.go delete mode 100644 resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/README.md delete mode 100644 resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/client.go delete mode 100644 resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/constants.go delete mode 100644 resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/id_privateendpointconnection.go delete mode 100644 resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/id_privateendpointconnection_test.go delete mode 100644 resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/method_delete_autorest.go delete mode 100644 resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/method_get_autorest.go delete mode 100644 resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/method_put_autorest.go delete mode 100644 resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/model_managedhsmsku.go delete mode 100644 resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/model_mhsmprivateendpoint.go delete mode 100644 resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/model_mhsmprivateendpointconnection.go delete mode 100644 resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/model_mhsmprivateendpointconnectionproperties.go delete mode 100644 resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/model_mhsmprivatelinkserviceconnectionstate.go delete mode 100644 resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/version.go delete mode 100644 resource-manager/keyvault/2022-11-01/mhsmprivatelinkresources/README.md delete mode 100644 resource-manager/keyvault/2022-11-01/mhsmprivatelinkresources/client.go delete mode 100644 resource-manager/keyvault/2022-11-01/mhsmprivatelinkresources/constants.go delete mode 100644 resource-manager/keyvault/2022-11-01/mhsmprivatelinkresources/id_managedhsm.go delete mode 100644 resource-manager/keyvault/2022-11-01/mhsmprivatelinkresources/id_managedhsm_test.go delete mode 100644 resource-manager/keyvault/2022-11-01/mhsmprivatelinkresources/method_listbymhsmresource_autorest.go delete mode 100644 resource-manager/keyvault/2022-11-01/mhsmprivatelinkresources/model_managedhsmsku.go delete mode 100644 resource-manager/keyvault/2022-11-01/mhsmprivatelinkresources/model_mhsmprivatelinkresource.go delete mode 100644 resource-manager/keyvault/2022-11-01/mhsmprivatelinkresources/model_mhsmprivatelinkresourcelistresult.go delete mode 100644 resource-manager/keyvault/2022-11-01/mhsmprivatelinkresources/model_mhsmprivatelinkresourceproperties.go delete mode 100644 resource-manager/keyvault/2022-11-01/mhsmprivatelinkresources/version.go delete mode 100644 resource-manager/keyvault/2022-11-01/privateendpointconnections/README.md delete mode 100644 resource-manager/keyvault/2022-11-01/privateendpointconnections/client.go delete mode 100644 resource-manager/keyvault/2022-11-01/privateendpointconnections/constants.go delete mode 100644 resource-manager/keyvault/2022-11-01/privateendpointconnections/method_delete_autorest.go delete mode 100644 resource-manager/keyvault/2022-11-01/privateendpointconnections/method_get_autorest.go delete mode 100644 resource-manager/keyvault/2022-11-01/privateendpointconnections/method_listbyresource_autorest.go delete mode 100644 resource-manager/keyvault/2022-11-01/privateendpointconnections/method_put_autorest.go delete mode 100644 resource-manager/keyvault/2022-11-01/privateendpointconnections/model_privateendpoint.go delete mode 100644 resource-manager/keyvault/2022-11-01/privateendpointconnections/model_privateendpointconnection.go delete mode 100644 resource-manager/keyvault/2022-11-01/privateendpointconnections/model_privateendpointconnectionproperties.go delete mode 100644 resource-manager/keyvault/2022-11-01/privateendpointconnections/model_privatelinkserviceconnectionstate.go delete mode 100644 resource-manager/keyvault/2022-11-01/privateendpointconnections/predicates.go delete mode 100644 resource-manager/keyvault/2022-11-01/privateendpointconnections/version.go delete mode 100644 resource-manager/keyvault/2022-11-01/privatelinkresources/README.md delete mode 100644 resource-manager/keyvault/2022-11-01/privatelinkresources/client.go delete mode 100644 resource-manager/keyvault/2022-11-01/privatelinkresources/method_listbyvault_autorest.go delete mode 100644 resource-manager/keyvault/2022-11-01/privatelinkresources/model_privatelinkresource.go delete mode 100644 resource-manager/keyvault/2022-11-01/privatelinkresources/model_privatelinkresourcelistresult.go delete mode 100644 resource-manager/keyvault/2022-11-01/privatelinkresources/model_privatelinkresourceproperties.go delete mode 100644 resource-manager/keyvault/2022-11-01/privatelinkresources/version.go delete mode 100644 resource-manager/keyvault/2022-11-01/secrets/README.md delete mode 100644 resource-manager/keyvault/2022-11-01/secrets/client.go delete mode 100644 resource-manager/keyvault/2022-11-01/secrets/id_secret.go delete mode 100644 resource-manager/keyvault/2022-11-01/secrets/id_secret_test.go delete mode 100644 resource-manager/keyvault/2022-11-01/secrets/method_createorupdate_autorest.go delete mode 100644 resource-manager/keyvault/2022-11-01/secrets/method_get_autorest.go delete mode 100644 resource-manager/keyvault/2022-11-01/secrets/method_list_autorest.go delete mode 100644 resource-manager/keyvault/2022-11-01/secrets/method_update_autorest.go delete mode 100644 resource-manager/keyvault/2022-11-01/secrets/model_attributes.go delete mode 100644 resource-manager/keyvault/2022-11-01/secrets/model_secret.go delete mode 100644 resource-manager/keyvault/2022-11-01/secrets/model_secretcreateorupdateparameters.go delete mode 100644 resource-manager/keyvault/2022-11-01/secrets/model_secretpatchparameters.go delete mode 100644 resource-manager/keyvault/2022-11-01/secrets/model_secretpatchproperties.go delete mode 100644 resource-manager/keyvault/2022-11-01/secrets/model_secretproperties.go delete mode 100644 resource-manager/keyvault/2022-11-01/secrets/predicates.go delete mode 100644 resource-manager/keyvault/2022-11-01/secrets/version.go delete mode 100644 resource-manager/keyvault/2022-11-01/vaults/README.md delete mode 100644 resource-manager/keyvault/2022-11-01/vaults/client.go delete mode 100644 resource-manager/keyvault/2022-11-01/vaults/constants.go delete mode 100644 resource-manager/keyvault/2022-11-01/vaults/id_deletedvault.go delete mode 100644 resource-manager/keyvault/2022-11-01/vaults/id_deletedvault_test.go delete mode 100644 resource-manager/keyvault/2022-11-01/vaults/id_operationkind.go delete mode 100644 resource-manager/keyvault/2022-11-01/vaults/id_operationkind_test.go delete mode 100644 resource-manager/keyvault/2022-11-01/vaults/method_checknameavailability_autorest.go delete mode 100644 resource-manager/keyvault/2022-11-01/vaults/method_createorupdate_autorest.go delete mode 100644 resource-manager/keyvault/2022-11-01/vaults/method_delete_autorest.go delete mode 100644 resource-manager/keyvault/2022-11-01/vaults/method_get_autorest.go delete mode 100644 resource-manager/keyvault/2022-11-01/vaults/method_getdeleted_autorest.go delete mode 100644 resource-manager/keyvault/2022-11-01/vaults/method_list_autorest.go delete mode 100644 resource-manager/keyvault/2022-11-01/vaults/method_listbyresourcegroup_autorest.go delete mode 100644 resource-manager/keyvault/2022-11-01/vaults/method_listbysubscription_autorest.go delete mode 100644 resource-manager/keyvault/2022-11-01/vaults/method_listdeleted_autorest.go delete mode 100644 resource-manager/keyvault/2022-11-01/vaults/method_purgedeleted_autorest.go delete mode 100644 resource-manager/keyvault/2022-11-01/vaults/method_update_autorest.go delete mode 100644 resource-manager/keyvault/2022-11-01/vaults/method_updateaccesspolicy_autorest.go delete mode 100644 resource-manager/keyvault/2022-11-01/vaults/model_accesspolicyentry.go delete mode 100644 resource-manager/keyvault/2022-11-01/vaults/model_checknameavailabilityresult.go delete mode 100644 resource-manager/keyvault/2022-11-01/vaults/model_deletedvault.go delete mode 100644 resource-manager/keyvault/2022-11-01/vaults/model_deletedvaultproperties.go delete mode 100644 resource-manager/keyvault/2022-11-01/vaults/model_iprule.go delete mode 100644 resource-manager/keyvault/2022-11-01/vaults/model_networkruleset.go delete mode 100644 resource-manager/keyvault/2022-11-01/vaults/model_permissions.go delete mode 100644 resource-manager/keyvault/2022-11-01/vaults/model_privateendpoint.go delete mode 100644 resource-manager/keyvault/2022-11-01/vaults/model_privateendpointconnectionitem.go delete mode 100644 resource-manager/keyvault/2022-11-01/vaults/model_privateendpointconnectionproperties.go delete mode 100644 resource-manager/keyvault/2022-11-01/vaults/model_privatelinkserviceconnectionstate.go delete mode 100644 resource-manager/keyvault/2022-11-01/vaults/model_resource.go delete mode 100644 resource-manager/keyvault/2022-11-01/vaults/model_sku.go delete mode 100644 resource-manager/keyvault/2022-11-01/vaults/model_vault.go delete mode 100644 resource-manager/keyvault/2022-11-01/vaults/model_vaultaccesspolicyparameters.go delete mode 100644 resource-manager/keyvault/2022-11-01/vaults/model_vaultaccesspolicyproperties.go delete mode 100644 resource-manager/keyvault/2022-11-01/vaults/model_vaultchecknameavailabilityparameters.go delete mode 100644 resource-manager/keyvault/2022-11-01/vaults/model_vaultcreateorupdateparameters.go delete mode 100644 resource-manager/keyvault/2022-11-01/vaults/model_vaultpatchparameters.go delete mode 100644 resource-manager/keyvault/2022-11-01/vaults/model_vaultpatchproperties.go delete mode 100644 resource-manager/keyvault/2022-11-01/vaults/model_vaultproperties.go delete mode 100644 resource-manager/keyvault/2022-11-01/vaults/model_virtualnetworkrule.go delete mode 100644 resource-manager/keyvault/2022-11-01/vaults/predicates.go delete mode 100644 resource-manager/keyvault/2022-11-01/vaults/version.go create mode 100644 resource-manager/keyvault/2023-07-01/keys/method_createifnotexist.go delete mode 100644 resource-manager/keyvault/2023-07-01/keys/method_createifnotexist_autorest.go create mode 100644 resource-manager/keyvault/2023-07-01/keys/method_get.go delete mode 100644 resource-manager/keyvault/2023-07-01/keys/method_get_autorest.go create mode 100644 resource-manager/keyvault/2023-07-01/keys/method_getversion.go delete mode 100644 resource-manager/keyvault/2023-07-01/keys/method_getversion_autorest.go create mode 100644 resource-manager/keyvault/2023-07-01/keys/method_list.go delete mode 100644 resource-manager/keyvault/2023-07-01/keys/method_list_autorest.go create mode 100644 resource-manager/keyvault/2023-07-01/keys/method_listversions.go delete mode 100644 resource-manager/keyvault/2023-07-01/keys/method_listversions_autorest.go create mode 100644 resource-manager/keyvault/2023-07-01/managedhsmkeys/method_createifnotexist.go delete mode 100644 resource-manager/keyvault/2023-07-01/managedhsmkeys/method_createifnotexist_autorest.go create mode 100644 resource-manager/keyvault/2023-07-01/managedhsmkeys/method_get.go delete mode 100644 resource-manager/keyvault/2023-07-01/managedhsmkeys/method_get_autorest.go create mode 100644 resource-manager/keyvault/2023-07-01/managedhsmkeys/method_getversion.go delete mode 100644 resource-manager/keyvault/2023-07-01/managedhsmkeys/method_getversion_autorest.go create mode 100644 resource-manager/keyvault/2023-07-01/managedhsmkeys/method_list.go delete mode 100644 resource-manager/keyvault/2023-07-01/managedhsmkeys/method_list_autorest.go create mode 100644 resource-manager/keyvault/2023-07-01/managedhsmkeys/method_listversions.go delete mode 100644 resource-manager/keyvault/2023-07-01/managedhsmkeys/method_listversions_autorest.go create mode 100644 resource-manager/keyvault/2023-07-01/managedhsms/method_checkmhsmnameavailability.go delete mode 100644 resource-manager/keyvault/2023-07-01/managedhsms/method_checkmhsmnameavailability_autorest.go create mode 100644 resource-manager/keyvault/2023-07-01/managedhsms/method_createorupdate.go delete mode 100644 resource-manager/keyvault/2023-07-01/managedhsms/method_createorupdate_autorest.go create mode 100644 resource-manager/keyvault/2023-07-01/managedhsms/method_delete.go delete mode 100644 resource-manager/keyvault/2023-07-01/managedhsms/method_delete_autorest.go create mode 100644 resource-manager/keyvault/2023-07-01/managedhsms/method_get.go delete mode 100644 resource-manager/keyvault/2023-07-01/managedhsms/method_get_autorest.go create mode 100644 resource-manager/keyvault/2023-07-01/managedhsms/method_getdeleted.go delete mode 100644 resource-manager/keyvault/2023-07-01/managedhsms/method_getdeleted_autorest.go create mode 100644 resource-manager/keyvault/2023-07-01/managedhsms/method_listbyresourcegroup.go delete mode 100644 resource-manager/keyvault/2023-07-01/managedhsms/method_listbyresourcegroup_autorest.go create mode 100644 resource-manager/keyvault/2023-07-01/managedhsms/method_listbysubscription.go delete mode 100644 resource-manager/keyvault/2023-07-01/managedhsms/method_listbysubscription_autorest.go create mode 100644 resource-manager/keyvault/2023-07-01/managedhsms/method_listdeleted.go delete mode 100644 resource-manager/keyvault/2023-07-01/managedhsms/method_listdeleted_autorest.go create mode 100644 resource-manager/keyvault/2023-07-01/managedhsms/method_purgedeleted.go delete mode 100644 resource-manager/keyvault/2023-07-01/managedhsms/method_purgedeleted_autorest.go create mode 100644 resource-manager/keyvault/2023-07-01/managedhsms/method_update.go delete mode 100644 resource-manager/keyvault/2023-07-01/managedhsms/method_update_autorest.go create mode 100644 resource-manager/keyvault/2023-07-01/mhsmlistprivateendpointconnections/method_mhsmprivateendpointconnectionslistbyresource.go delete mode 100644 resource-manager/keyvault/2023-07-01/mhsmlistprivateendpointconnections/method_mhsmprivateendpointconnectionslistbyresource_autorest.go create mode 100644 resource-manager/keyvault/2023-07-01/mhsmlistregions/method_mhsmregionslistbyresource.go delete mode 100644 resource-manager/keyvault/2023-07-01/mhsmlistregions/method_mhsmregionslistbyresource_autorest.go create mode 100644 resource-manager/keyvault/2023-07-01/mhsmprivateendpointconnections/method_delete.go delete mode 100644 resource-manager/keyvault/2023-07-01/mhsmprivateendpointconnections/method_delete_autorest.go create mode 100644 resource-manager/keyvault/2023-07-01/mhsmprivateendpointconnections/method_get.go delete mode 100644 resource-manager/keyvault/2023-07-01/mhsmprivateendpointconnections/method_get_autorest.go create mode 100644 resource-manager/keyvault/2023-07-01/mhsmprivateendpointconnections/method_put.go delete mode 100644 resource-manager/keyvault/2023-07-01/mhsmprivateendpointconnections/method_put_autorest.go create mode 100644 resource-manager/keyvault/2023-07-01/mhsmprivatelinkresources/method_listbymhsmresource.go delete mode 100644 resource-manager/keyvault/2023-07-01/mhsmprivatelinkresources/method_listbymhsmresource_autorest.go create mode 100644 resource-manager/keyvault/2023-07-01/privateendpointconnections/method_delete.go delete mode 100644 resource-manager/keyvault/2023-07-01/privateendpointconnections/method_delete_autorest.go create mode 100644 resource-manager/keyvault/2023-07-01/privateendpointconnections/method_get.go delete mode 100644 resource-manager/keyvault/2023-07-01/privateendpointconnections/method_get_autorest.go create mode 100644 resource-manager/keyvault/2023-07-01/privateendpointconnections/method_listbyresource.go delete mode 100644 resource-manager/keyvault/2023-07-01/privateendpointconnections/method_listbyresource_autorest.go create mode 100644 resource-manager/keyvault/2023-07-01/privateendpointconnections/method_put.go delete mode 100644 resource-manager/keyvault/2023-07-01/privateendpointconnections/method_put_autorest.go create mode 100644 resource-manager/keyvault/2023-07-01/privatelinkresources/method_listbyvault.go delete mode 100644 resource-manager/keyvault/2023-07-01/privatelinkresources/method_listbyvault_autorest.go create mode 100644 resource-manager/keyvault/2023-07-01/secrets/method_createorupdate.go delete mode 100644 resource-manager/keyvault/2023-07-01/secrets/method_createorupdate_autorest.go create mode 100644 resource-manager/keyvault/2023-07-01/secrets/method_get.go delete mode 100644 resource-manager/keyvault/2023-07-01/secrets/method_get_autorest.go create mode 100644 resource-manager/keyvault/2023-07-01/secrets/method_list.go delete mode 100644 resource-manager/keyvault/2023-07-01/secrets/method_list_autorest.go create mode 100644 resource-manager/keyvault/2023-07-01/secrets/method_update.go delete mode 100644 resource-manager/keyvault/2023-07-01/secrets/method_update_autorest.go create mode 100644 resource-manager/keyvault/2023-07-01/vaults/method_checknameavailability.go delete mode 100644 resource-manager/keyvault/2023-07-01/vaults/method_checknameavailability_autorest.go create mode 100644 resource-manager/keyvault/2023-07-01/vaults/method_createorupdate.go delete mode 100644 resource-manager/keyvault/2023-07-01/vaults/method_createorupdate_autorest.go create mode 100644 resource-manager/keyvault/2023-07-01/vaults/method_delete.go delete mode 100644 resource-manager/keyvault/2023-07-01/vaults/method_delete_autorest.go create mode 100644 resource-manager/keyvault/2023-07-01/vaults/method_get.go delete mode 100644 resource-manager/keyvault/2023-07-01/vaults/method_get_autorest.go create mode 100644 resource-manager/keyvault/2023-07-01/vaults/method_getdeleted.go delete mode 100644 resource-manager/keyvault/2023-07-01/vaults/method_getdeleted_autorest.go create mode 100644 resource-manager/keyvault/2023-07-01/vaults/method_list.go delete mode 100644 resource-manager/keyvault/2023-07-01/vaults/method_list_autorest.go create mode 100644 resource-manager/keyvault/2023-07-01/vaults/method_listbyresourcegroup.go delete mode 100644 resource-manager/keyvault/2023-07-01/vaults/method_listbyresourcegroup_autorest.go create mode 100644 resource-manager/keyvault/2023-07-01/vaults/method_listbysubscription.go delete mode 100644 resource-manager/keyvault/2023-07-01/vaults/method_listbysubscription_autorest.go create mode 100644 resource-manager/keyvault/2023-07-01/vaults/method_listdeleted.go delete mode 100644 resource-manager/keyvault/2023-07-01/vaults/method_listdeleted_autorest.go create mode 100644 resource-manager/keyvault/2023-07-01/vaults/method_purgedeleted.go delete mode 100644 resource-manager/keyvault/2023-07-01/vaults/method_purgedeleted_autorest.go create mode 100644 resource-manager/keyvault/2023-07-01/vaults/method_update.go delete mode 100644 resource-manager/keyvault/2023-07-01/vaults/method_update_autorest.go create mode 100644 resource-manager/keyvault/2023-07-01/vaults/method_updateaccesspolicy.go delete mode 100644 resource-manager/keyvault/2023-07-01/vaults/method_updateaccesspolicy_autorest.go diff --git a/resource-manager/keyvault/2021-10-01/client.go b/resource-manager/keyvault/2021-10-01/client.go deleted file mode 100644 index eccb4165ef2..00000000000 --- a/resource-manager/keyvault/2021-10-01/client.go +++ /dev/null @@ -1,71 +0,0 @@ -package v2021_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 ( - "github.com/Azure/go-autorest/autorest" - "github.com/hashicorp/go-azure-sdk/resource-manager/keyvault/2021-10-01/keys" - "github.com/hashicorp/go-azure-sdk/resource-manager/keyvault/2021-10-01/managedhsms" - "github.com/hashicorp/go-azure-sdk/resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections" - "github.com/hashicorp/go-azure-sdk/resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections" - "github.com/hashicorp/go-azure-sdk/resource-manager/keyvault/2021-10-01/mhsmprivatelinkresources" - "github.com/hashicorp/go-azure-sdk/resource-manager/keyvault/2021-10-01/privateendpointconnections" - "github.com/hashicorp/go-azure-sdk/resource-manager/keyvault/2021-10-01/privatelinkresources" - "github.com/hashicorp/go-azure-sdk/resource-manager/keyvault/2021-10-01/secrets" - "github.com/hashicorp/go-azure-sdk/resource-manager/keyvault/2021-10-01/vaults" -) - -type Client struct { - Keys *keys.KeysClient - MHSMListPrivateEndpointConnections *mhsmlistprivateendpointconnections.MHSMListPrivateEndpointConnectionsClient - MHSMPrivateEndpointConnections *mhsmprivateendpointconnections.MHSMPrivateEndpointConnectionsClient - MHSMPrivateLinkResources *mhsmprivatelinkresources.MHSMPrivateLinkResourcesClient - ManagedHsms *managedhsms.ManagedHsmsClient - PrivateEndpointConnections *privateendpointconnections.PrivateEndpointConnectionsClient - PrivateLinkResources *privatelinkresources.PrivateLinkResourcesClient - Secrets *secrets.SecretsClient - Vaults *vaults.VaultsClient -} - -func NewClientWithBaseURI(endpoint string, configureAuthFunc func(c *autorest.Client)) Client { - - keysClient := keys.NewKeysClientWithBaseURI(endpoint) - configureAuthFunc(&keysClient.Client) - - mHSMListPrivateEndpointConnectionsClient := mhsmlistprivateendpointconnections.NewMHSMListPrivateEndpointConnectionsClientWithBaseURI(endpoint) - configureAuthFunc(&mHSMListPrivateEndpointConnectionsClient.Client) - - mHSMPrivateEndpointConnectionsClient := mhsmprivateendpointconnections.NewMHSMPrivateEndpointConnectionsClientWithBaseURI(endpoint) - configureAuthFunc(&mHSMPrivateEndpointConnectionsClient.Client) - - mHSMPrivateLinkResourcesClient := mhsmprivatelinkresources.NewMHSMPrivateLinkResourcesClientWithBaseURI(endpoint) - configureAuthFunc(&mHSMPrivateLinkResourcesClient.Client) - - managedHsmsClient := managedhsms.NewManagedHsmsClientWithBaseURI(endpoint) - configureAuthFunc(&managedHsmsClient.Client) - - privateEndpointConnectionsClient := privateendpointconnections.NewPrivateEndpointConnectionsClientWithBaseURI(endpoint) - configureAuthFunc(&privateEndpointConnectionsClient.Client) - - privateLinkResourcesClient := privatelinkresources.NewPrivateLinkResourcesClientWithBaseURI(endpoint) - configureAuthFunc(&privateLinkResourcesClient.Client) - - secretsClient := secrets.NewSecretsClientWithBaseURI(endpoint) - configureAuthFunc(&secretsClient.Client) - - vaultsClient := vaults.NewVaultsClientWithBaseURI(endpoint) - configureAuthFunc(&vaultsClient.Client) - - return Client{ - Keys: &keysClient, - MHSMListPrivateEndpointConnections: &mHSMListPrivateEndpointConnectionsClient, - MHSMPrivateEndpointConnections: &mHSMPrivateEndpointConnectionsClient, - MHSMPrivateLinkResources: &mHSMPrivateLinkResourcesClient, - ManagedHsms: &managedHsmsClient, - PrivateEndpointConnections: &privateEndpointConnectionsClient, - PrivateLinkResources: &privateLinkResourcesClient, - Secrets: &secretsClient, - Vaults: &vaultsClient, - } -} diff --git a/resource-manager/keyvault/2021-10-01/keys/README.md b/resource-manager/keyvault/2021-10-01/keys/README.md deleted file mode 100644 index b5ff593a67c..00000000000 --- a/resource-manager/keyvault/2021-10-01/keys/README.md +++ /dev/null @@ -1,107 +0,0 @@ - -## `github.com/hashicorp/go-azure-sdk/resource-manager/keyvault/2021-10-01/keys` Documentation - -The `keys` SDK allows for interaction with the Azure Resource Manager Service `keyvault` (API Version `2021-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/keyvault/2021-10-01/keys" -``` - - -### Client Initialization - -```go -client := keys.NewKeysClientWithBaseURI("https://management.azure.com") -client.Client.Authorizer = authorizer -``` - - -### Example Usage: `KeysClient.CreateIfNotExist` - -```go -ctx := context.TODO() -id := keys.NewKeyVaultKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "keyValue") - -payload := keys.KeyCreateParameters{ - // ... -} - - -read, err := client.CreateIfNotExist(ctx, id, payload) -if err != nil { - // handle the error -} -if model := read.Model; model != nil { - // do something with the model/response object -} -``` - - -### Example Usage: `KeysClient.Get` - -```go -ctx := context.TODO() -id := keys.NewKeyVaultKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "keyValue") - -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: `KeysClient.GetVersion` - -```go -ctx := context.TODO() -id := keys.NewKeyVaultKeyVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "keyValue", "versionValue") - -read, err := client.GetVersion(ctx, id) -if err != nil { - // handle the error -} -if model := read.Model; model != nil { - // do something with the model/response object -} -``` - - -### Example Usage: `KeysClient.List` - -```go -ctx := context.TODO() -id := keys.NewKeyVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") - -// 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: `KeysClient.ListVersions` - -```go -ctx := context.TODO() -id := keys.NewKeyVaultKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "keyValue") - -// alternatively `client.ListVersions(ctx, id)` can be used to do batched pagination -items, err := client.ListVersionsComplete(ctx, id) -if err != nil { - // handle the error -} -for _, item := range items { - // do something -} -``` diff --git a/resource-manager/keyvault/2021-10-01/keys/client.go b/resource-manager/keyvault/2021-10-01/keys/client.go deleted file mode 100644 index bc451013a0b..00000000000 --- a/resource-manager/keyvault/2021-10-01/keys/client.go +++ /dev/null @@ -1,18 +0,0 @@ -package keys - -import "github.com/Azure/go-autorest/autorest" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type KeysClient struct { - Client autorest.Client - baseUri string -} - -func NewKeysClientWithBaseURI(endpoint string) KeysClient { - return KeysClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/resource-manager/keyvault/2021-10-01/keys/constants.go b/resource-manager/keyvault/2021-10-01/keys/constants.go deleted file mode 100644 index abb6e6f810d..00000000000 --- a/resource-manager/keyvault/2021-10-01/keys/constants.go +++ /dev/null @@ -1,151 +0,0 @@ -package keys - -import "strings" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeletionRecoveryLevel string - -const ( - DeletionRecoveryLevelPurgeable DeletionRecoveryLevel = "Purgeable" - DeletionRecoveryLevelRecoverable DeletionRecoveryLevel = "Recoverable" - DeletionRecoveryLevelRecoverablePositiveProtectedSubscription DeletionRecoveryLevel = "Recoverable+ProtectedSubscription" - DeletionRecoveryLevelRecoverablePositivePurgeable DeletionRecoveryLevel = "Recoverable+Purgeable" -) - -func PossibleValuesForDeletionRecoveryLevel() []string { - return []string{ - string(DeletionRecoveryLevelPurgeable), - string(DeletionRecoveryLevelRecoverable), - string(DeletionRecoveryLevelRecoverablePositiveProtectedSubscription), - string(DeletionRecoveryLevelRecoverablePositivePurgeable), - } -} - -func parseDeletionRecoveryLevel(input string) (*DeletionRecoveryLevel, error) { - vals := map[string]DeletionRecoveryLevel{ - "purgeable": DeletionRecoveryLevelPurgeable, - "recoverable": DeletionRecoveryLevelRecoverable, - "recoverable+protectedsubscription": DeletionRecoveryLevelRecoverablePositiveProtectedSubscription, - "recoverable+purgeable": DeletionRecoveryLevelRecoverablePositivePurgeable, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := DeletionRecoveryLevel(input) - return &out, nil -} - -type JsonWebKeyCurveName string - -const ( - JsonWebKeyCurveNamePNegativeFiveTwoOne JsonWebKeyCurveName = "P-521" - JsonWebKeyCurveNamePNegativeThreeEightFour JsonWebKeyCurveName = "P-384" - JsonWebKeyCurveNamePNegativeTwoFiveSix JsonWebKeyCurveName = "P-256" - JsonWebKeyCurveNamePNegativeTwoFiveSixK JsonWebKeyCurveName = "P-256K" -) - -func PossibleValuesForJsonWebKeyCurveName() []string { - return []string{ - string(JsonWebKeyCurveNamePNegativeFiveTwoOne), - string(JsonWebKeyCurveNamePNegativeThreeEightFour), - string(JsonWebKeyCurveNamePNegativeTwoFiveSix), - string(JsonWebKeyCurveNamePNegativeTwoFiveSixK), - } -} - -func parseJsonWebKeyCurveName(input string) (*JsonWebKeyCurveName, error) { - vals := map[string]JsonWebKeyCurveName{ - "p-521": JsonWebKeyCurveNamePNegativeFiveTwoOne, - "p-384": JsonWebKeyCurveNamePNegativeThreeEightFour, - "p-256": JsonWebKeyCurveNamePNegativeTwoFiveSix, - "p-256k": JsonWebKeyCurveNamePNegativeTwoFiveSixK, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := JsonWebKeyCurveName(input) - return &out, nil -} - -type JsonWebKeyOperation string - -const ( - JsonWebKeyOperationDecrypt JsonWebKeyOperation = "decrypt" - JsonWebKeyOperationEncrypt JsonWebKeyOperation = "encrypt" - JsonWebKeyOperationImport JsonWebKeyOperation = "import" - JsonWebKeyOperationSign JsonWebKeyOperation = "sign" - JsonWebKeyOperationUnwrapKey JsonWebKeyOperation = "unwrapKey" - JsonWebKeyOperationVerify JsonWebKeyOperation = "verify" - JsonWebKeyOperationWrapKey JsonWebKeyOperation = "wrapKey" -) - -func PossibleValuesForJsonWebKeyOperation() []string { - return []string{ - string(JsonWebKeyOperationDecrypt), - string(JsonWebKeyOperationEncrypt), - string(JsonWebKeyOperationImport), - string(JsonWebKeyOperationSign), - string(JsonWebKeyOperationUnwrapKey), - string(JsonWebKeyOperationVerify), - string(JsonWebKeyOperationWrapKey), - } -} - -func parseJsonWebKeyOperation(input string) (*JsonWebKeyOperation, error) { - vals := map[string]JsonWebKeyOperation{ - "decrypt": JsonWebKeyOperationDecrypt, - "encrypt": JsonWebKeyOperationEncrypt, - "import": JsonWebKeyOperationImport, - "sign": JsonWebKeyOperationSign, - "unwrapkey": JsonWebKeyOperationUnwrapKey, - "verify": JsonWebKeyOperationVerify, - "wrapkey": JsonWebKeyOperationWrapKey, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := JsonWebKeyOperation(input) - return &out, nil -} - -type JsonWebKeyType string - -const ( - JsonWebKeyTypeEC JsonWebKeyType = "EC" - JsonWebKeyTypeECNegativeHSM JsonWebKeyType = "EC-HSM" - JsonWebKeyTypeRSA JsonWebKeyType = "RSA" - JsonWebKeyTypeRSANegativeHSM JsonWebKeyType = "RSA-HSM" -) - -func PossibleValuesForJsonWebKeyType() []string { - return []string{ - string(JsonWebKeyTypeEC), - string(JsonWebKeyTypeECNegativeHSM), - string(JsonWebKeyTypeRSA), - string(JsonWebKeyTypeRSANegativeHSM), - } -} - -func parseJsonWebKeyType(input string) (*JsonWebKeyType, error) { - vals := map[string]JsonWebKeyType{ - "ec": JsonWebKeyTypeEC, - "ec-hsm": JsonWebKeyTypeECNegativeHSM, - "rsa": JsonWebKeyTypeRSA, - "rsa-hsm": JsonWebKeyTypeRSANegativeHSM, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := JsonWebKeyType(input) - return &out, nil -} diff --git a/resource-manager/keyvault/2021-10-01/keys/method_createifnotexist_autorest.go b/resource-manager/keyvault/2021-10-01/keys/method_createifnotexist_autorest.go deleted file mode 100644 index 638f6c1d6b1..00000000000 --- a/resource-manager/keyvault/2021-10-01/keys/method_createifnotexist_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package keys - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateIfNotExistOperationResponse struct { - HttpResponse *http.Response - Model *Key -} - -// CreateIfNotExist ... -func (c KeysClient) CreateIfNotExist(ctx context.Context, id commonids.KeyVaultKeyId, input KeyCreateParameters) (result CreateIfNotExistOperationResponse, err error) { - req, err := c.preparerForCreateIfNotExist(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "CreateIfNotExist", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "CreateIfNotExist", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateIfNotExist(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "CreateIfNotExist", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateIfNotExist prepares the CreateIfNotExist request. -func (c KeysClient) preparerForCreateIfNotExist(ctx context.Context, id commonids.KeyVaultKeyId, input KeyCreateParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateIfNotExist handles the response to the CreateIfNotExist request. The method always -// closes the http.Response Body. -func (c KeysClient) responderForCreateIfNotExist(resp *http.Response) (result CreateIfNotExistOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2021-10-01/keys/method_get_autorest.go b/resource-manager/keyvault/2021-10-01/keys/method_get_autorest.go deleted file mode 100644 index 5d081998ae6..00000000000 --- a/resource-manager/keyvault/2021-10-01/keys/method_get_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package keys - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *Key -} - -// Get ... -func (c KeysClient) Get(ctx context.Context, id commonids.KeyVaultKeyId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c KeysClient) preparerForGet(ctx context.Context, id commonids.KeyVaultKeyId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c KeysClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2021-10-01/keys/method_getversion_autorest.go b/resource-manager/keyvault/2021-10-01/keys/method_getversion_autorest.go deleted file mode 100644 index 97ea758183b..00000000000 --- a/resource-manager/keyvault/2021-10-01/keys/method_getversion_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package keys - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetVersionOperationResponse struct { - HttpResponse *http.Response - Model *Key -} - -// GetVersion ... -func (c KeysClient) GetVersion(ctx context.Context, id commonids.KeyVaultKeyVersionId) (result GetVersionOperationResponse, err error) { - req, err := c.preparerForGetVersion(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "GetVersion", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "GetVersion", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetVersion(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "GetVersion", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetVersion prepares the GetVersion request. -func (c KeysClient) preparerForGetVersion(ctx context.Context, id commonids.KeyVaultKeyVersionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetVersion handles the response to the GetVersion request. The method always -// closes the http.Response Body. -func (c KeysClient) responderForGetVersion(resp *http.Response) (result GetVersionOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2021-10-01/keys/method_list_autorest.go b/resource-manager/keyvault/2021-10-01/keys/method_list_autorest.go deleted file mode 100644 index c0ac89d60ff..00000000000 --- a/resource-manager/keyvault/2021-10-01/keys/method_list_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package keys - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *[]Key - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []Key -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// List ... -func (c KeysClient) List(ctx context.Context, id commonids.KeyVaultId) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c KeysClient) preparerForList(ctx context.Context, id commonids.KeyVaultId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/keys", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c KeysClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c KeysClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []Key `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { - req, err := c.preparerForListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c KeysClient) ListComplete(ctx context.Context, id commonids.KeyVaultId) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, KeyOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c KeysClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.KeyVaultId, predicate KeyOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]Key, 0) - - page, err := c.List(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/keyvault/2021-10-01/keys/method_listversions_autorest.go b/resource-manager/keyvault/2021-10-01/keys/method_listversions_autorest.go deleted file mode 100644 index f88803ad5ef..00000000000 --- a/resource-manager/keyvault/2021-10-01/keys/method_listversions_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package keys - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListVersionsOperationResponse struct { - HttpResponse *http.Response - Model *[]Key - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListVersionsOperationResponse, error) -} - -type ListVersionsCompleteResult struct { - Items []Key -} - -func (r ListVersionsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListVersionsOperationResponse) LoadMore(ctx context.Context) (resp ListVersionsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListVersions ... -func (c KeysClient) ListVersions(ctx context.Context, id commonids.KeyVaultKeyId) (resp ListVersionsOperationResponse, err error) { - req, err := c.preparerForListVersions(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "ListVersions", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "ListVersions", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListVersions(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "ListVersions", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListVersions prepares the ListVersions request. -func (c KeysClient) preparerForListVersions(ctx context.Context, id commonids.KeyVaultKeyId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/versions", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListVersionsWithNextLink prepares the ListVersions request with the given nextLink token. -func (c KeysClient) preparerForListVersionsWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListVersions handles the response to the ListVersions request. The method always -// closes the http.Response Body. -func (c KeysClient) responderForListVersions(resp *http.Response) (result ListVersionsOperationResponse, err error) { - type page struct { - Values []Key `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListVersionsOperationResponse, err error) { - req, err := c.preparerForListVersionsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "ListVersions", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "ListVersions", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListVersions(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "ListVersions", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListVersionsComplete retrieves all of the results into a single object -func (c KeysClient) ListVersionsComplete(ctx context.Context, id commonids.KeyVaultKeyId) (ListVersionsCompleteResult, error) { - return c.ListVersionsCompleteMatchingPredicate(ctx, id, KeyOperationPredicate{}) -} - -// ListVersionsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c KeysClient) ListVersionsCompleteMatchingPredicate(ctx context.Context, id commonids.KeyVaultKeyId, predicate KeyOperationPredicate) (resp ListVersionsCompleteResult, err error) { - items := make([]Key, 0) - - page, err := c.ListVersions(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListVersionsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/keyvault/2021-10-01/keys/model_key.go b/resource-manager/keyvault/2021-10-01/keys/model_key.go deleted file mode 100644 index 60f6d4257d8..00000000000 --- a/resource-manager/keyvault/2021-10-01/keys/model_key.go +++ /dev/null @@ -1,13 +0,0 @@ -package keys - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type Key struct { - Id *string `json:"id,omitempty"` - Location *string `json:"location,omitempty"` - Name *string `json:"name,omitempty"` - Properties KeyProperties `json:"properties"` - Tags *map[string]string `json:"tags,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/resource-manager/keyvault/2021-10-01/keys/model_keyattributes.go b/resource-manager/keyvault/2021-10-01/keys/model_keyattributes.go deleted file mode 100644 index ba14a8921b0..00000000000 --- a/resource-manager/keyvault/2021-10-01/keys/model_keyattributes.go +++ /dev/null @@ -1,14 +0,0 @@ -package keys - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type KeyAttributes struct { - Created *int64 `json:"created,omitempty"` - Enabled *bool `json:"enabled,omitempty"` - Exp *int64 `json:"exp,omitempty"` - Exportable *bool `json:"exportable,omitempty"` - Nbf *int64 `json:"nbf,omitempty"` - RecoveryLevel *DeletionRecoveryLevel `json:"recoveryLevel,omitempty"` - Updated *int64 `json:"updated,omitempty"` -} diff --git a/resource-manager/keyvault/2021-10-01/keys/model_keycreateparameters.go b/resource-manager/keyvault/2021-10-01/keys/model_keycreateparameters.go deleted file mode 100644 index 4ce00d53412..00000000000 --- a/resource-manager/keyvault/2021-10-01/keys/model_keycreateparameters.go +++ /dev/null @@ -1,9 +0,0 @@ -package keys - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type KeyCreateParameters struct { - Properties KeyProperties `json:"properties"` - Tags *map[string]string `json:"tags,omitempty"` -} diff --git a/resource-manager/keyvault/2021-10-01/keys/model_keyproperties.go b/resource-manager/keyvault/2021-10-01/keys/model_keyproperties.go deleted file mode 100644 index 1f9cbcd8221..00000000000 --- a/resource-manager/keyvault/2021-10-01/keys/model_keyproperties.go +++ /dev/null @@ -1,14 +0,0 @@ -package keys - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type KeyProperties struct { - Attributes *KeyAttributes `json:"attributes,omitempty"` - CurveName *JsonWebKeyCurveName `json:"curveName,omitempty"` - KeyOps *[]JsonWebKeyOperation `json:"keyOps,omitempty"` - KeySize *int64 `json:"keySize,omitempty"` - KeyUri *string `json:"keyUri,omitempty"` - KeyUriWithVersion *string `json:"keyUriWithVersion,omitempty"` - Kty *JsonWebKeyType `json:"kty,omitempty"` -} diff --git a/resource-manager/keyvault/2021-10-01/keys/predicates.go b/resource-manager/keyvault/2021-10-01/keys/predicates.go deleted file mode 100644 index d7bea89219a..00000000000 --- a/resource-manager/keyvault/2021-10-01/keys/predicates.go +++ /dev/null @@ -1,32 +0,0 @@ -package keys - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type KeyOperationPredicate struct { - Id *string - Location *string - Name *string - Type *string -} - -func (p KeyOperationPredicate) Matches(input Key) 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/keyvault/2021-10-01/keys/version.go b/resource-manager/keyvault/2021-10-01/keys/version.go deleted file mode 100644 index 44268a25d01..00000000000 --- a/resource-manager/keyvault/2021-10-01/keys/version.go +++ /dev/null @@ -1,12 +0,0 @@ -package keys - -import "fmt" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -const defaultApiVersion = "2021-10-01" - -func userAgent() string { - return fmt.Sprintf("hashicorp/go-azure-sdk/keys/%s", defaultApiVersion) -} diff --git a/resource-manager/keyvault/2021-10-01/managedhsms/README.md b/resource-manager/keyvault/2021-10-01/managedhsms/README.md deleted file mode 100644 index a2a335b8aeb..00000000000 --- a/resource-manager/keyvault/2021-10-01/managedhsms/README.md +++ /dev/null @@ -1,161 +0,0 @@ - -## `github.com/hashicorp/go-azure-sdk/resource-manager/keyvault/2021-10-01/managedhsms` Documentation - -The `managedhsms` SDK allows for interaction with the Azure Resource Manager Service `keyvault` (API Version `2021-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/keyvault/2021-10-01/managedhsms" -``` - - -### Client Initialization - -```go -client := managedhsms.NewManagedHsmsClientWithBaseURI("https://management.azure.com") -client.Client.Authorizer = authorizer -``` - - -### Example Usage: `ManagedHsmsClient.CreateOrUpdate` - -```go -ctx := context.TODO() -id := managedhsms.NewManagedHSMID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedHSMValue") - -payload := managedhsms.ManagedHsm{ - // ... -} - - -if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { - // handle the error -} -``` - - -### Example Usage: `ManagedHsmsClient.Delete` - -```go -ctx := context.TODO() -id := managedhsms.NewManagedHSMID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedHSMValue") - -if err := client.DeleteThenPoll(ctx, id); err != nil { - // handle the error -} -``` - - -### Example Usage: `ManagedHsmsClient.Get` - -```go -ctx := context.TODO() -id := managedhsms.NewManagedHSMID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedHSMValue") - -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: `ManagedHsmsClient.GetDeleted` - -```go -ctx := context.TODO() -id := managedhsms.NewDeletedManagedHSMID("12345678-1234-9876-4563-123456789012", "locationValue", "deletedManagedHSMValue") - -read, err := client.GetDeleted(ctx, id) -if err != nil { - // handle the error -} -if model := read.Model; model != nil { - // do something with the model/response object -} -``` - - -### Example Usage: `ManagedHsmsClient.ListByResourceGroup` - -```go -ctx := context.TODO() -id := managedhsms.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") - -// alternatively `client.ListByResourceGroup(ctx, id, managedhsms.DefaultListByResourceGroupOperationOptions())` can be used to do batched pagination -items, err := client.ListByResourceGroupComplete(ctx, id, managedhsms.DefaultListByResourceGroupOperationOptions()) -if err != nil { - // handle the error -} -for _, item := range items { - // do something -} -``` - - -### Example Usage: `ManagedHsmsClient.ListBySubscription` - -```go -ctx := context.TODO() -id := managedhsms.NewSubscriptionID("12345678-1234-9876-4563-123456789012") - -// alternatively `client.ListBySubscription(ctx, id, managedhsms.DefaultListBySubscriptionOperationOptions())` can be used to do batched pagination -items, err := client.ListBySubscriptionComplete(ctx, id, managedhsms.DefaultListBySubscriptionOperationOptions()) -if err != nil { - // handle the error -} -for _, item := range items { - // do something -} -``` - - -### Example Usage: `ManagedHsmsClient.ListDeleted` - -```go -ctx := context.TODO() -id := managedhsms.NewSubscriptionID("12345678-1234-9876-4563-123456789012") - -// alternatively `client.ListDeleted(ctx, id)` can be used to do batched pagination -items, err := client.ListDeletedComplete(ctx, id) -if err != nil { - // handle the error -} -for _, item := range items { - // do something -} -``` - - -### Example Usage: `ManagedHsmsClient.PurgeDeleted` - -```go -ctx := context.TODO() -id := managedhsms.NewDeletedManagedHSMID("12345678-1234-9876-4563-123456789012", "locationValue", "deletedManagedHSMValue") - -if err := client.PurgeDeletedThenPoll(ctx, id); err != nil { - // handle the error -} -``` - - -### Example Usage: `ManagedHsmsClient.Update` - -```go -ctx := context.TODO() -id := managedhsms.NewManagedHSMID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedHSMValue") - -payload := managedhsms.ManagedHsm{ - // ... -} - - -if err := client.UpdateThenPoll(ctx, id, payload); err != nil { - // handle the error -} -``` diff --git a/resource-manager/keyvault/2021-10-01/managedhsms/client.go b/resource-manager/keyvault/2021-10-01/managedhsms/client.go deleted file mode 100644 index 3063f136888..00000000000 --- a/resource-manager/keyvault/2021-10-01/managedhsms/client.go +++ /dev/null @@ -1,18 +0,0 @@ -package managedhsms - -import "github.com/Azure/go-autorest/autorest" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ManagedHsmsClient struct { - Client autorest.Client - baseUri string -} - -func NewManagedHsmsClientWithBaseURI(endpoint string) ManagedHsmsClient { - return ManagedHsmsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/resource-manager/keyvault/2021-10-01/managedhsms/constants.go b/resource-manager/keyvault/2021-10-01/managedhsms/constants.go deleted file mode 100644 index 6801912fe08..00000000000 --- a/resource-manager/keyvault/2021-10-01/managedhsms/constants.go +++ /dev/null @@ -1,319 +0,0 @@ -package managedhsms - -import "strings" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ActionsRequired string - -const ( - ActionsRequiredNone ActionsRequired = "None" -) - -func PossibleValuesForActionsRequired() []string { - return []string{ - string(ActionsRequiredNone), - } -} - -func parseActionsRequired(input string) (*ActionsRequired, error) { - vals := map[string]ActionsRequired{ - "none": ActionsRequiredNone, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ActionsRequired(input) - return &out, nil -} - -type CreateMode string - -const ( - CreateModeDefault CreateMode = "default" - CreateModeRecover CreateMode = "recover" -) - -func PossibleValuesForCreateMode() []string { - return []string{ - string(CreateModeDefault), - string(CreateModeRecover), - } -} - -func parseCreateMode(input string) (*CreateMode, error) { - vals := map[string]CreateMode{ - "default": CreateModeDefault, - "recover": CreateModeRecover, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := CreateMode(input) - return &out, nil -} - -type ManagedHsmSkuFamily string - -const ( - ManagedHsmSkuFamilyB ManagedHsmSkuFamily = "B" -) - -func PossibleValuesForManagedHsmSkuFamily() []string { - return []string{ - string(ManagedHsmSkuFamilyB), - } -} - -func parseManagedHsmSkuFamily(input string) (*ManagedHsmSkuFamily, error) { - vals := map[string]ManagedHsmSkuFamily{ - "b": ManagedHsmSkuFamilyB, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ManagedHsmSkuFamily(input) - return &out, nil -} - -type ManagedHsmSkuName string - -const ( - ManagedHsmSkuNameCustomBSix ManagedHsmSkuName = "Custom_B6" - ManagedHsmSkuNameCustomBThreeTwo ManagedHsmSkuName = "Custom_B32" - ManagedHsmSkuNameStandardBOne ManagedHsmSkuName = "Standard_B1" -) - -func PossibleValuesForManagedHsmSkuName() []string { - return []string{ - string(ManagedHsmSkuNameCustomBSix), - string(ManagedHsmSkuNameCustomBThreeTwo), - string(ManagedHsmSkuNameStandardBOne), - } -} - -func parseManagedHsmSkuName(input string) (*ManagedHsmSkuName, error) { - vals := map[string]ManagedHsmSkuName{ - "custom_b6": ManagedHsmSkuNameCustomBSix, - "custom_b32": ManagedHsmSkuNameCustomBThreeTwo, - "standard_b1": ManagedHsmSkuNameStandardBOne, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ManagedHsmSkuName(input) - return &out, nil -} - -type NetworkRuleAction string - -const ( - NetworkRuleActionAllow NetworkRuleAction = "Allow" - NetworkRuleActionDeny NetworkRuleAction = "Deny" -) - -func PossibleValuesForNetworkRuleAction() []string { - return []string{ - string(NetworkRuleActionAllow), - string(NetworkRuleActionDeny), - } -} - -func parseNetworkRuleAction(input string) (*NetworkRuleAction, error) { - vals := map[string]NetworkRuleAction{ - "allow": NetworkRuleActionAllow, - "deny": NetworkRuleActionDeny, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := NetworkRuleAction(input) - return &out, nil -} - -type NetworkRuleBypassOptions string - -const ( - NetworkRuleBypassOptionsAzureServices NetworkRuleBypassOptions = "AzureServices" - NetworkRuleBypassOptionsNone NetworkRuleBypassOptions = "None" -) - -func PossibleValuesForNetworkRuleBypassOptions() []string { - return []string{ - string(NetworkRuleBypassOptionsAzureServices), - string(NetworkRuleBypassOptionsNone), - } -} - -func parseNetworkRuleBypassOptions(input string) (*NetworkRuleBypassOptions, error) { - vals := map[string]NetworkRuleBypassOptions{ - "azureservices": NetworkRuleBypassOptionsAzureServices, - "none": NetworkRuleBypassOptionsNone, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := NetworkRuleBypassOptions(input) - return &out, nil -} - -type PrivateEndpointConnectionProvisioningState string - -const ( - PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" - PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" - PrivateEndpointConnectionProvisioningStateDisconnected PrivateEndpointConnectionProvisioningState = "Disconnected" - PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" - PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" - PrivateEndpointConnectionProvisioningStateUpdating PrivateEndpointConnectionProvisioningState = "Updating" -) - -func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { - return []string{ - string(PrivateEndpointConnectionProvisioningStateCreating), - string(PrivateEndpointConnectionProvisioningStateDeleting), - string(PrivateEndpointConnectionProvisioningStateDisconnected), - string(PrivateEndpointConnectionProvisioningStateFailed), - string(PrivateEndpointConnectionProvisioningStateSucceeded), - string(PrivateEndpointConnectionProvisioningStateUpdating), - } -} - -func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { - vals := map[string]PrivateEndpointConnectionProvisioningState{ - "creating": PrivateEndpointConnectionProvisioningStateCreating, - "deleting": PrivateEndpointConnectionProvisioningStateDeleting, - "disconnected": PrivateEndpointConnectionProvisioningStateDisconnected, - "failed": PrivateEndpointConnectionProvisioningStateFailed, - "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, - "updating": PrivateEndpointConnectionProvisioningStateUpdating, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := PrivateEndpointConnectionProvisioningState(input) - return &out, nil -} - -type PrivateEndpointServiceConnectionStatus string - -const ( - PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" - PrivateEndpointServiceConnectionStatusDisconnected PrivateEndpointServiceConnectionStatus = "Disconnected" - PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" - PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" -) - -func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { - return []string{ - string(PrivateEndpointServiceConnectionStatusApproved), - string(PrivateEndpointServiceConnectionStatusDisconnected), - string(PrivateEndpointServiceConnectionStatusPending), - string(PrivateEndpointServiceConnectionStatusRejected), - } -} - -func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { - vals := map[string]PrivateEndpointServiceConnectionStatus{ - "approved": PrivateEndpointServiceConnectionStatusApproved, - "disconnected": PrivateEndpointServiceConnectionStatusDisconnected, - "pending": PrivateEndpointServiceConnectionStatusPending, - "rejected": PrivateEndpointServiceConnectionStatusRejected, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := PrivateEndpointServiceConnectionStatus(input) - return &out, nil -} - -type ProvisioningState string - -const ( - ProvisioningStateActivated ProvisioningState = "Activated" - ProvisioningStateDeleting ProvisioningState = "Deleting" - ProvisioningStateFailed ProvisioningState = "Failed" - ProvisioningStateProvisioning ProvisioningState = "Provisioning" - ProvisioningStateRestoring ProvisioningState = "Restoring" - ProvisioningStateSecurityDomainRestore ProvisioningState = "SecurityDomainRestore" - ProvisioningStateSucceeded ProvisioningState = "Succeeded" - ProvisioningStateUpdating ProvisioningState = "Updating" -) - -func PossibleValuesForProvisioningState() []string { - return []string{ - string(ProvisioningStateActivated), - string(ProvisioningStateDeleting), - string(ProvisioningStateFailed), - string(ProvisioningStateProvisioning), - string(ProvisioningStateRestoring), - string(ProvisioningStateSecurityDomainRestore), - string(ProvisioningStateSucceeded), - string(ProvisioningStateUpdating), - } -} - -func parseProvisioningState(input string) (*ProvisioningState, error) { - vals := map[string]ProvisioningState{ - "activated": ProvisioningStateActivated, - "deleting": ProvisioningStateDeleting, - "failed": ProvisioningStateFailed, - "provisioning": ProvisioningStateProvisioning, - "restoring": ProvisioningStateRestoring, - "securitydomainrestore": ProvisioningStateSecurityDomainRestore, - "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 PublicNetworkAccess string - -const ( - PublicNetworkAccessDisabled PublicNetworkAccess = "Disabled" - PublicNetworkAccessEnabled PublicNetworkAccess = "Enabled" -) - -func PossibleValuesForPublicNetworkAccess() []string { - return []string{ - string(PublicNetworkAccessDisabled), - string(PublicNetworkAccessEnabled), - } -} - -func parsePublicNetworkAccess(input string) (*PublicNetworkAccess, error) { - vals := map[string]PublicNetworkAccess{ - "disabled": PublicNetworkAccessDisabled, - "enabled": PublicNetworkAccessEnabled, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := PublicNetworkAccess(input) - return &out, nil -} diff --git a/resource-manager/keyvault/2021-10-01/managedhsms/id_deletedmanagedhsm.go b/resource-manager/keyvault/2021-10-01/managedhsms/id_deletedmanagedhsm.go deleted file mode 100644 index 6e8a2447888..00000000000 --- a/resource-manager/keyvault/2021-10-01/managedhsms/id_deletedmanagedhsm.go +++ /dev/null @@ -1,125 +0,0 @@ -package managedhsms - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -var _ resourceids.ResourceId = &DeletedManagedHSMId{} - -// DeletedManagedHSMId is a struct representing the Resource ID for a Deleted Managed H S M -type DeletedManagedHSMId struct { - SubscriptionId string - LocationName string - DeletedManagedHSMName string -} - -// NewDeletedManagedHSMID returns a new DeletedManagedHSMId struct -func NewDeletedManagedHSMID(subscriptionId string, locationName string, deletedManagedHSMName string) DeletedManagedHSMId { - return DeletedManagedHSMId{ - SubscriptionId: subscriptionId, - LocationName: locationName, - DeletedManagedHSMName: deletedManagedHSMName, - } -} - -// ParseDeletedManagedHSMID parses 'input' into a DeletedManagedHSMId -func ParseDeletedManagedHSMID(input string) (*DeletedManagedHSMId, error) { - parser := resourceids.NewParserFromResourceIdType(&DeletedManagedHSMId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := DeletedManagedHSMId{} - if err := id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -// ParseDeletedManagedHSMIDInsensitively parses 'input' case-insensitively into a DeletedManagedHSMId -// note: this method should only be used for API response data and not user input -func ParseDeletedManagedHSMIDInsensitively(input string) (*DeletedManagedHSMId, error) { - parser := resourceids.NewParserFromResourceIdType(&DeletedManagedHSMId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := DeletedManagedHSMId{} - if err := id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -func (id *DeletedManagedHSMId) FromParseResult(input resourceids.ParseResult) error { - var ok bool - - if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) - } - - if id.LocationName, ok = input.Parsed["locationName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) - } - - if id.DeletedManagedHSMName, ok = input.Parsed["deletedManagedHSMName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "deletedManagedHSMName", input) - } - - return nil -} - -// ValidateDeletedManagedHSMID checks that 'input' can be parsed as a Deleted Managed H S M ID -func ValidateDeletedManagedHSMID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParseDeletedManagedHSMID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Deleted Managed H S M ID -func (id DeletedManagedHSMId) ID() string { - fmtString := "/subscriptions/%s/providers/Microsoft.KeyVault/locations/%s/deletedManagedHSMs/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName, id.DeletedManagedHSMName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Deleted Managed H S M ID -func (id DeletedManagedHSMId) 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("staticMicrosoftKeyVault", "Microsoft.KeyVault", "Microsoft.KeyVault"), - resourceids.StaticSegment("staticLocations", "locations", "locations"), - resourceids.UserSpecifiedSegment("locationName", "locationValue"), - resourceids.StaticSegment("staticDeletedManagedHSMs", "deletedManagedHSMs", "deletedManagedHSMs"), - resourceids.UserSpecifiedSegment("deletedManagedHSMName", "deletedManagedHSMValue"), - } -} - -// String returns a human-readable description of this Deleted Managed H S M ID -func (id DeletedManagedHSMId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Location Name: %q", id.LocationName), - fmt.Sprintf("Deleted Managed H S M Name: %q", id.DeletedManagedHSMName), - } - return fmt.Sprintf("Deleted Managed H S M (%s)", strings.Join(components, "\n")) -} diff --git a/resource-manager/keyvault/2021-10-01/managedhsms/id_deletedmanagedhsm_test.go b/resource-manager/keyvault/2021-10-01/managedhsms/id_deletedmanagedhsm_test.go deleted file mode 100644 index 6657b964ef1..00000000000 --- a/resource-manager/keyvault/2021-10-01/managedhsms/id_deletedmanagedhsm_test.go +++ /dev/null @@ -1,282 +0,0 @@ -package managedhsms - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -var _ resourceids.ResourceId = &DeletedManagedHSMId{} - -func TestNewDeletedManagedHSMID(t *testing.T) { - id := NewDeletedManagedHSMID("12345678-1234-9876-4563-123456789012", "locationValue", "deletedManagedHSMValue") - - if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { - t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") - } - - if id.LocationName != "locationValue" { - t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationValue") - } - - if id.DeletedManagedHSMName != "deletedManagedHSMValue" { - t.Fatalf("Expected %q but got %q for Segment 'DeletedManagedHSMName'", id.DeletedManagedHSMName, "deletedManagedHSMValue") - } -} - -func TestFormatDeletedManagedHSMID(t *testing.T) { - actual := NewDeletedManagedHSMID("12345678-1234-9876-4563-123456789012", "locationValue", "deletedManagedHSMValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.KeyVault/locations/locationValue/deletedManagedHSMs/deletedManagedHSMValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseDeletedManagedHSMID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *DeletedManagedHSMId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - 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.KeyVault", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.KeyVault/locations", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.KeyVault/locations/locationValue", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.KeyVault/locations/locationValue/deletedManagedHSMs", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.KeyVault/locations/locationValue/deletedManagedHSMs/deletedManagedHSMValue", - Expected: &DeletedManagedHSMId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - LocationName: "locationValue", - DeletedManagedHSMName: "deletedManagedHSMValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.KeyVault/locations/locationValue/deletedManagedHSMs/deletedManagedHSMValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseDeletedManagedHSMID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.LocationName != v.Expected.LocationName { - t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) - } - - if actual.DeletedManagedHSMName != v.Expected.DeletedManagedHSMName { - t.Fatalf("Expected %q but got %q for DeletedManagedHSMName", v.Expected.DeletedManagedHSMName, actual.DeletedManagedHSMName) - } - - } -} - -func TestParseDeletedManagedHSMIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *DeletedManagedHSMId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI (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.KeyVault", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.kEyVaUlT", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.KeyVault/locations", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.kEyVaUlT/lOcAtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.KeyVault/locations/locationValue", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.kEyVaUlT/lOcAtIoNs/lOcAtIoNvAlUe", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.KeyVault/locations/locationValue/deletedManagedHSMs", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.kEyVaUlT/lOcAtIoNs/lOcAtIoNvAlUe/dElEtEdMaNaGeDhSmS", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.KeyVault/locations/locationValue/deletedManagedHSMs/deletedManagedHSMValue", - Expected: &DeletedManagedHSMId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - LocationName: "locationValue", - DeletedManagedHSMName: "deletedManagedHSMValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.KeyVault/locations/locationValue/deletedManagedHSMs/deletedManagedHSMValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.kEyVaUlT/lOcAtIoNs/lOcAtIoNvAlUe/dElEtEdMaNaGeDhSmS/dElEtEdMaNaGeDhSmVaLuE", - Expected: &DeletedManagedHSMId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - LocationName: "lOcAtIoNvAlUe", - DeletedManagedHSMName: "dElEtEdMaNaGeDhSmVaLuE", - }, - }, - { - // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.kEyVaUlT/lOcAtIoNs/lOcAtIoNvAlUe/dElEtEdMaNaGeDhSmS/dElEtEdMaNaGeDhSmVaLuE/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseDeletedManagedHSMIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.LocationName != v.Expected.LocationName { - t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) - } - - if actual.DeletedManagedHSMName != v.Expected.DeletedManagedHSMName { - t.Fatalf("Expected %q but got %q for DeletedManagedHSMName", v.Expected.DeletedManagedHSMName, actual.DeletedManagedHSMName) - } - - } -} - -func TestSegmentsForDeletedManagedHSMId(t *testing.T) { - segments := DeletedManagedHSMId{}.Segments() - if len(segments) == 0 { - t.Fatalf("DeletedManagedHSMId has no segments") - } - - uniqueNames := make(map[string]struct{}, 0) - for _, segment := range segments { - uniqueNames[segment.Name] = struct{}{} - } - if len(uniqueNames) != len(segments) { - t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) - } -} diff --git a/resource-manager/keyvault/2021-10-01/managedhsms/id_managedhsm.go b/resource-manager/keyvault/2021-10-01/managedhsms/id_managedhsm.go deleted file mode 100644 index b317e14bc06..00000000000 --- a/resource-manager/keyvault/2021-10-01/managedhsms/id_managedhsm.go +++ /dev/null @@ -1,125 +0,0 @@ -package managedhsms - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -var _ resourceids.ResourceId = &ManagedHSMId{} - -// ManagedHSMId is a struct representing the Resource ID for a Managed H S M -type ManagedHSMId struct { - SubscriptionId string - ResourceGroupName string - ManagedHSMName string -} - -// NewManagedHSMID returns a new ManagedHSMId struct -func NewManagedHSMID(subscriptionId string, resourceGroupName string, managedHSMName string) ManagedHSMId { - return ManagedHSMId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - ManagedHSMName: managedHSMName, - } -} - -// ParseManagedHSMID parses 'input' into a ManagedHSMId -func ParseManagedHSMID(input string) (*ManagedHSMId, error) { - parser := resourceids.NewParserFromResourceIdType(&ManagedHSMId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := ManagedHSMId{} - if err := id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -// ParseManagedHSMIDInsensitively parses 'input' case-insensitively into a ManagedHSMId -// note: this method should only be used for API response data and not user input -func ParseManagedHSMIDInsensitively(input string) (*ManagedHSMId, error) { - parser := resourceids.NewParserFromResourceIdType(&ManagedHSMId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := ManagedHSMId{} - if err := id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -func (id *ManagedHSMId) FromParseResult(input resourceids.ParseResult) error { - var ok bool - - if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) - } - - if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) - } - - if id.ManagedHSMName, ok = input.Parsed["managedHSMName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "managedHSMName", input) - } - - return nil -} - -// ValidateManagedHSMID checks that 'input' can be parsed as a Managed H S M ID -func ValidateManagedHSMID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParseManagedHSMID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Managed H S M ID -func (id ManagedHSMId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.KeyVault/managedHSMs/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedHSMName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Managed H S M ID -func (id ManagedHSMId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftKeyVault", "Microsoft.KeyVault", "Microsoft.KeyVault"), - resourceids.StaticSegment("staticManagedHSMs", "managedHSMs", "managedHSMs"), - resourceids.UserSpecifiedSegment("managedHSMName", "managedHSMValue"), - } -} - -// String returns a human-readable description of this Managed H S M ID -func (id ManagedHSMId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Managed H S M Name: %q", id.ManagedHSMName), - } - return fmt.Sprintf("Managed H S M (%s)", strings.Join(components, "\n")) -} diff --git a/resource-manager/keyvault/2021-10-01/managedhsms/id_managedhsm_test.go b/resource-manager/keyvault/2021-10-01/managedhsms/id_managedhsm_test.go deleted file mode 100644 index dfb23a201b7..00000000000 --- a/resource-manager/keyvault/2021-10-01/managedhsms/id_managedhsm_test.go +++ /dev/null @@ -1,282 +0,0 @@ -package managedhsms - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -var _ resourceids.ResourceId = &ManagedHSMId{} - -func TestNewManagedHSMID(t *testing.T) { - id := NewManagedHSMID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedHSMValue") - - if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { - t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") - } - - if id.ResourceGroupName != "example-resource-group" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") - } - - if id.ManagedHSMName != "managedHSMValue" { - t.Fatalf("Expected %q but got %q for Segment 'ManagedHSMName'", id.ManagedHSMName, "managedHSMValue") - } -} - -func TestFormatManagedHSMID(t *testing.T) { - actual := NewManagedHSMID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedHSMValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseManagedHSMID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *ManagedHSMId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue", - Expected: &ManagedHSMId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ManagedHSMName: "managedHSMValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseManagedHSMID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.ManagedHSMName != v.Expected.ManagedHSMName { - t.Fatalf("Expected %q but got %q for ManagedHSMName", v.Expected.ManagedHSMName, actual.ManagedHSMName) - } - - } -} - -func TestParseManagedHSMIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *ManagedHSMId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/mAnAgEdHsMs", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue", - Expected: &ManagedHSMId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ManagedHSMName: "managedHSMValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/mAnAgEdHsMs/mAnAgEdHsMvAlUe", - Expected: &ManagedHSMId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - ManagedHSMName: "mAnAgEdHsMvAlUe", - }, - }, - { - // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/mAnAgEdHsMs/mAnAgEdHsMvAlUe/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseManagedHSMIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.ManagedHSMName != v.Expected.ManagedHSMName { - t.Fatalf("Expected %q but got %q for ManagedHSMName", v.Expected.ManagedHSMName, actual.ManagedHSMName) - } - - } -} - -func TestSegmentsForManagedHSMId(t *testing.T) { - segments := ManagedHSMId{}.Segments() - if len(segments) == 0 { - t.Fatalf("ManagedHSMId has no segments") - } - - uniqueNames := make(map[string]struct{}, 0) - for _, segment := range segments { - uniqueNames[segment.Name] = struct{}{} - } - if len(uniqueNames) != len(segments) { - t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) - } -} diff --git a/resource-manager/keyvault/2021-10-01/managedhsms/method_createorupdate_autorest.go b/resource-manager/keyvault/2021-10-01/managedhsms/method_createorupdate_autorest.go deleted file mode 100644 index 13ea1b5b54e..00000000000 --- a/resource-manager/keyvault/2021-10-01/managedhsms/method_createorupdate_autorest.go +++ /dev/null @@ -1,80 +0,0 @@ -package managedhsms - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response - Model *ManagedHsm -} - -// CreateOrUpdate ... -func (c ManagedHsmsClient) CreateOrUpdate(ctx context.Context, id ManagedHSMId, input ManagedHsm) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c ManagedHsmsClient) CreateOrUpdateThenPoll(ctx context.Context, id ManagedHSMId, input ManagedHsm) error { - result, err := c.CreateOrUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c ManagedHsmsClient) preparerForCreateOrUpdate(ctx context.Context, id ManagedHSMId, input ManagedHsm) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c ManagedHsmsClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/keyvault/2021-10-01/managedhsms/method_delete_autorest.go b/resource-manager/keyvault/2021-10-01/managedhsms/method_delete_autorest.go deleted file mode 100644 index 56fa4634de5..00000000000 --- a/resource-manager/keyvault/2021-10-01/managedhsms/method_delete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package managedhsms - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Delete ... -func (c ManagedHsmsClient) Delete(ctx context.Context, id ManagedHSMId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c ManagedHsmsClient) DeleteThenPoll(ctx context.Context, id ManagedHSMId) error { - result, err := c.Delete(ctx, id) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} - -// preparerForDelete prepares the Delete request. -func (c ManagedHsmsClient) preparerForDelete(ctx context.Context, id ManagedHSMId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDelete sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (c ManagedHsmsClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/keyvault/2021-10-01/managedhsms/method_get_autorest.go b/resource-manager/keyvault/2021-10-01/managedhsms/method_get_autorest.go deleted file mode 100644 index 2be3a31b09a..00000000000 --- a/resource-manager/keyvault/2021-10-01/managedhsms/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package managedhsms - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *ManagedHsm -} - -// Get ... -func (c ManagedHsmsClient) Get(ctx context.Context, id ManagedHSMId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ManagedHsmsClient) preparerForGet(ctx context.Context, id ManagedHSMId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c ManagedHsmsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusNoContent, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2021-10-01/managedhsms/method_getdeleted_autorest.go b/resource-manager/keyvault/2021-10-01/managedhsms/method_getdeleted_autorest.go deleted file mode 100644 index ad43ab79e1b..00000000000 --- a/resource-manager/keyvault/2021-10-01/managedhsms/method_getdeleted_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package managedhsms - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetDeletedOperationResponse struct { - HttpResponse *http.Response - Model *DeletedManagedHsm -} - -// GetDeleted ... -func (c ManagedHsmsClient) GetDeleted(ctx context.Context, id DeletedManagedHSMId) (result GetDeletedOperationResponse, err error) { - req, err := c.preparerForGetDeleted(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "GetDeleted", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "GetDeleted", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetDeleted(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "GetDeleted", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetDeleted prepares the GetDeleted request. -func (c ManagedHsmsClient) preparerForGetDeleted(ctx context.Context, id DeletedManagedHSMId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetDeleted handles the response to the GetDeleted request. The method always -// closes the http.Response Body. -func (c ManagedHsmsClient) responderForGetDeleted(resp *http.Response) (result GetDeletedOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2021-10-01/managedhsms/method_listbyresourcegroup_autorest.go b/resource-manager/keyvault/2021-10-01/managedhsms/method_listbyresourcegroup_autorest.go deleted file mode 100644 index 941be9aa8ee..00000000000 --- a/resource-manager/keyvault/2021-10-01/managedhsms/method_listbyresourcegroup_autorest.go +++ /dev/null @@ -1,216 +0,0 @@ -package managedhsms - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// 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 - Model *[]ManagedHsm - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByResourceGroupOperationResponse, error) -} - -type ListByResourceGroupCompleteResult struct { - Items []ManagedHsm -} - -func (r ListByResourceGroupOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByResourceGroupOperationResponse) LoadMore(ctx context.Context) (resp ListByResourceGroupOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByResourceGroupOperationOptions struct { - Top *int64 -} - -func DefaultListByResourceGroupOperationOptions() ListByResourceGroupOperationOptions { - return ListByResourceGroupOperationOptions{} -} - -func (o ListByResourceGroupOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByResourceGroupOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByResourceGroup ... -func (c ManagedHsmsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (resp ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroup(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListByResourceGroup", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByResourceGroup(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListByResourceGroup", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByResourceGroup prepares the ListByResourceGroup request. -func (c ManagedHsmsClient) preparerForListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.KeyVault/managedHSMs", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByResourceGroupWithNextLink prepares the ListByResourceGroup request with the given nextLink token. -func (c ManagedHsmsClient) preparerForListByResourceGroupWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByResourceGroup handles the response to the ListByResourceGroup request. The method always -// closes the http.Response Body. -func (c ManagedHsmsClient) responderForListByResourceGroup(resp *http.Response) (result ListByResourceGroupOperationResponse, err error) { - type page struct { - Values []ManagedHsm `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroupWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListByResourceGroup", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByResourceGroup(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListByResourceGroup", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByResourceGroupComplete retrieves all of the results into a single object -func (c ManagedHsmsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (ListByResourceGroupCompleteResult, error) { - return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, options, ManagedHsmOperationPredicate{}) -} - -// ListByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ManagedHsmsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions, predicate ManagedHsmOperationPredicate) (resp ListByResourceGroupCompleteResult, err error) { - items := make([]ManagedHsm, 0) - - page, err := c.ListByResourceGroup(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByResourceGroupCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/keyvault/2021-10-01/managedhsms/method_listbysubscription_autorest.go b/resource-manager/keyvault/2021-10-01/managedhsms/method_listbysubscription_autorest.go deleted file mode 100644 index fcf426e915e..00000000000 --- a/resource-manager/keyvault/2021-10-01/managedhsms/method_listbysubscription_autorest.go +++ /dev/null @@ -1,216 +0,0 @@ -package managedhsms - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// 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 - Model *[]ManagedHsm - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListBySubscriptionOperationResponse, error) -} - -type ListBySubscriptionCompleteResult struct { - Items []ManagedHsm -} - -func (r ListBySubscriptionOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListBySubscriptionOperationResponse) LoadMore(ctx context.Context) (resp ListBySubscriptionOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListBySubscriptionOperationOptions struct { - Top *int64 -} - -func DefaultListBySubscriptionOperationOptions() ListBySubscriptionOperationOptions { - return ListBySubscriptionOperationOptions{} -} - -func (o ListBySubscriptionOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListBySubscriptionOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListBySubscription ... -func (c ManagedHsmsClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions) (resp ListBySubscriptionOperationResponse, err error) { - req, err := c.preparerForListBySubscription(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListBySubscription", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListBySubscription", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListBySubscription(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListBySubscription", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListBySubscription prepares the ListBySubscription request. -func (c ManagedHsmsClient) preparerForListBySubscription(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.KeyVault/managedHSMs", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListBySubscriptionWithNextLink prepares the ListBySubscription request with the given nextLink token. -func (c ManagedHsmsClient) preparerForListBySubscriptionWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListBySubscription handles the response to the ListBySubscription request. The method always -// closes the http.Response Body. -func (c ManagedHsmsClient) responderForListBySubscription(resp *http.Response) (result ListBySubscriptionOperationResponse, err error) { - type page struct { - Values []ManagedHsm `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListBySubscriptionOperationResponse, err error) { - req, err := c.preparerForListBySubscriptionWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListBySubscription", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListBySubscription", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListBySubscription(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListBySubscription", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListBySubscriptionComplete retrieves all of the results into a single object -func (c ManagedHsmsClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions) (ListBySubscriptionCompleteResult, error) { - return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, options, ManagedHsmOperationPredicate{}) -} - -// ListBySubscriptionCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ManagedHsmsClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions, predicate ManagedHsmOperationPredicate) (resp ListBySubscriptionCompleteResult, err error) { - items := make([]ManagedHsm, 0) - - page, err := c.ListBySubscription(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListBySubscriptionCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/keyvault/2021-10-01/managedhsms/method_listdeleted_autorest.go b/resource-manager/keyvault/2021-10-01/managedhsms/method_listdeleted_autorest.go deleted file mode 100644 index 72c2fcb6ecb..00000000000 --- a/resource-manager/keyvault/2021-10-01/managedhsms/method_listdeleted_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package managedhsms - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListDeletedOperationResponse struct { - HttpResponse *http.Response - Model *[]DeletedManagedHsm - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListDeletedOperationResponse, error) -} - -type ListDeletedCompleteResult struct { - Items []DeletedManagedHsm -} - -func (r ListDeletedOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListDeletedOperationResponse) LoadMore(ctx context.Context) (resp ListDeletedOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListDeleted ... -func (c ManagedHsmsClient) ListDeleted(ctx context.Context, id commonids.SubscriptionId) (resp ListDeletedOperationResponse, err error) { - req, err := c.preparerForListDeleted(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListDeleted", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListDeleted", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListDeleted(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListDeleted", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListDeleted prepares the ListDeleted request. -func (c ManagedHsmsClient) preparerForListDeleted(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.KeyVault/deletedManagedHSMs", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListDeletedWithNextLink prepares the ListDeleted request with the given nextLink token. -func (c ManagedHsmsClient) preparerForListDeletedWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListDeleted handles the response to the ListDeleted request. The method always -// closes the http.Response Body. -func (c ManagedHsmsClient) responderForListDeleted(resp *http.Response) (result ListDeletedOperationResponse, err error) { - type page struct { - Values []DeletedManagedHsm `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListDeletedOperationResponse, err error) { - req, err := c.preparerForListDeletedWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListDeleted", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListDeleted", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListDeleted(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListDeleted", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListDeletedComplete retrieves all of the results into a single object -func (c ManagedHsmsClient) ListDeletedComplete(ctx context.Context, id commonids.SubscriptionId) (ListDeletedCompleteResult, error) { - return c.ListDeletedCompleteMatchingPredicate(ctx, id, DeletedManagedHsmOperationPredicate{}) -} - -// ListDeletedCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ManagedHsmsClient) ListDeletedCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate DeletedManagedHsmOperationPredicate) (resp ListDeletedCompleteResult, err error) { - items := make([]DeletedManagedHsm, 0) - - page, err := c.ListDeleted(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListDeletedCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/keyvault/2021-10-01/managedhsms/method_purgedeleted_autorest.go b/resource-manager/keyvault/2021-10-01/managedhsms/method_purgedeleted_autorest.go deleted file mode 100644 index 25a1e6e2654..00000000000 --- a/resource-manager/keyvault/2021-10-01/managedhsms/method_purgedeleted_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package managedhsms - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PurgeDeletedOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// PurgeDeleted ... -func (c ManagedHsmsClient) PurgeDeleted(ctx context.Context, id DeletedManagedHSMId) (result PurgeDeletedOperationResponse, err error) { - req, err := c.preparerForPurgeDeleted(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "PurgeDeleted", nil, "Failure preparing request") - return - } - - result, err = c.senderForPurgeDeleted(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "PurgeDeleted", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// PurgeDeletedThenPoll performs PurgeDeleted then polls until it's completed -func (c ManagedHsmsClient) PurgeDeletedThenPoll(ctx context.Context, id DeletedManagedHSMId) error { - result, err := c.PurgeDeleted(ctx, id) - if err != nil { - return fmt.Errorf("performing PurgeDeleted: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after PurgeDeleted: %+v", err) - } - - return nil -} - -// preparerForPurgeDeleted prepares the PurgeDeleted request. -func (c ManagedHsmsClient) preparerForPurgeDeleted(ctx context.Context, id DeletedManagedHSMId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/purge", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForPurgeDeleted sends the PurgeDeleted request. The method will close the -// http.Response Body if it receives an error. -func (c ManagedHsmsClient) senderForPurgeDeleted(ctx context.Context, req *http.Request) (future PurgeDeletedOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/keyvault/2021-10-01/managedhsms/method_update_autorest.go b/resource-manager/keyvault/2021-10-01/managedhsms/method_update_autorest.go deleted file mode 100644 index f0ad60994ca..00000000000 --- a/resource-manager/keyvault/2021-10-01/managedhsms/method_update_autorest.go +++ /dev/null @@ -1,80 +0,0 @@ -package managedhsms - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response - Model *ManagedHsm -} - -// Update ... -func (c ManagedHsmsClient) Update(ctx context.Context, id ManagedHSMId, input ManagedHsm) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "Update", nil, "Failure preparing request") - return - } - - result, err = c.senderForUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// UpdateThenPoll performs Update then polls until it's completed -func (c ManagedHsmsClient) UpdateThenPoll(ctx context.Context, id ManagedHSMId, input ManagedHsm) error { - result, err := c.Update(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Update: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Update: %+v", err) - } - - return nil -} - -// preparerForUpdate prepares the Update request. -func (c ManagedHsmsClient) preparerForUpdate(ctx context.Context, id ManagedHSMId, input ManagedHsm) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForUpdate sends the Update request. The method will close the -// http.Response Body if it receives an error. -func (c ManagedHsmsClient) senderForUpdate(ctx context.Context, req *http.Request) (future UpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/keyvault/2021-10-01/managedhsms/model_deletedmanagedhsm.go b/resource-manager/keyvault/2021-10-01/managedhsms/model_deletedmanagedhsm.go deleted file mode 100644 index ae5e8a11615..00000000000 --- a/resource-manager/keyvault/2021-10-01/managedhsms/model_deletedmanagedhsm.go +++ /dev/null @@ -1,11 +0,0 @@ -package managedhsms - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeletedManagedHsm struct { - Id *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Properties *DeletedManagedHsmProperties `json:"properties,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/resource-manager/keyvault/2021-10-01/managedhsms/model_deletedmanagedhsmproperties.go b/resource-manager/keyvault/2021-10-01/managedhsms/model_deletedmanagedhsmproperties.go deleted file mode 100644 index 5093466f02e..00000000000 --- a/resource-manager/keyvault/2021-10-01/managedhsms/model_deletedmanagedhsmproperties.go +++ /dev/null @@ -1,43 +0,0 @@ -package managedhsms - -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 DeletedManagedHsmProperties struct { - DeletionDate *string `json:"deletionDate,omitempty"` - Location *string `json:"location,omitempty"` - MhsmId *string `json:"mhsmId,omitempty"` - PurgeProtectionEnabled *bool `json:"purgeProtectionEnabled,omitempty"` - ScheduledPurgeDate *string `json:"scheduledPurgeDate,omitempty"` - Tags *map[string]string `json:"tags,omitempty"` -} - -func (o *DeletedManagedHsmProperties) GetDeletionDateAsTime() (*time.Time, error) { - if o.DeletionDate == nil { - return nil, nil - } - return dates.ParseAsFormat(o.DeletionDate, "2006-01-02T15:04:05Z07:00") -} - -func (o *DeletedManagedHsmProperties) SetDeletionDateAsTime(input time.Time) { - formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.DeletionDate = &formatted -} - -func (o *DeletedManagedHsmProperties) GetScheduledPurgeDateAsTime() (*time.Time, error) { - if o.ScheduledPurgeDate == nil { - return nil, nil - } - return dates.ParseAsFormat(o.ScheduledPurgeDate, "2006-01-02T15:04:05Z07:00") -} - -func (o *DeletedManagedHsmProperties) SetScheduledPurgeDateAsTime(input time.Time) { - formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.ScheduledPurgeDate = &formatted -} diff --git a/resource-manager/keyvault/2021-10-01/managedhsms/model_managedhsm.go b/resource-manager/keyvault/2021-10-01/managedhsms/model_managedhsm.go deleted file mode 100644 index 15895c20ae0..00000000000 --- a/resource-manager/keyvault/2021-10-01/managedhsms/model_managedhsm.go +++ /dev/null @@ -1,19 +0,0 @@ -package managedhsms - -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 ManagedHsm struct { - Id *string `json:"id,omitempty"` - Location *string `json:"location,omitempty"` - Name *string `json:"name,omitempty"` - Properties *ManagedHsmProperties `json:"properties,omitempty"` - Sku *ManagedHsmSku `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/keyvault/2021-10-01/managedhsms/model_managedhsmproperties.go b/resource-manager/keyvault/2021-10-01/managedhsms/model_managedhsmproperties.go deleted file mode 100644 index 56694534066..00000000000 --- a/resource-manager/keyvault/2021-10-01/managedhsms/model_managedhsmproperties.go +++ /dev/null @@ -1,38 +0,0 @@ -package managedhsms - -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 ManagedHsmProperties struct { - CreateMode *CreateMode `json:"createMode,omitempty"` - EnablePurgeProtection *bool `json:"enablePurgeProtection,omitempty"` - EnableSoftDelete *bool `json:"enableSoftDelete,omitempty"` - HsmUri *string `json:"hsmUri,omitempty"` - InitialAdminObjectIds *[]string `json:"initialAdminObjectIds,omitempty"` - NetworkAcls *MHSMNetworkRuleSet `json:"networkAcls,omitempty"` - PrivateEndpointConnections *[]MHSMPrivateEndpointConnectionItem `json:"privateEndpointConnections,omitempty"` - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` - PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` - ScheduledPurgeDate *string `json:"scheduledPurgeDate,omitempty"` - SoftDeleteRetentionInDays *int64 `json:"softDeleteRetentionInDays,omitempty"` - StatusMessage *string `json:"statusMessage,omitempty"` - TenantId *string `json:"tenantId,omitempty"` -} - -func (o *ManagedHsmProperties) GetScheduledPurgeDateAsTime() (*time.Time, error) { - if o.ScheduledPurgeDate == nil { - return nil, nil - } - return dates.ParseAsFormat(o.ScheduledPurgeDate, "2006-01-02T15:04:05Z07:00") -} - -func (o *ManagedHsmProperties) SetScheduledPurgeDateAsTime(input time.Time) { - formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.ScheduledPurgeDate = &formatted -} diff --git a/resource-manager/keyvault/2021-10-01/managedhsms/model_managedhsmsku.go b/resource-manager/keyvault/2021-10-01/managedhsms/model_managedhsmsku.go deleted file mode 100644 index 61dcd5e3b98..00000000000 --- a/resource-manager/keyvault/2021-10-01/managedhsms/model_managedhsmsku.go +++ /dev/null @@ -1,9 +0,0 @@ -package managedhsms - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ManagedHsmSku struct { - Family ManagedHsmSkuFamily `json:"family"` - Name ManagedHsmSkuName `json:"name"` -} diff --git a/resource-manager/keyvault/2021-10-01/managedhsms/model_mhsmiprule.go b/resource-manager/keyvault/2021-10-01/managedhsms/model_mhsmiprule.go deleted file mode 100644 index 6fb2abdeef9..00000000000 --- a/resource-manager/keyvault/2021-10-01/managedhsms/model_mhsmiprule.go +++ /dev/null @@ -1,8 +0,0 @@ -package managedhsms - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type MHSMIPRule struct { - Value string `json:"value"` -} diff --git a/resource-manager/keyvault/2021-10-01/managedhsms/model_mhsmnetworkruleset.go b/resource-manager/keyvault/2021-10-01/managedhsms/model_mhsmnetworkruleset.go deleted file mode 100644 index 2fc81ecae8d..00000000000 --- a/resource-manager/keyvault/2021-10-01/managedhsms/model_mhsmnetworkruleset.go +++ /dev/null @@ -1,11 +0,0 @@ -package managedhsms - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type MHSMNetworkRuleSet struct { - Bypass *NetworkRuleBypassOptions `json:"bypass,omitempty"` - DefaultAction *NetworkRuleAction `json:"defaultAction,omitempty"` - IPRules *[]MHSMIPRule `json:"ipRules,omitempty"` - VirtualNetworkRules *[]MHSMVirtualNetworkRule `json:"virtualNetworkRules,omitempty"` -} diff --git a/resource-manager/keyvault/2021-10-01/managedhsms/model_mhsmprivateendpoint.go b/resource-manager/keyvault/2021-10-01/managedhsms/model_mhsmprivateendpoint.go deleted file mode 100644 index dadd1b65b93..00000000000 --- a/resource-manager/keyvault/2021-10-01/managedhsms/model_mhsmprivateendpoint.go +++ /dev/null @@ -1,8 +0,0 @@ -package managedhsms - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type MHSMPrivateEndpoint struct { - Id *string `json:"id,omitempty"` -} diff --git a/resource-manager/keyvault/2021-10-01/managedhsms/model_mhsmprivateendpointconnectionitem.go b/resource-manager/keyvault/2021-10-01/managedhsms/model_mhsmprivateendpointconnectionitem.go deleted file mode 100644 index d7b577af988..00000000000 --- a/resource-manager/keyvault/2021-10-01/managedhsms/model_mhsmprivateendpointconnectionitem.go +++ /dev/null @@ -1,10 +0,0 @@ -package managedhsms - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type MHSMPrivateEndpointConnectionItem struct { - Etag *string `json:"etag,omitempty"` - Id *string `json:"id,omitempty"` - Properties *MHSMPrivateEndpointConnectionProperties `json:"properties,omitempty"` -} diff --git a/resource-manager/keyvault/2021-10-01/managedhsms/model_mhsmprivateendpointconnectionproperties.go b/resource-manager/keyvault/2021-10-01/managedhsms/model_mhsmprivateendpointconnectionproperties.go deleted file mode 100644 index e91a4b16dec..00000000000 --- a/resource-manager/keyvault/2021-10-01/managedhsms/model_mhsmprivateendpointconnectionproperties.go +++ /dev/null @@ -1,10 +0,0 @@ -package managedhsms - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type MHSMPrivateEndpointConnectionProperties struct { - PrivateEndpoint *MHSMPrivateEndpoint `json:"privateEndpoint,omitempty"` - PrivateLinkServiceConnectionState *MHSMPrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` - ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` -} diff --git a/resource-manager/keyvault/2021-10-01/managedhsms/model_mhsmprivatelinkserviceconnectionstate.go b/resource-manager/keyvault/2021-10-01/managedhsms/model_mhsmprivatelinkserviceconnectionstate.go deleted file mode 100644 index 83b45a02518..00000000000 --- a/resource-manager/keyvault/2021-10-01/managedhsms/model_mhsmprivatelinkserviceconnectionstate.go +++ /dev/null @@ -1,10 +0,0 @@ -package managedhsms - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type MHSMPrivateLinkServiceConnectionState struct { - ActionsRequired *ActionsRequired `json:"actionsRequired,omitempty"` - Description *string `json:"description,omitempty"` - Status *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` -} diff --git a/resource-manager/keyvault/2021-10-01/managedhsms/model_mhsmvirtualnetworkrule.go b/resource-manager/keyvault/2021-10-01/managedhsms/model_mhsmvirtualnetworkrule.go deleted file mode 100644 index 3daa2f4233b..00000000000 --- a/resource-manager/keyvault/2021-10-01/managedhsms/model_mhsmvirtualnetworkrule.go +++ /dev/null @@ -1,8 +0,0 @@ -package managedhsms - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type MHSMVirtualNetworkRule struct { - Id string `json:"id"` -} diff --git a/resource-manager/keyvault/2021-10-01/managedhsms/predicates.go b/resource-manager/keyvault/2021-10-01/managedhsms/predicates.go deleted file mode 100644 index 598d2e6d12b..00000000000 --- a/resource-manager/keyvault/2021-10-01/managedhsms/predicates.go +++ /dev/null @@ -1,55 +0,0 @@ -package managedhsms - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeletedManagedHsmOperationPredicate struct { - Id *string - Name *string - Type *string -} - -func (p DeletedManagedHsmOperationPredicate) Matches(input DeletedManagedHsm) bool { - - if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { - return false - } - - if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { - return false - } - - if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { - return false - } - - return true -} - -type ManagedHsmOperationPredicate struct { - Id *string - Location *string - Name *string - Type *string -} - -func (p ManagedHsmOperationPredicate) Matches(input ManagedHsm) 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/keyvault/2021-10-01/managedhsms/version.go b/resource-manager/keyvault/2021-10-01/managedhsms/version.go deleted file mode 100644 index bcd6ed1296d..00000000000 --- a/resource-manager/keyvault/2021-10-01/managedhsms/version.go +++ /dev/null @@ -1,12 +0,0 @@ -package managedhsms - -import "fmt" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -const defaultApiVersion = "2021-10-01" - -func userAgent() string { - return fmt.Sprintf("hashicorp/go-azure-sdk/managedhsms/%s", defaultApiVersion) -} diff --git a/resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/README.md b/resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/README.md deleted file mode 100644 index f73a108adc9..00000000000 --- a/resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/README.md +++ /dev/null @@ -1,37 +0,0 @@ - -## `github.com/hashicorp/go-azure-sdk/resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections` Documentation - -The `mhsmlistprivateendpointconnections` SDK allows for interaction with the Azure Resource Manager Service `keyvault` (API Version `2021-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/keyvault/2021-10-01/mhsmlistprivateendpointconnections" -``` - - -### Client Initialization - -```go -client := mhsmlistprivateendpointconnections.NewMHSMListPrivateEndpointConnectionsClientWithBaseURI("https://management.azure.com") -client.Client.Authorizer = authorizer -``` - - -### Example Usage: `MHSMListPrivateEndpointConnectionsClient.MHSMPrivateEndpointConnectionsListByResource` - -```go -ctx := context.TODO() -id := mhsmlistprivateendpointconnections.NewManagedHSMID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedHSMValue") - -// alternatively `client.MHSMPrivateEndpointConnectionsListByResource(ctx, id)` can be used to do batched pagination -items, err := client.MHSMPrivateEndpointConnectionsListByResourceComplete(ctx, id) -if err != nil { - // handle the error -} -for _, item := range items { - // do something -} -``` diff --git a/resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/client.go b/resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/client.go deleted file mode 100644 index e8f5caf9f7b..00000000000 --- a/resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/client.go +++ /dev/null @@ -1,18 +0,0 @@ -package mhsmlistprivateendpointconnections - -import "github.com/Azure/go-autorest/autorest" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type MHSMListPrivateEndpointConnectionsClient struct { - Client autorest.Client - baseUri string -} - -func NewMHSMListPrivateEndpointConnectionsClientWithBaseURI(endpoint string) MHSMListPrivateEndpointConnectionsClient { - return MHSMListPrivateEndpointConnectionsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/constants.go b/resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/constants.go deleted file mode 100644 index 6217f9d1eca..00000000000 --- a/resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/constants.go +++ /dev/null @@ -1,161 +0,0 @@ -package mhsmlistprivateendpointconnections - -import "strings" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ActionsRequired string - -const ( - ActionsRequiredNone ActionsRequired = "None" -) - -func PossibleValuesForActionsRequired() []string { - return []string{ - string(ActionsRequiredNone), - } -} - -func parseActionsRequired(input string) (*ActionsRequired, error) { - vals := map[string]ActionsRequired{ - "none": ActionsRequiredNone, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ActionsRequired(input) - return &out, nil -} - -type ManagedHsmSkuFamily string - -const ( - ManagedHsmSkuFamilyB ManagedHsmSkuFamily = "B" -) - -func PossibleValuesForManagedHsmSkuFamily() []string { - return []string{ - string(ManagedHsmSkuFamilyB), - } -} - -func parseManagedHsmSkuFamily(input string) (*ManagedHsmSkuFamily, error) { - vals := map[string]ManagedHsmSkuFamily{ - "b": ManagedHsmSkuFamilyB, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ManagedHsmSkuFamily(input) - return &out, nil -} - -type ManagedHsmSkuName string - -const ( - ManagedHsmSkuNameCustomBSix ManagedHsmSkuName = "Custom_B6" - ManagedHsmSkuNameCustomBThreeTwo ManagedHsmSkuName = "Custom_B32" - ManagedHsmSkuNameStandardBOne ManagedHsmSkuName = "Standard_B1" -) - -func PossibleValuesForManagedHsmSkuName() []string { - return []string{ - string(ManagedHsmSkuNameCustomBSix), - string(ManagedHsmSkuNameCustomBThreeTwo), - string(ManagedHsmSkuNameStandardBOne), - } -} - -func parseManagedHsmSkuName(input string) (*ManagedHsmSkuName, error) { - vals := map[string]ManagedHsmSkuName{ - "custom_b6": ManagedHsmSkuNameCustomBSix, - "custom_b32": ManagedHsmSkuNameCustomBThreeTwo, - "standard_b1": ManagedHsmSkuNameStandardBOne, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ManagedHsmSkuName(input) - return &out, nil -} - -type PrivateEndpointConnectionProvisioningState string - -const ( - PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" - PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" - PrivateEndpointConnectionProvisioningStateDisconnected PrivateEndpointConnectionProvisioningState = "Disconnected" - PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" - PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" - PrivateEndpointConnectionProvisioningStateUpdating PrivateEndpointConnectionProvisioningState = "Updating" -) - -func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { - return []string{ - string(PrivateEndpointConnectionProvisioningStateCreating), - string(PrivateEndpointConnectionProvisioningStateDeleting), - string(PrivateEndpointConnectionProvisioningStateDisconnected), - string(PrivateEndpointConnectionProvisioningStateFailed), - string(PrivateEndpointConnectionProvisioningStateSucceeded), - string(PrivateEndpointConnectionProvisioningStateUpdating), - } -} - -func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { - vals := map[string]PrivateEndpointConnectionProvisioningState{ - "creating": PrivateEndpointConnectionProvisioningStateCreating, - "deleting": PrivateEndpointConnectionProvisioningStateDeleting, - "disconnected": PrivateEndpointConnectionProvisioningStateDisconnected, - "failed": PrivateEndpointConnectionProvisioningStateFailed, - "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, - "updating": PrivateEndpointConnectionProvisioningStateUpdating, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := PrivateEndpointConnectionProvisioningState(input) - return &out, nil -} - -type PrivateEndpointServiceConnectionStatus string - -const ( - PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" - PrivateEndpointServiceConnectionStatusDisconnected PrivateEndpointServiceConnectionStatus = "Disconnected" - PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" - PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" -) - -func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { - return []string{ - string(PrivateEndpointServiceConnectionStatusApproved), - string(PrivateEndpointServiceConnectionStatusDisconnected), - string(PrivateEndpointServiceConnectionStatusPending), - string(PrivateEndpointServiceConnectionStatusRejected), - } -} - -func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { - vals := map[string]PrivateEndpointServiceConnectionStatus{ - "approved": PrivateEndpointServiceConnectionStatusApproved, - "disconnected": PrivateEndpointServiceConnectionStatusDisconnected, - "pending": PrivateEndpointServiceConnectionStatusPending, - "rejected": PrivateEndpointServiceConnectionStatusRejected, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := PrivateEndpointServiceConnectionStatus(input) - return &out, nil -} diff --git a/resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/id_managedhsm.go b/resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/id_managedhsm.go deleted file mode 100644 index 0a553b86cce..00000000000 --- a/resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/id_managedhsm.go +++ /dev/null @@ -1,125 +0,0 @@ -package mhsmlistprivateendpointconnections - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -var _ resourceids.ResourceId = &ManagedHSMId{} - -// ManagedHSMId is a struct representing the Resource ID for a Managed H S M -type ManagedHSMId struct { - SubscriptionId string - ResourceGroupName string - ManagedHSMName string -} - -// NewManagedHSMID returns a new ManagedHSMId struct -func NewManagedHSMID(subscriptionId string, resourceGroupName string, managedHSMName string) ManagedHSMId { - return ManagedHSMId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - ManagedHSMName: managedHSMName, - } -} - -// ParseManagedHSMID parses 'input' into a ManagedHSMId -func ParseManagedHSMID(input string) (*ManagedHSMId, error) { - parser := resourceids.NewParserFromResourceIdType(&ManagedHSMId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := ManagedHSMId{} - if err := id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -// ParseManagedHSMIDInsensitively parses 'input' case-insensitively into a ManagedHSMId -// note: this method should only be used for API response data and not user input -func ParseManagedHSMIDInsensitively(input string) (*ManagedHSMId, error) { - parser := resourceids.NewParserFromResourceIdType(&ManagedHSMId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := ManagedHSMId{} - if err := id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -func (id *ManagedHSMId) FromParseResult(input resourceids.ParseResult) error { - var ok bool - - if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) - } - - if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) - } - - if id.ManagedHSMName, ok = input.Parsed["managedHSMName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "managedHSMName", input) - } - - return nil -} - -// ValidateManagedHSMID checks that 'input' can be parsed as a Managed H S M ID -func ValidateManagedHSMID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParseManagedHSMID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Managed H S M ID -func (id ManagedHSMId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.KeyVault/managedHSMs/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedHSMName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Managed H S M ID -func (id ManagedHSMId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftKeyVault", "Microsoft.KeyVault", "Microsoft.KeyVault"), - resourceids.StaticSegment("staticManagedHSMs", "managedHSMs", "managedHSMs"), - resourceids.UserSpecifiedSegment("managedHSMName", "managedHSMValue"), - } -} - -// String returns a human-readable description of this Managed H S M ID -func (id ManagedHSMId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Managed H S M Name: %q", id.ManagedHSMName), - } - return fmt.Sprintf("Managed H S M (%s)", strings.Join(components, "\n")) -} diff --git a/resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/id_managedhsm_test.go b/resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/id_managedhsm_test.go deleted file mode 100644 index b65d451df41..00000000000 --- a/resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/id_managedhsm_test.go +++ /dev/null @@ -1,282 +0,0 @@ -package mhsmlistprivateendpointconnections - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -var _ resourceids.ResourceId = &ManagedHSMId{} - -func TestNewManagedHSMID(t *testing.T) { - id := NewManagedHSMID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedHSMValue") - - if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { - t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") - } - - if id.ResourceGroupName != "example-resource-group" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") - } - - if id.ManagedHSMName != "managedHSMValue" { - t.Fatalf("Expected %q but got %q for Segment 'ManagedHSMName'", id.ManagedHSMName, "managedHSMValue") - } -} - -func TestFormatManagedHSMID(t *testing.T) { - actual := NewManagedHSMID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedHSMValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseManagedHSMID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *ManagedHSMId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue", - Expected: &ManagedHSMId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ManagedHSMName: "managedHSMValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseManagedHSMID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.ManagedHSMName != v.Expected.ManagedHSMName { - t.Fatalf("Expected %q but got %q for ManagedHSMName", v.Expected.ManagedHSMName, actual.ManagedHSMName) - } - - } -} - -func TestParseManagedHSMIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *ManagedHSMId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/mAnAgEdHsMs", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue", - Expected: &ManagedHSMId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ManagedHSMName: "managedHSMValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/mAnAgEdHsMs/mAnAgEdHsMvAlUe", - Expected: &ManagedHSMId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - ManagedHSMName: "mAnAgEdHsMvAlUe", - }, - }, - { - // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/mAnAgEdHsMs/mAnAgEdHsMvAlUe/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseManagedHSMIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.ManagedHSMName != v.Expected.ManagedHSMName { - t.Fatalf("Expected %q but got %q for ManagedHSMName", v.Expected.ManagedHSMName, actual.ManagedHSMName) - } - - } -} - -func TestSegmentsForManagedHSMId(t *testing.T) { - segments := ManagedHSMId{}.Segments() - if len(segments) == 0 { - t.Fatalf("ManagedHSMId has no segments") - } - - uniqueNames := make(map[string]struct{}, 0) - for _, segment := range segments { - uniqueNames[segment.Name] = struct{}{} - } - if len(uniqueNames) != len(segments) { - t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) - } -} diff --git a/resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/method_mhsmprivateendpointconnectionslistbyresource_autorest.go b/resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/method_mhsmprivateendpointconnectionslistbyresource_autorest.go deleted file mode 100644 index ee28909928e..00000000000 --- a/resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/method_mhsmprivateendpointconnectionslistbyresource_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package mhsmlistprivateendpointconnections - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type MHSMPrivateEndpointConnectionsListByResourceOperationResponse struct { - HttpResponse *http.Response - Model *[]MHSMPrivateEndpointConnection - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (MHSMPrivateEndpointConnectionsListByResourceOperationResponse, error) -} - -type MHSMPrivateEndpointConnectionsListByResourceCompleteResult struct { - Items []MHSMPrivateEndpointConnection -} - -func (r MHSMPrivateEndpointConnectionsListByResourceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r MHSMPrivateEndpointConnectionsListByResourceOperationResponse) LoadMore(ctx context.Context) (resp MHSMPrivateEndpointConnectionsListByResourceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// MHSMPrivateEndpointConnectionsListByResource ... -func (c MHSMListPrivateEndpointConnectionsClient) MHSMPrivateEndpointConnectionsListByResource(ctx context.Context, id ManagedHSMId) (resp MHSMPrivateEndpointConnectionsListByResourceOperationResponse, err error) { - req, err := c.preparerForMHSMPrivateEndpointConnectionsListByResource(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmlistprivateendpointconnections.MHSMListPrivateEndpointConnectionsClient", "MHSMPrivateEndpointConnectionsListByResource", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmlistprivateendpointconnections.MHSMListPrivateEndpointConnectionsClient", "MHSMPrivateEndpointConnectionsListByResource", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForMHSMPrivateEndpointConnectionsListByResource(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmlistprivateendpointconnections.MHSMListPrivateEndpointConnectionsClient", "MHSMPrivateEndpointConnectionsListByResource", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForMHSMPrivateEndpointConnectionsListByResource prepares the MHSMPrivateEndpointConnectionsListByResource request. -func (c MHSMListPrivateEndpointConnectionsClient) preparerForMHSMPrivateEndpointConnectionsListByResource(ctx context.Context, id ManagedHSMId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/privateEndpointConnections", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForMHSMPrivateEndpointConnectionsListByResourceWithNextLink prepares the MHSMPrivateEndpointConnectionsListByResource request with the given nextLink token. -func (c MHSMListPrivateEndpointConnectionsClient) preparerForMHSMPrivateEndpointConnectionsListByResourceWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForMHSMPrivateEndpointConnectionsListByResource handles the response to the MHSMPrivateEndpointConnectionsListByResource request. The method always -// closes the http.Response Body. -func (c MHSMListPrivateEndpointConnectionsClient) responderForMHSMPrivateEndpointConnectionsListByResource(resp *http.Response) (result MHSMPrivateEndpointConnectionsListByResourceOperationResponse, err error) { - type page struct { - Values []MHSMPrivateEndpointConnection `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result MHSMPrivateEndpointConnectionsListByResourceOperationResponse, err error) { - req, err := c.preparerForMHSMPrivateEndpointConnectionsListByResourceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmlistprivateendpointconnections.MHSMListPrivateEndpointConnectionsClient", "MHSMPrivateEndpointConnectionsListByResource", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmlistprivateendpointconnections.MHSMListPrivateEndpointConnectionsClient", "MHSMPrivateEndpointConnectionsListByResource", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForMHSMPrivateEndpointConnectionsListByResource(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmlistprivateendpointconnections.MHSMListPrivateEndpointConnectionsClient", "MHSMPrivateEndpointConnectionsListByResource", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// MHSMPrivateEndpointConnectionsListByResourceComplete retrieves all of the results into a single object -func (c MHSMListPrivateEndpointConnectionsClient) MHSMPrivateEndpointConnectionsListByResourceComplete(ctx context.Context, id ManagedHSMId) (MHSMPrivateEndpointConnectionsListByResourceCompleteResult, error) { - return c.MHSMPrivateEndpointConnectionsListByResourceCompleteMatchingPredicate(ctx, id, MHSMPrivateEndpointConnectionOperationPredicate{}) -} - -// MHSMPrivateEndpointConnectionsListByResourceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c MHSMListPrivateEndpointConnectionsClient) MHSMPrivateEndpointConnectionsListByResourceCompleteMatchingPredicate(ctx context.Context, id ManagedHSMId, predicate MHSMPrivateEndpointConnectionOperationPredicate) (resp MHSMPrivateEndpointConnectionsListByResourceCompleteResult, err error) { - items := make([]MHSMPrivateEndpointConnection, 0) - - page, err := c.MHSMPrivateEndpointConnectionsListByResource(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := MHSMPrivateEndpointConnectionsListByResourceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/model_managedhsmsku.go b/resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/model_managedhsmsku.go deleted file mode 100644 index 80d6089af8f..00000000000 --- a/resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/model_managedhsmsku.go +++ /dev/null @@ -1,9 +0,0 @@ -package mhsmlistprivateendpointconnections - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ManagedHsmSku struct { - Family ManagedHsmSkuFamily `json:"family"` - Name ManagedHsmSkuName `json:"name"` -} diff --git a/resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/model_mhsmprivateendpoint.go b/resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/model_mhsmprivateendpoint.go deleted file mode 100644 index 584d7931ee7..00000000000 --- a/resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/model_mhsmprivateendpoint.go +++ /dev/null @@ -1,8 +0,0 @@ -package mhsmlistprivateendpointconnections - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type MHSMPrivateEndpoint struct { - Id *string `json:"id,omitempty"` -} diff --git a/resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/model_mhsmprivateendpointconnection.go b/resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/model_mhsmprivateendpointconnection.go deleted file mode 100644 index 194164efde7..00000000000 --- a/resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/model_mhsmprivateendpointconnection.go +++ /dev/null @@ -1,20 +0,0 @@ -package mhsmlistprivateendpointconnections - -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 MHSMPrivateEndpointConnection struct { - Etag *string `json:"etag,omitempty"` - Id *string `json:"id,omitempty"` - Location *string `json:"location,omitempty"` - Name *string `json:"name,omitempty"` - Properties *MHSMPrivateEndpointConnectionProperties `json:"properties,omitempty"` - Sku *ManagedHsmSku `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/keyvault/2021-10-01/mhsmlistprivateendpointconnections/model_mhsmprivateendpointconnectionproperties.go b/resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/model_mhsmprivateendpointconnectionproperties.go deleted file mode 100644 index 983aa57e6bd..00000000000 --- a/resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/model_mhsmprivateendpointconnectionproperties.go +++ /dev/null @@ -1,10 +0,0 @@ -package mhsmlistprivateendpointconnections - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type MHSMPrivateEndpointConnectionProperties struct { - PrivateEndpoint *MHSMPrivateEndpoint `json:"privateEndpoint,omitempty"` - PrivateLinkServiceConnectionState *MHSMPrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` - ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` -} diff --git a/resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/model_mhsmprivatelinkserviceconnectionstate.go b/resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/model_mhsmprivatelinkserviceconnectionstate.go deleted file mode 100644 index 3a7d8db5ebb..00000000000 --- a/resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/model_mhsmprivatelinkserviceconnectionstate.go +++ /dev/null @@ -1,10 +0,0 @@ -package mhsmlistprivateendpointconnections - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type MHSMPrivateLinkServiceConnectionState struct { - ActionsRequired *ActionsRequired `json:"actionsRequired,omitempty"` - Description *string `json:"description,omitempty"` - Status *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` -} diff --git a/resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/predicates.go b/resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/predicates.go deleted file mode 100644 index 18e2f2156a7..00000000000 --- a/resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/predicates.go +++ /dev/null @@ -1,37 +0,0 @@ -package mhsmlistprivateendpointconnections - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type MHSMPrivateEndpointConnectionOperationPredicate struct { - Etag *string - Id *string - Location *string - Name *string - Type *string -} - -func (p MHSMPrivateEndpointConnectionOperationPredicate) Matches(input MHSMPrivateEndpointConnection) bool { - - if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { - return false - } - - if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { - return false - } - - if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { - return false - } - - if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { - return false - } - - if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { - return false - } - - return true -} diff --git a/resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/version.go b/resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/version.go deleted file mode 100644 index 6c61f535b03..00000000000 --- a/resource-manager/keyvault/2021-10-01/mhsmlistprivateendpointconnections/version.go +++ /dev/null @@ -1,12 +0,0 @@ -package mhsmlistprivateendpointconnections - -import "fmt" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -const defaultApiVersion = "2021-10-01" - -func userAgent() string { - return fmt.Sprintf("hashicorp/go-azure-sdk/mhsmlistprivateendpointconnections/%s", defaultApiVersion) -} diff --git a/resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/README.md b/resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/README.md deleted file mode 100644 index 4e0ebef6ac7..00000000000 --- a/resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/README.md +++ /dev/null @@ -1,69 +0,0 @@ - -## `github.com/hashicorp/go-azure-sdk/resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections` Documentation - -The `mhsmprivateendpointconnections` SDK allows for interaction with the Azure Resource Manager Service `keyvault` (API Version `2021-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/keyvault/2021-10-01/mhsmprivateendpointconnections" -``` - - -### Client Initialization - -```go -client := mhsmprivateendpointconnections.NewMHSMPrivateEndpointConnectionsClientWithBaseURI("https://management.azure.com") -client.Client.Authorizer = authorizer -``` - - -### Example Usage: `MHSMPrivateEndpointConnectionsClient.Delete` - -```go -ctx := context.TODO() -id := mhsmprivateendpointconnections.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedHSMValue", "privateEndpointConnectionValue") - -if err := client.DeleteThenPoll(ctx, id); err != nil { - // handle the error -} -``` - - -### Example Usage: `MHSMPrivateEndpointConnectionsClient.Get` - -```go -ctx := context.TODO() -id := mhsmprivateendpointconnections.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedHSMValue", "privateEndpointConnectionValue") - -read, err := client.Get(ctx, id) -if err != nil { - // handle the error -} -if model := read.Model; model != nil { - // do something with the model/response object -} -``` - - -### Example Usage: `MHSMPrivateEndpointConnectionsClient.Put` - -```go -ctx := context.TODO() -id := mhsmprivateendpointconnections.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedHSMValue", "privateEndpointConnectionValue") - -payload := mhsmprivateendpointconnections.MHSMPrivateEndpointConnection{ - // ... -} - - -read, err := client.Put(ctx, id, payload) -if err != nil { - // handle the error -} -if model := read.Model; model != nil { - // do something with the model/response object -} -``` diff --git a/resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/client.go b/resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/client.go deleted file mode 100644 index 933a39f9036..00000000000 --- a/resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/client.go +++ /dev/null @@ -1,18 +0,0 @@ -package mhsmprivateendpointconnections - -import "github.com/Azure/go-autorest/autorest" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type MHSMPrivateEndpointConnectionsClient struct { - Client autorest.Client - baseUri string -} - -func NewMHSMPrivateEndpointConnectionsClientWithBaseURI(endpoint string) MHSMPrivateEndpointConnectionsClient { - return MHSMPrivateEndpointConnectionsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/constants.go b/resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/constants.go deleted file mode 100644 index c8d3a4886e3..00000000000 --- a/resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/constants.go +++ /dev/null @@ -1,161 +0,0 @@ -package mhsmprivateendpointconnections - -import "strings" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ActionsRequired string - -const ( - ActionsRequiredNone ActionsRequired = "None" -) - -func PossibleValuesForActionsRequired() []string { - return []string{ - string(ActionsRequiredNone), - } -} - -func parseActionsRequired(input string) (*ActionsRequired, error) { - vals := map[string]ActionsRequired{ - "none": ActionsRequiredNone, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ActionsRequired(input) - return &out, nil -} - -type ManagedHsmSkuFamily string - -const ( - ManagedHsmSkuFamilyB ManagedHsmSkuFamily = "B" -) - -func PossibleValuesForManagedHsmSkuFamily() []string { - return []string{ - string(ManagedHsmSkuFamilyB), - } -} - -func parseManagedHsmSkuFamily(input string) (*ManagedHsmSkuFamily, error) { - vals := map[string]ManagedHsmSkuFamily{ - "b": ManagedHsmSkuFamilyB, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ManagedHsmSkuFamily(input) - return &out, nil -} - -type ManagedHsmSkuName string - -const ( - ManagedHsmSkuNameCustomBSix ManagedHsmSkuName = "Custom_B6" - ManagedHsmSkuNameCustomBThreeTwo ManagedHsmSkuName = "Custom_B32" - ManagedHsmSkuNameStandardBOne ManagedHsmSkuName = "Standard_B1" -) - -func PossibleValuesForManagedHsmSkuName() []string { - return []string{ - string(ManagedHsmSkuNameCustomBSix), - string(ManagedHsmSkuNameCustomBThreeTwo), - string(ManagedHsmSkuNameStandardBOne), - } -} - -func parseManagedHsmSkuName(input string) (*ManagedHsmSkuName, error) { - vals := map[string]ManagedHsmSkuName{ - "custom_b6": ManagedHsmSkuNameCustomBSix, - "custom_b32": ManagedHsmSkuNameCustomBThreeTwo, - "standard_b1": ManagedHsmSkuNameStandardBOne, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ManagedHsmSkuName(input) - return &out, nil -} - -type PrivateEndpointConnectionProvisioningState string - -const ( - PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" - PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" - PrivateEndpointConnectionProvisioningStateDisconnected PrivateEndpointConnectionProvisioningState = "Disconnected" - PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" - PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" - PrivateEndpointConnectionProvisioningStateUpdating PrivateEndpointConnectionProvisioningState = "Updating" -) - -func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { - return []string{ - string(PrivateEndpointConnectionProvisioningStateCreating), - string(PrivateEndpointConnectionProvisioningStateDeleting), - string(PrivateEndpointConnectionProvisioningStateDisconnected), - string(PrivateEndpointConnectionProvisioningStateFailed), - string(PrivateEndpointConnectionProvisioningStateSucceeded), - string(PrivateEndpointConnectionProvisioningStateUpdating), - } -} - -func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { - vals := map[string]PrivateEndpointConnectionProvisioningState{ - "creating": PrivateEndpointConnectionProvisioningStateCreating, - "deleting": PrivateEndpointConnectionProvisioningStateDeleting, - "disconnected": PrivateEndpointConnectionProvisioningStateDisconnected, - "failed": PrivateEndpointConnectionProvisioningStateFailed, - "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, - "updating": PrivateEndpointConnectionProvisioningStateUpdating, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := PrivateEndpointConnectionProvisioningState(input) - return &out, nil -} - -type PrivateEndpointServiceConnectionStatus string - -const ( - PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" - PrivateEndpointServiceConnectionStatusDisconnected PrivateEndpointServiceConnectionStatus = "Disconnected" - PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" - PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" -) - -func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { - return []string{ - string(PrivateEndpointServiceConnectionStatusApproved), - string(PrivateEndpointServiceConnectionStatusDisconnected), - string(PrivateEndpointServiceConnectionStatusPending), - string(PrivateEndpointServiceConnectionStatusRejected), - } -} - -func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { - vals := map[string]PrivateEndpointServiceConnectionStatus{ - "approved": PrivateEndpointServiceConnectionStatusApproved, - "disconnected": PrivateEndpointServiceConnectionStatusDisconnected, - "pending": PrivateEndpointServiceConnectionStatusPending, - "rejected": PrivateEndpointServiceConnectionStatusRejected, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := PrivateEndpointServiceConnectionStatus(input) - return &out, nil -} diff --git a/resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/id_privateendpointconnection.go b/resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/id_privateendpointconnection.go deleted file mode 100644 index 0d174a3978f..00000000000 --- a/resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/id_privateendpointconnection.go +++ /dev/null @@ -1,134 +0,0 @@ -package mhsmprivateendpointconnections - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -var _ resourceids.ResourceId = &PrivateEndpointConnectionId{} - -// PrivateEndpointConnectionId is a struct representing the Resource ID for a Private Endpoint Connection -type PrivateEndpointConnectionId struct { - SubscriptionId string - ResourceGroupName string - ManagedHSMName string - PrivateEndpointConnectionName string -} - -// NewPrivateEndpointConnectionID returns a new PrivateEndpointConnectionId struct -func NewPrivateEndpointConnectionID(subscriptionId string, resourceGroupName string, managedHSMName string, privateEndpointConnectionName string) PrivateEndpointConnectionId { - return PrivateEndpointConnectionId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - ManagedHSMName: managedHSMName, - PrivateEndpointConnectionName: privateEndpointConnectionName, - } -} - -// ParsePrivateEndpointConnectionID parses 'input' into a PrivateEndpointConnectionId -func ParsePrivateEndpointConnectionID(input string) (*PrivateEndpointConnectionId, error) { - parser := resourceids.NewParserFromResourceIdType(&PrivateEndpointConnectionId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := PrivateEndpointConnectionId{} - if err := id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -// ParsePrivateEndpointConnectionIDInsensitively parses 'input' case-insensitively into a PrivateEndpointConnectionId -// note: this method should only be used for API response data and not user input -func ParsePrivateEndpointConnectionIDInsensitively(input string) (*PrivateEndpointConnectionId, error) { - parser := resourceids.NewParserFromResourceIdType(&PrivateEndpointConnectionId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := PrivateEndpointConnectionId{} - if err := id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -func (id *PrivateEndpointConnectionId) FromParseResult(input resourceids.ParseResult) error { - var ok bool - - if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) - } - - if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) - } - - if id.ManagedHSMName, ok = input.Parsed["managedHSMName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "managedHSMName", input) - } - - if id.PrivateEndpointConnectionName, ok = input.Parsed["privateEndpointConnectionName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "privateEndpointConnectionName", input) - } - - return nil -} - -// ValidatePrivateEndpointConnectionID checks that 'input' can be parsed as a Private Endpoint Connection ID -func ValidatePrivateEndpointConnectionID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParsePrivateEndpointConnectionID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Private Endpoint Connection ID -func (id PrivateEndpointConnectionId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.KeyVault/managedHSMs/%s/privateEndpointConnections/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedHSMName, id.PrivateEndpointConnectionName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Private Endpoint Connection ID -func (id PrivateEndpointConnectionId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftKeyVault", "Microsoft.KeyVault", "Microsoft.KeyVault"), - resourceids.StaticSegment("staticManagedHSMs", "managedHSMs", "managedHSMs"), - resourceids.UserSpecifiedSegment("managedHSMName", "managedHSMValue"), - resourceids.StaticSegment("staticPrivateEndpointConnections", "privateEndpointConnections", "privateEndpointConnections"), - resourceids.UserSpecifiedSegment("privateEndpointConnectionName", "privateEndpointConnectionValue"), - } -} - -// String returns a human-readable description of this Private Endpoint Connection ID -func (id PrivateEndpointConnectionId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Managed H S M Name: %q", id.ManagedHSMName), - fmt.Sprintf("Private Endpoint Connection Name: %q", id.PrivateEndpointConnectionName), - } - return fmt.Sprintf("Private Endpoint Connection (%s)", strings.Join(components, "\n")) -} diff --git a/resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/id_privateendpointconnection_test.go b/resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/id_privateendpointconnection_test.go deleted file mode 100644 index 47eafd0f1d8..00000000000 --- a/resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/id_privateendpointconnection_test.go +++ /dev/null @@ -1,327 +0,0 @@ -package mhsmprivateendpointconnections - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -var _ resourceids.ResourceId = &PrivateEndpointConnectionId{} - -func TestNewPrivateEndpointConnectionID(t *testing.T) { - id := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedHSMValue", "privateEndpointConnectionValue") - - if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { - t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") - } - - if id.ResourceGroupName != "example-resource-group" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") - } - - if id.ManagedHSMName != "managedHSMValue" { - t.Fatalf("Expected %q but got %q for Segment 'ManagedHSMName'", id.ManagedHSMName, "managedHSMValue") - } - - if id.PrivateEndpointConnectionName != "privateEndpointConnectionValue" { - t.Fatalf("Expected %q but got %q for Segment 'PrivateEndpointConnectionName'", id.PrivateEndpointConnectionName, "privateEndpointConnectionValue") - } -} - -func TestFormatPrivateEndpointConnectionID(t *testing.T) { - actual := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedHSMValue", "privateEndpointConnectionValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue/privateEndpointConnections/privateEndpointConnectionValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParsePrivateEndpointConnectionID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *PrivateEndpointConnectionId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue/privateEndpointConnections", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue/privateEndpointConnections/privateEndpointConnectionValue", - Expected: &PrivateEndpointConnectionId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ManagedHSMName: "managedHSMValue", - PrivateEndpointConnectionName: "privateEndpointConnectionValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue/privateEndpointConnections/privateEndpointConnectionValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParsePrivateEndpointConnectionID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.ManagedHSMName != v.Expected.ManagedHSMName { - t.Fatalf("Expected %q but got %q for ManagedHSMName", v.Expected.ManagedHSMName, actual.ManagedHSMName) - } - - if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { - t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) - } - - } -} - -func TestParsePrivateEndpointConnectionIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *PrivateEndpointConnectionId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/mAnAgEdHsMs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/mAnAgEdHsMs/mAnAgEdHsMvAlUe", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue/privateEndpointConnections", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/mAnAgEdHsMs/mAnAgEdHsMvAlUe/pRiVaTeEnDpOiNtCoNnEcTiOnS", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue/privateEndpointConnections/privateEndpointConnectionValue", - Expected: &PrivateEndpointConnectionId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ManagedHSMName: "managedHSMValue", - PrivateEndpointConnectionName: "privateEndpointConnectionValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue/privateEndpointConnections/privateEndpointConnectionValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/mAnAgEdHsMs/mAnAgEdHsMvAlUe/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE", - Expected: &PrivateEndpointConnectionId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - ManagedHSMName: "mAnAgEdHsMvAlUe", - PrivateEndpointConnectionName: "pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE", - }, - }, - { - // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/mAnAgEdHsMs/mAnAgEdHsMvAlUe/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParsePrivateEndpointConnectionIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.ManagedHSMName != v.Expected.ManagedHSMName { - t.Fatalf("Expected %q but got %q for ManagedHSMName", v.Expected.ManagedHSMName, actual.ManagedHSMName) - } - - if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { - t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) - } - - } -} - -func TestSegmentsForPrivateEndpointConnectionId(t *testing.T) { - segments := PrivateEndpointConnectionId{}.Segments() - if len(segments) == 0 { - t.Fatalf("PrivateEndpointConnectionId has no segments") - } - - uniqueNames := make(map[string]struct{}, 0) - for _, segment := range segments { - uniqueNames[segment.Name] = struct{}{} - } - if len(uniqueNames) != len(segments) { - t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) - } -} diff --git a/resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/method_delete_autorest.go b/resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/method_delete_autorest.go deleted file mode 100644 index d3eef6a25df..00000000000 --- a/resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/method_delete_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package mhsmprivateendpointconnections - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response - Model *MHSMPrivateEndpointConnection -} - -// Delete ... -func (c MHSMPrivateEndpointConnectionsClient) Delete(ctx context.Context, id PrivateEndpointConnectionId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmprivateendpointconnections.MHSMPrivateEndpointConnectionsClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmprivateendpointconnections.MHSMPrivateEndpointConnectionsClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c MHSMPrivateEndpointConnectionsClient) DeleteThenPoll(ctx context.Context, id PrivateEndpointConnectionId) error { - result, err := c.Delete(ctx, id) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} - -// preparerForDelete prepares the Delete request. -func (c MHSMPrivateEndpointConnectionsClient) preparerForDelete(ctx context.Context, id PrivateEndpointConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDelete sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (c MHSMPrivateEndpointConnectionsClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/method_get_autorest.go b/resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/method_get_autorest.go deleted file mode 100644 index e20835facef..00000000000 --- a/resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package mhsmprivateendpointconnections - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *MHSMPrivateEndpointConnection -} - -// Get ... -func (c MHSMPrivateEndpointConnectionsClient) Get(ctx context.Context, id PrivateEndpointConnectionId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmprivateendpointconnections.MHSMPrivateEndpointConnectionsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmprivateendpointconnections.MHSMPrivateEndpointConnectionsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmprivateendpointconnections.MHSMPrivateEndpointConnectionsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c MHSMPrivateEndpointConnectionsClient) preparerForGet(ctx context.Context, id PrivateEndpointConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c MHSMPrivateEndpointConnectionsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/method_put_autorest.go b/resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/method_put_autorest.go deleted file mode 100644 index 61f1cad7759..00000000000 --- a/resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/method_put_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package mhsmprivateendpointconnections - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PutOperationResponse struct { - HttpResponse *http.Response - Model *MHSMPrivateEndpointConnection -} - -// Put ... -func (c MHSMPrivateEndpointConnectionsClient) Put(ctx context.Context, id PrivateEndpointConnectionId, input MHSMPrivateEndpointConnection) (result PutOperationResponse, err error) { - req, err := c.preparerForPut(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmprivateendpointconnections.MHSMPrivateEndpointConnectionsClient", "Put", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmprivateendpointconnections.MHSMPrivateEndpointConnectionsClient", "Put", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForPut(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmprivateendpointconnections.MHSMPrivateEndpointConnectionsClient", "Put", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForPut prepares the Put request. -func (c MHSMPrivateEndpointConnectionsClient) preparerForPut(ctx context.Context, id PrivateEndpointConnectionId, input MHSMPrivateEndpointConnection) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForPut handles the response to the Put request. The method always -// closes the http.Response Body. -func (c MHSMPrivateEndpointConnectionsClient) responderForPut(resp *http.Response) (result PutOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/model_managedhsmsku.go b/resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/model_managedhsmsku.go deleted file mode 100644 index 846aefa2cd9..00000000000 --- a/resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/model_managedhsmsku.go +++ /dev/null @@ -1,9 +0,0 @@ -package mhsmprivateendpointconnections - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ManagedHsmSku struct { - Family ManagedHsmSkuFamily `json:"family"` - Name ManagedHsmSkuName `json:"name"` -} diff --git a/resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/model_mhsmprivateendpoint.go b/resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/model_mhsmprivateendpoint.go deleted file mode 100644 index efd7da80d73..00000000000 --- a/resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/model_mhsmprivateendpoint.go +++ /dev/null @@ -1,8 +0,0 @@ -package mhsmprivateendpointconnections - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type MHSMPrivateEndpoint struct { - Id *string `json:"id,omitempty"` -} diff --git a/resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/model_mhsmprivateendpointconnection.go b/resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/model_mhsmprivateendpointconnection.go deleted file mode 100644 index d37189be404..00000000000 --- a/resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/model_mhsmprivateendpointconnection.go +++ /dev/null @@ -1,20 +0,0 @@ -package mhsmprivateendpointconnections - -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 MHSMPrivateEndpointConnection struct { - Etag *string `json:"etag,omitempty"` - Id *string `json:"id,omitempty"` - Location *string `json:"location,omitempty"` - Name *string `json:"name,omitempty"` - Properties *MHSMPrivateEndpointConnectionProperties `json:"properties,omitempty"` - Sku *ManagedHsmSku `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/keyvault/2021-10-01/mhsmprivateendpointconnections/model_mhsmprivateendpointconnectionproperties.go b/resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/model_mhsmprivateendpointconnectionproperties.go deleted file mode 100644 index 13ad3394c3e..00000000000 --- a/resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/model_mhsmprivateendpointconnectionproperties.go +++ /dev/null @@ -1,10 +0,0 @@ -package mhsmprivateendpointconnections - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type MHSMPrivateEndpointConnectionProperties struct { - PrivateEndpoint *MHSMPrivateEndpoint `json:"privateEndpoint,omitempty"` - PrivateLinkServiceConnectionState *MHSMPrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` - ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` -} diff --git a/resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/model_mhsmprivatelinkserviceconnectionstate.go b/resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/model_mhsmprivatelinkserviceconnectionstate.go deleted file mode 100644 index 13353b33837..00000000000 --- a/resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/model_mhsmprivatelinkserviceconnectionstate.go +++ /dev/null @@ -1,10 +0,0 @@ -package mhsmprivateendpointconnections - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type MHSMPrivateLinkServiceConnectionState struct { - ActionsRequired *ActionsRequired `json:"actionsRequired,omitempty"` - Description *string `json:"description,omitempty"` - Status *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` -} diff --git a/resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/version.go b/resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/version.go deleted file mode 100644 index 4025f2bca3b..00000000000 --- a/resource-manager/keyvault/2021-10-01/mhsmprivateendpointconnections/version.go +++ /dev/null @@ -1,12 +0,0 @@ -package mhsmprivateendpointconnections - -import "fmt" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -const defaultApiVersion = "2021-10-01" - -func userAgent() string { - return fmt.Sprintf("hashicorp/go-azure-sdk/mhsmprivateendpointconnections/%s", defaultApiVersion) -} diff --git a/resource-manager/keyvault/2021-10-01/mhsmprivatelinkresources/README.md b/resource-manager/keyvault/2021-10-01/mhsmprivatelinkresources/README.md deleted file mode 100644 index d524eaffe11..00000000000 --- a/resource-manager/keyvault/2021-10-01/mhsmprivatelinkresources/README.md +++ /dev/null @@ -1,36 +0,0 @@ - -## `github.com/hashicorp/go-azure-sdk/resource-manager/keyvault/2021-10-01/mhsmprivatelinkresources` Documentation - -The `mhsmprivatelinkresources` SDK allows for interaction with the Azure Resource Manager Service `keyvault` (API Version `2021-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/keyvault/2021-10-01/mhsmprivatelinkresources" -``` - - -### Client Initialization - -```go -client := mhsmprivatelinkresources.NewMHSMPrivateLinkResourcesClientWithBaseURI("https://management.azure.com") -client.Client.Authorizer = authorizer -``` - - -### Example Usage: `MHSMPrivateLinkResourcesClient.ListByMHSMResource` - -```go -ctx := context.TODO() -id := mhsmprivatelinkresources.NewManagedHSMID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedHSMValue") - -read, err := client.ListByMHSMResource(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/keyvault/2021-10-01/mhsmprivatelinkresources/client.go b/resource-manager/keyvault/2021-10-01/mhsmprivatelinkresources/client.go deleted file mode 100644 index 45db1c12858..00000000000 --- a/resource-manager/keyvault/2021-10-01/mhsmprivatelinkresources/client.go +++ /dev/null @@ -1,18 +0,0 @@ -package mhsmprivatelinkresources - -import "github.com/Azure/go-autorest/autorest" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type MHSMPrivateLinkResourcesClient struct { - Client autorest.Client - baseUri string -} - -func NewMHSMPrivateLinkResourcesClientWithBaseURI(endpoint string) MHSMPrivateLinkResourcesClient { - return MHSMPrivateLinkResourcesClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/resource-manager/keyvault/2021-10-01/mhsmprivatelinkresources/constants.go b/resource-manager/keyvault/2021-10-01/mhsmprivatelinkresources/constants.go deleted file mode 100644 index aa5754b95cd..00000000000 --- a/resource-manager/keyvault/2021-10-01/mhsmprivatelinkresources/constants.go +++ /dev/null @@ -1,62 +0,0 @@ -package mhsmprivatelinkresources - -import "strings" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ManagedHsmSkuFamily string - -const ( - ManagedHsmSkuFamilyB ManagedHsmSkuFamily = "B" -) - -func PossibleValuesForManagedHsmSkuFamily() []string { - return []string{ - string(ManagedHsmSkuFamilyB), - } -} - -func parseManagedHsmSkuFamily(input string) (*ManagedHsmSkuFamily, error) { - vals := map[string]ManagedHsmSkuFamily{ - "b": ManagedHsmSkuFamilyB, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ManagedHsmSkuFamily(input) - return &out, nil -} - -type ManagedHsmSkuName string - -const ( - ManagedHsmSkuNameCustomBSix ManagedHsmSkuName = "Custom_B6" - ManagedHsmSkuNameCustomBThreeTwo ManagedHsmSkuName = "Custom_B32" - ManagedHsmSkuNameStandardBOne ManagedHsmSkuName = "Standard_B1" -) - -func PossibleValuesForManagedHsmSkuName() []string { - return []string{ - string(ManagedHsmSkuNameCustomBSix), - string(ManagedHsmSkuNameCustomBThreeTwo), - string(ManagedHsmSkuNameStandardBOne), - } -} - -func parseManagedHsmSkuName(input string) (*ManagedHsmSkuName, error) { - vals := map[string]ManagedHsmSkuName{ - "custom_b6": ManagedHsmSkuNameCustomBSix, - "custom_b32": ManagedHsmSkuNameCustomBThreeTwo, - "standard_b1": ManagedHsmSkuNameStandardBOne, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ManagedHsmSkuName(input) - return &out, nil -} diff --git a/resource-manager/keyvault/2021-10-01/mhsmprivatelinkresources/id_managedhsm.go b/resource-manager/keyvault/2021-10-01/mhsmprivatelinkresources/id_managedhsm.go deleted file mode 100644 index 0b71dcbc99d..00000000000 --- a/resource-manager/keyvault/2021-10-01/mhsmprivatelinkresources/id_managedhsm.go +++ /dev/null @@ -1,125 +0,0 @@ -package mhsmprivatelinkresources - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -var _ resourceids.ResourceId = &ManagedHSMId{} - -// ManagedHSMId is a struct representing the Resource ID for a Managed H S M -type ManagedHSMId struct { - SubscriptionId string - ResourceGroupName string - ManagedHSMName string -} - -// NewManagedHSMID returns a new ManagedHSMId struct -func NewManagedHSMID(subscriptionId string, resourceGroupName string, managedHSMName string) ManagedHSMId { - return ManagedHSMId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - ManagedHSMName: managedHSMName, - } -} - -// ParseManagedHSMID parses 'input' into a ManagedHSMId -func ParseManagedHSMID(input string) (*ManagedHSMId, error) { - parser := resourceids.NewParserFromResourceIdType(&ManagedHSMId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := ManagedHSMId{} - if err := id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -// ParseManagedHSMIDInsensitively parses 'input' case-insensitively into a ManagedHSMId -// note: this method should only be used for API response data and not user input -func ParseManagedHSMIDInsensitively(input string) (*ManagedHSMId, error) { - parser := resourceids.NewParserFromResourceIdType(&ManagedHSMId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := ManagedHSMId{} - if err := id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -func (id *ManagedHSMId) FromParseResult(input resourceids.ParseResult) error { - var ok bool - - if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) - } - - if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) - } - - if id.ManagedHSMName, ok = input.Parsed["managedHSMName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "managedHSMName", input) - } - - return nil -} - -// ValidateManagedHSMID checks that 'input' can be parsed as a Managed H S M ID -func ValidateManagedHSMID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParseManagedHSMID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Managed H S M ID -func (id ManagedHSMId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.KeyVault/managedHSMs/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedHSMName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Managed H S M ID -func (id ManagedHSMId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftKeyVault", "Microsoft.KeyVault", "Microsoft.KeyVault"), - resourceids.StaticSegment("staticManagedHSMs", "managedHSMs", "managedHSMs"), - resourceids.UserSpecifiedSegment("managedHSMName", "managedHSMValue"), - } -} - -// String returns a human-readable description of this Managed H S M ID -func (id ManagedHSMId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Managed H S M Name: %q", id.ManagedHSMName), - } - return fmt.Sprintf("Managed H S M (%s)", strings.Join(components, "\n")) -} diff --git a/resource-manager/keyvault/2021-10-01/mhsmprivatelinkresources/id_managedhsm_test.go b/resource-manager/keyvault/2021-10-01/mhsmprivatelinkresources/id_managedhsm_test.go deleted file mode 100644 index 25de48e1d9a..00000000000 --- a/resource-manager/keyvault/2021-10-01/mhsmprivatelinkresources/id_managedhsm_test.go +++ /dev/null @@ -1,282 +0,0 @@ -package mhsmprivatelinkresources - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -var _ resourceids.ResourceId = &ManagedHSMId{} - -func TestNewManagedHSMID(t *testing.T) { - id := NewManagedHSMID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedHSMValue") - - if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { - t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") - } - - if id.ResourceGroupName != "example-resource-group" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") - } - - if id.ManagedHSMName != "managedHSMValue" { - t.Fatalf("Expected %q but got %q for Segment 'ManagedHSMName'", id.ManagedHSMName, "managedHSMValue") - } -} - -func TestFormatManagedHSMID(t *testing.T) { - actual := NewManagedHSMID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedHSMValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseManagedHSMID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *ManagedHSMId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue", - Expected: &ManagedHSMId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ManagedHSMName: "managedHSMValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseManagedHSMID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.ManagedHSMName != v.Expected.ManagedHSMName { - t.Fatalf("Expected %q but got %q for ManagedHSMName", v.Expected.ManagedHSMName, actual.ManagedHSMName) - } - - } -} - -func TestParseManagedHSMIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *ManagedHSMId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/mAnAgEdHsMs", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue", - Expected: &ManagedHSMId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ManagedHSMName: "managedHSMValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/mAnAgEdHsMs/mAnAgEdHsMvAlUe", - Expected: &ManagedHSMId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - ManagedHSMName: "mAnAgEdHsMvAlUe", - }, - }, - { - // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/mAnAgEdHsMs/mAnAgEdHsMvAlUe/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseManagedHSMIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.ManagedHSMName != v.Expected.ManagedHSMName { - t.Fatalf("Expected %q but got %q for ManagedHSMName", v.Expected.ManagedHSMName, actual.ManagedHSMName) - } - - } -} - -func TestSegmentsForManagedHSMId(t *testing.T) { - segments := ManagedHSMId{}.Segments() - if len(segments) == 0 { - t.Fatalf("ManagedHSMId has no segments") - } - - uniqueNames := make(map[string]struct{}, 0) - for _, segment := range segments { - uniqueNames[segment.Name] = struct{}{} - } - if len(uniqueNames) != len(segments) { - t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) - } -} diff --git a/resource-manager/keyvault/2021-10-01/mhsmprivatelinkresources/method_listbymhsmresource_autorest.go b/resource-manager/keyvault/2021-10-01/mhsmprivatelinkresources/method_listbymhsmresource_autorest.go deleted file mode 100644 index 039d077edfe..00000000000 --- a/resource-manager/keyvault/2021-10-01/mhsmprivatelinkresources/method_listbymhsmresource_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package mhsmprivatelinkresources - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByMHSMResourceOperationResponse struct { - HttpResponse *http.Response - Model *MHSMPrivateLinkResourceListResult -} - -// ListByMHSMResource ... -func (c MHSMPrivateLinkResourcesClient) ListByMHSMResource(ctx context.Context, id ManagedHSMId) (result ListByMHSMResourceOperationResponse, err error) { - req, err := c.preparerForListByMHSMResource(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmprivatelinkresources.MHSMPrivateLinkResourcesClient", "ListByMHSMResource", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmprivatelinkresources.MHSMPrivateLinkResourcesClient", "ListByMHSMResource", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByMHSMResource(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmprivatelinkresources.MHSMPrivateLinkResourcesClient", "ListByMHSMResource", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByMHSMResource prepares the ListByMHSMResource request. -func (c MHSMPrivateLinkResourcesClient) preparerForListByMHSMResource(ctx context.Context, id ManagedHSMId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/privateLinkResources", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByMHSMResource handles the response to the ListByMHSMResource request. The method always -// closes the http.Response Body. -func (c MHSMPrivateLinkResourcesClient) responderForListByMHSMResource(resp *http.Response) (result ListByMHSMResourceOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2021-10-01/mhsmprivatelinkresources/model_managedhsmsku.go b/resource-manager/keyvault/2021-10-01/mhsmprivatelinkresources/model_managedhsmsku.go deleted file mode 100644 index 31124d8e20f..00000000000 --- a/resource-manager/keyvault/2021-10-01/mhsmprivatelinkresources/model_managedhsmsku.go +++ /dev/null @@ -1,9 +0,0 @@ -package mhsmprivatelinkresources - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ManagedHsmSku struct { - Family ManagedHsmSkuFamily `json:"family"` - Name ManagedHsmSkuName `json:"name"` -} diff --git a/resource-manager/keyvault/2021-10-01/mhsmprivatelinkresources/model_mhsmprivatelinkresource.go b/resource-manager/keyvault/2021-10-01/mhsmprivatelinkresources/model_mhsmprivatelinkresource.go deleted file mode 100644 index 292a506a4d5..00000000000 --- a/resource-manager/keyvault/2021-10-01/mhsmprivatelinkresources/model_mhsmprivatelinkresource.go +++ /dev/null @@ -1,19 +0,0 @@ -package mhsmprivatelinkresources - -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 MHSMPrivateLinkResource struct { - Id *string `json:"id,omitempty"` - Location *string `json:"location,omitempty"` - Name *string `json:"name,omitempty"` - Properties *MHSMPrivateLinkResourceProperties `json:"properties,omitempty"` - Sku *ManagedHsmSku `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/keyvault/2021-10-01/mhsmprivatelinkresources/model_mhsmprivatelinkresourcelistresult.go b/resource-manager/keyvault/2021-10-01/mhsmprivatelinkresources/model_mhsmprivatelinkresourcelistresult.go deleted file mode 100644 index 1589954fa56..00000000000 --- a/resource-manager/keyvault/2021-10-01/mhsmprivatelinkresources/model_mhsmprivatelinkresourcelistresult.go +++ /dev/null @@ -1,8 +0,0 @@ -package mhsmprivatelinkresources - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type MHSMPrivateLinkResourceListResult struct { - Value *[]MHSMPrivateLinkResource `json:"value,omitempty"` -} diff --git a/resource-manager/keyvault/2021-10-01/mhsmprivatelinkresources/model_mhsmprivatelinkresourceproperties.go b/resource-manager/keyvault/2021-10-01/mhsmprivatelinkresources/model_mhsmprivatelinkresourceproperties.go deleted file mode 100644 index 318dc85b436..00000000000 --- a/resource-manager/keyvault/2021-10-01/mhsmprivatelinkresources/model_mhsmprivatelinkresourceproperties.go +++ /dev/null @@ -1,10 +0,0 @@ -package mhsmprivatelinkresources - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type MHSMPrivateLinkResourceProperties struct { - GroupId *string `json:"groupId,omitempty"` - RequiredMembers *[]string `json:"requiredMembers,omitempty"` - RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` -} diff --git a/resource-manager/keyvault/2021-10-01/mhsmprivatelinkresources/version.go b/resource-manager/keyvault/2021-10-01/mhsmprivatelinkresources/version.go deleted file mode 100644 index 3e2414a213d..00000000000 --- a/resource-manager/keyvault/2021-10-01/mhsmprivatelinkresources/version.go +++ /dev/null @@ -1,12 +0,0 @@ -package mhsmprivatelinkresources - -import "fmt" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -const defaultApiVersion = "2021-10-01" - -func userAgent() string { - return fmt.Sprintf("hashicorp/go-azure-sdk/mhsmprivatelinkresources/%s", defaultApiVersion) -} diff --git a/resource-manager/keyvault/2021-10-01/privateendpointconnections/README.md b/resource-manager/keyvault/2021-10-01/privateendpointconnections/README.md deleted file mode 100644 index 1e0764c09ac..00000000000 --- a/resource-manager/keyvault/2021-10-01/privateendpointconnections/README.md +++ /dev/null @@ -1,86 +0,0 @@ - -## `github.com/hashicorp/go-azure-sdk/resource-manager/keyvault/2021-10-01/privateendpointconnections` Documentation - -The `privateendpointconnections` SDK allows for interaction with the Azure Resource Manager Service `keyvault` (API Version `2021-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/keyvault/2021-10-01/privateendpointconnections" -``` - - -### Client Initialization - -```go -client := privateendpointconnections.NewPrivateEndpointConnectionsClientWithBaseURI("https://management.azure.com") -client.Client.Authorizer = authorizer -``` - - -### Example Usage: `PrivateEndpointConnectionsClient.Delete` - -```go -ctx := context.TODO() -id := privateendpointconnections.NewKeyVaultPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "privateEndpointConnectionValue") - -if err := client.DeleteThenPoll(ctx, id); err != nil { - // handle the error -} -``` - - -### Example Usage: `PrivateEndpointConnectionsClient.Get` - -```go -ctx := context.TODO() -id := privateendpointconnections.NewKeyVaultPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "privateEndpointConnectionValue") - -read, err := client.Get(ctx, id) -if err != nil { - // handle the error -} -if model := read.Model; model != nil { - // do something with the model/response object -} -``` - - -### Example Usage: `PrivateEndpointConnectionsClient.ListByResource` - -```go -ctx := context.TODO() -id := privateendpointconnections.NewKeyVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") - -// alternatively `client.ListByResource(ctx, id)` can be used to do batched pagination -items, err := client.ListByResourceComplete(ctx, id) -if err != nil { - // handle the error -} -for _, item := range items { - // do something -} -``` - - -### Example Usage: `PrivateEndpointConnectionsClient.Put` - -```go -ctx := context.TODO() -id := privateendpointconnections.NewKeyVaultPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "privateEndpointConnectionValue") - -payload := privateendpointconnections.PrivateEndpointConnection{ - // ... -} - - -read, err := client.Put(ctx, id, payload) -if err != nil { - // handle the error -} -if model := read.Model; model != nil { - // do something with the model/response object -} -``` diff --git a/resource-manager/keyvault/2021-10-01/privateendpointconnections/client.go b/resource-manager/keyvault/2021-10-01/privateendpointconnections/client.go deleted file mode 100644 index 1de584406fe..00000000000 --- a/resource-manager/keyvault/2021-10-01/privateendpointconnections/client.go +++ /dev/null @@ -1,18 +0,0 @@ -package privateendpointconnections - -import "github.com/Azure/go-autorest/autorest" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PrivateEndpointConnectionsClient struct { - Client autorest.Client - baseUri string -} - -func NewPrivateEndpointConnectionsClientWithBaseURI(endpoint string) PrivateEndpointConnectionsClient { - return PrivateEndpointConnectionsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/resource-manager/keyvault/2021-10-01/privateendpointconnections/constants.go b/resource-manager/keyvault/2021-10-01/privateendpointconnections/constants.go deleted file mode 100644 index 127a9d9aafd..00000000000 --- a/resource-manager/keyvault/2021-10-01/privateendpointconnections/constants.go +++ /dev/null @@ -1,105 +0,0 @@ -package privateendpointconnections - -import "strings" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ActionsRequired string - -const ( - ActionsRequiredNone ActionsRequired = "None" -) - -func PossibleValuesForActionsRequired() []string { - return []string{ - string(ActionsRequiredNone), - } -} - -func parseActionsRequired(input string) (*ActionsRequired, error) { - vals := map[string]ActionsRequired{ - "none": ActionsRequiredNone, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ActionsRequired(input) - return &out, nil -} - -type PrivateEndpointConnectionProvisioningState string - -const ( - PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" - PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" - PrivateEndpointConnectionProvisioningStateDisconnected PrivateEndpointConnectionProvisioningState = "Disconnected" - PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" - PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" - PrivateEndpointConnectionProvisioningStateUpdating PrivateEndpointConnectionProvisioningState = "Updating" -) - -func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { - return []string{ - string(PrivateEndpointConnectionProvisioningStateCreating), - string(PrivateEndpointConnectionProvisioningStateDeleting), - string(PrivateEndpointConnectionProvisioningStateDisconnected), - string(PrivateEndpointConnectionProvisioningStateFailed), - string(PrivateEndpointConnectionProvisioningStateSucceeded), - string(PrivateEndpointConnectionProvisioningStateUpdating), - } -} - -func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { - vals := map[string]PrivateEndpointConnectionProvisioningState{ - "creating": PrivateEndpointConnectionProvisioningStateCreating, - "deleting": PrivateEndpointConnectionProvisioningStateDeleting, - "disconnected": PrivateEndpointConnectionProvisioningStateDisconnected, - "failed": PrivateEndpointConnectionProvisioningStateFailed, - "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, - "updating": PrivateEndpointConnectionProvisioningStateUpdating, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := PrivateEndpointConnectionProvisioningState(input) - return &out, nil -} - -type PrivateEndpointServiceConnectionStatus string - -const ( - PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" - PrivateEndpointServiceConnectionStatusDisconnected PrivateEndpointServiceConnectionStatus = "Disconnected" - PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" - PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" -) - -func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { - return []string{ - string(PrivateEndpointServiceConnectionStatusApproved), - string(PrivateEndpointServiceConnectionStatusDisconnected), - string(PrivateEndpointServiceConnectionStatusPending), - string(PrivateEndpointServiceConnectionStatusRejected), - } -} - -func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { - vals := map[string]PrivateEndpointServiceConnectionStatus{ - "approved": PrivateEndpointServiceConnectionStatusApproved, - "disconnected": PrivateEndpointServiceConnectionStatusDisconnected, - "pending": PrivateEndpointServiceConnectionStatusPending, - "rejected": PrivateEndpointServiceConnectionStatusRejected, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := PrivateEndpointServiceConnectionStatus(input) - return &out, nil -} diff --git a/resource-manager/keyvault/2021-10-01/privateendpointconnections/method_delete_autorest.go b/resource-manager/keyvault/2021-10-01/privateendpointconnections/method_delete_autorest.go deleted file mode 100644 index 4703a8f08ad..00000000000 --- a/resource-manager/keyvault/2021-10-01/privateendpointconnections/method_delete_autorest.go +++ /dev/null @@ -1,80 +0,0 @@ -package privateendpointconnections - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response - Model *PrivateEndpointConnection -} - -// Delete ... -func (c PrivateEndpointConnectionsClient) Delete(ctx context.Context, id commonids.KeyVaultPrivateEndpointConnectionId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c PrivateEndpointConnectionsClient) DeleteThenPoll(ctx context.Context, id commonids.KeyVaultPrivateEndpointConnectionId) error { - result, err := c.Delete(ctx, id) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} - -// preparerForDelete prepares the Delete request. -func (c PrivateEndpointConnectionsClient) preparerForDelete(ctx context.Context, id commonids.KeyVaultPrivateEndpointConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDelete sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (c PrivateEndpointConnectionsClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/keyvault/2021-10-01/privateendpointconnections/method_get_autorest.go b/resource-manager/keyvault/2021-10-01/privateendpointconnections/method_get_autorest.go deleted file mode 100644 index 6c5953b7a4e..00000000000 --- a/resource-manager/keyvault/2021-10-01/privateendpointconnections/method_get_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package privateendpointconnections - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *PrivateEndpointConnection -} - -// Get ... -func (c PrivateEndpointConnectionsClient) Get(ctx context.Context, id commonids.KeyVaultPrivateEndpointConnectionId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c PrivateEndpointConnectionsClient) preparerForGet(ctx context.Context, id commonids.KeyVaultPrivateEndpointConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c PrivateEndpointConnectionsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2021-10-01/privateendpointconnections/method_listbyresource_autorest.go b/resource-manager/keyvault/2021-10-01/privateendpointconnections/method_listbyresource_autorest.go deleted file mode 100644 index 04d7c90769d..00000000000 --- a/resource-manager/keyvault/2021-10-01/privateendpointconnections/method_listbyresource_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package privateendpointconnections - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByResourceOperationResponse struct { - HttpResponse *http.Response - Model *[]PrivateEndpointConnection - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByResourceOperationResponse, error) -} - -type ListByResourceCompleteResult struct { - Items []PrivateEndpointConnection -} - -func (r ListByResourceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByResourceOperationResponse) LoadMore(ctx context.Context) (resp ListByResourceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByResource ... -func (c PrivateEndpointConnectionsClient) ListByResource(ctx context.Context, id commonids.KeyVaultId) (resp ListByResourceOperationResponse, err error) { - req, err := c.preparerForListByResource(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "ListByResource", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "ListByResource", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByResource(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "ListByResource", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByResource prepares the ListByResource request. -func (c PrivateEndpointConnectionsClient) preparerForListByResource(ctx context.Context, id commonids.KeyVaultId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/privateEndpointConnections", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByResourceWithNextLink prepares the ListByResource request with the given nextLink token. -func (c PrivateEndpointConnectionsClient) preparerForListByResourceWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByResource handles the response to the ListByResource request. The method always -// closes the http.Response Body. -func (c PrivateEndpointConnectionsClient) responderForListByResource(resp *http.Response) (result ListByResourceOperationResponse, err error) { - type page struct { - Values []PrivateEndpointConnection `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByResourceOperationResponse, err error) { - req, err := c.preparerForListByResourceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "ListByResource", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "ListByResource", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByResource(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "ListByResource", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByResourceComplete retrieves all of the results into a single object -func (c PrivateEndpointConnectionsClient) ListByResourceComplete(ctx context.Context, id commonids.KeyVaultId) (ListByResourceCompleteResult, error) { - return c.ListByResourceCompleteMatchingPredicate(ctx, id, PrivateEndpointConnectionOperationPredicate{}) -} - -// ListByResourceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c PrivateEndpointConnectionsClient) ListByResourceCompleteMatchingPredicate(ctx context.Context, id commonids.KeyVaultId, predicate PrivateEndpointConnectionOperationPredicate) (resp ListByResourceCompleteResult, err error) { - items := make([]PrivateEndpointConnection, 0) - - page, err := c.ListByResource(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByResourceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/keyvault/2021-10-01/privateendpointconnections/method_put_autorest.go b/resource-manager/keyvault/2021-10-01/privateendpointconnections/method_put_autorest.go deleted file mode 100644 index 20a86574f4c..00000000000 --- a/resource-manager/keyvault/2021-10-01/privateendpointconnections/method_put_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package privateendpointconnections - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PutOperationResponse struct { - HttpResponse *http.Response - Model *PrivateEndpointConnection -} - -// Put ... -func (c PrivateEndpointConnectionsClient) Put(ctx context.Context, id commonids.KeyVaultPrivateEndpointConnectionId, input PrivateEndpointConnection) (result PutOperationResponse, err error) { - req, err := c.preparerForPut(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Put", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Put", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForPut(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Put", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForPut prepares the Put request. -func (c PrivateEndpointConnectionsClient) preparerForPut(ctx context.Context, id commonids.KeyVaultPrivateEndpointConnectionId, input PrivateEndpointConnection) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForPut handles the response to the Put request. The method always -// closes the http.Response Body. -func (c PrivateEndpointConnectionsClient) responderForPut(resp *http.Response) (result PutOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2021-10-01/privateendpointconnections/model_privateendpoint.go b/resource-manager/keyvault/2021-10-01/privateendpointconnections/model_privateendpoint.go deleted file mode 100644 index 1bc8cf2a97c..00000000000 --- a/resource-manager/keyvault/2021-10-01/privateendpointconnections/model_privateendpoint.go +++ /dev/null @@ -1,8 +0,0 @@ -package privateendpointconnections - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PrivateEndpoint struct { - Id *string `json:"id,omitempty"` -} diff --git a/resource-manager/keyvault/2021-10-01/privateendpointconnections/model_privateendpointconnection.go b/resource-manager/keyvault/2021-10-01/privateendpointconnections/model_privateendpointconnection.go deleted file mode 100644 index 74b0e5c4644..00000000000 --- a/resource-manager/keyvault/2021-10-01/privateendpointconnections/model_privateendpointconnection.go +++ /dev/null @@ -1,14 +0,0 @@ -package privateendpointconnections - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PrivateEndpointConnection struct { - Etag *string `json:"etag,omitempty"` - Id *string `json:"id,omitempty"` - Location *string `json:"location,omitempty"` - Name *string `json:"name,omitempty"` - Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` - Tags *map[string]string `json:"tags,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/resource-manager/keyvault/2021-10-01/privateendpointconnections/model_privateendpointconnectionproperties.go b/resource-manager/keyvault/2021-10-01/privateendpointconnections/model_privateendpointconnectionproperties.go deleted file mode 100644 index 78e87db45fe..00000000000 --- a/resource-manager/keyvault/2021-10-01/privateendpointconnections/model_privateendpointconnectionproperties.go +++ /dev/null @@ -1,10 +0,0 @@ -package privateendpointconnections - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PrivateEndpointConnectionProperties struct { - PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` - PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` - ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` -} diff --git a/resource-manager/keyvault/2021-10-01/privateendpointconnections/model_privatelinkserviceconnectionstate.go b/resource-manager/keyvault/2021-10-01/privateendpointconnections/model_privatelinkserviceconnectionstate.go deleted file mode 100644 index ca71b62e3ff..00000000000 --- a/resource-manager/keyvault/2021-10-01/privateendpointconnections/model_privatelinkserviceconnectionstate.go +++ /dev/null @@ -1,10 +0,0 @@ -package privateendpointconnections - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PrivateLinkServiceConnectionState struct { - ActionsRequired *ActionsRequired `json:"actionsRequired,omitempty"` - Description *string `json:"description,omitempty"` - Status *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` -} diff --git a/resource-manager/keyvault/2021-10-01/privateendpointconnections/predicates.go b/resource-manager/keyvault/2021-10-01/privateendpointconnections/predicates.go deleted file mode 100644 index accb20a0cc4..00000000000 --- a/resource-manager/keyvault/2021-10-01/privateendpointconnections/predicates.go +++ /dev/null @@ -1,37 +0,0 @@ -package privateendpointconnections - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PrivateEndpointConnectionOperationPredicate struct { - Etag *string - Id *string - Location *string - Name *string - Type *string -} - -func (p PrivateEndpointConnectionOperationPredicate) Matches(input PrivateEndpointConnection) bool { - - if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { - return false - } - - if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { - return false - } - - if p.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/keyvault/2021-10-01/privateendpointconnections/version.go b/resource-manager/keyvault/2021-10-01/privateendpointconnections/version.go deleted file mode 100644 index b5498ab5d03..00000000000 --- a/resource-manager/keyvault/2021-10-01/privateendpointconnections/version.go +++ /dev/null @@ -1,12 +0,0 @@ -package privateendpointconnections - -import "fmt" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -const defaultApiVersion = "2021-10-01" - -func userAgent() string { - return fmt.Sprintf("hashicorp/go-azure-sdk/privateendpointconnections/%s", defaultApiVersion) -} diff --git a/resource-manager/keyvault/2021-10-01/privatelinkresources/README.md b/resource-manager/keyvault/2021-10-01/privatelinkresources/README.md deleted file mode 100644 index f568ec2db3c..00000000000 --- a/resource-manager/keyvault/2021-10-01/privatelinkresources/README.md +++ /dev/null @@ -1,36 +0,0 @@ - -## `github.com/hashicorp/go-azure-sdk/resource-manager/keyvault/2021-10-01/privatelinkresources` Documentation - -The `privatelinkresources` SDK allows for interaction with the Azure Resource Manager Service `keyvault` (API Version `2021-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/keyvault/2021-10-01/privatelinkresources" -``` - - -### Client Initialization - -```go -client := privatelinkresources.NewPrivateLinkResourcesClientWithBaseURI("https://management.azure.com") -client.Client.Authorizer = authorizer -``` - - -### Example Usage: `PrivateLinkResourcesClient.ListByVault` - -```go -ctx := context.TODO() -id := privatelinkresources.NewKeyVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") - -read, err := client.ListByVault(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/keyvault/2021-10-01/privatelinkresources/client.go b/resource-manager/keyvault/2021-10-01/privatelinkresources/client.go deleted file mode 100644 index 5f532940700..00000000000 --- a/resource-manager/keyvault/2021-10-01/privatelinkresources/client.go +++ /dev/null @@ -1,18 +0,0 @@ -package privatelinkresources - -import "github.com/Azure/go-autorest/autorest" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PrivateLinkResourcesClient struct { - Client autorest.Client - baseUri string -} - -func NewPrivateLinkResourcesClientWithBaseURI(endpoint string) PrivateLinkResourcesClient { - return PrivateLinkResourcesClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/resource-manager/keyvault/2021-10-01/privatelinkresources/method_listbyvault_autorest.go b/resource-manager/keyvault/2021-10-01/privatelinkresources/method_listbyvault_autorest.go deleted file mode 100644 index ec68e666d4b..00000000000 --- a/resource-manager/keyvault/2021-10-01/privatelinkresources/method_listbyvault_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package privatelinkresources - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByVaultOperationResponse struct { - HttpResponse *http.Response - Model *PrivateLinkResourceListResult -} - -// ListByVault ... -func (c PrivateLinkResourcesClient) ListByVault(ctx context.Context, id commonids.KeyVaultId) (result ListByVaultOperationResponse, err error) { - req, err := c.preparerForListByVault(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "ListByVault", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "ListByVault", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByVault(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "ListByVault", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByVault prepares the ListByVault request. -func (c PrivateLinkResourcesClient) preparerForListByVault(ctx context.Context, id commonids.KeyVaultId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/privateLinkResources", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByVault handles the response to the ListByVault request. The method always -// closes the http.Response Body. -func (c PrivateLinkResourcesClient) responderForListByVault(resp *http.Response) (result ListByVaultOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2021-10-01/privatelinkresources/model_privatelinkresource.go b/resource-manager/keyvault/2021-10-01/privatelinkresources/model_privatelinkresource.go deleted file mode 100644 index 8bcc42fe6ee..00000000000 --- a/resource-manager/keyvault/2021-10-01/privatelinkresources/model_privatelinkresource.go +++ /dev/null @@ -1,13 +0,0 @@ -package privatelinkresources - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PrivateLinkResource struct { - Id *string `json:"id,omitempty"` - Location *string `json:"location,omitempty"` - Name *string `json:"name,omitempty"` - Properties *PrivateLinkResourceProperties `json:"properties,omitempty"` - Tags *map[string]string `json:"tags,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/resource-manager/keyvault/2021-10-01/privatelinkresources/model_privatelinkresourcelistresult.go b/resource-manager/keyvault/2021-10-01/privatelinkresources/model_privatelinkresourcelistresult.go deleted file mode 100644 index fa950217c47..00000000000 --- a/resource-manager/keyvault/2021-10-01/privatelinkresources/model_privatelinkresourcelistresult.go +++ /dev/null @@ -1,8 +0,0 @@ -package privatelinkresources - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PrivateLinkResourceListResult struct { - Value *[]PrivateLinkResource `json:"value,omitempty"` -} diff --git a/resource-manager/keyvault/2021-10-01/privatelinkresources/model_privatelinkresourceproperties.go b/resource-manager/keyvault/2021-10-01/privatelinkresources/model_privatelinkresourceproperties.go deleted file mode 100644 index 3c98012cdd1..00000000000 --- a/resource-manager/keyvault/2021-10-01/privatelinkresources/model_privatelinkresourceproperties.go +++ /dev/null @@ -1,10 +0,0 @@ -package privatelinkresources - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PrivateLinkResourceProperties struct { - GroupId *string `json:"groupId,omitempty"` - RequiredMembers *[]string `json:"requiredMembers,omitempty"` - RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` -} diff --git a/resource-manager/keyvault/2021-10-01/privatelinkresources/version.go b/resource-manager/keyvault/2021-10-01/privatelinkresources/version.go deleted file mode 100644 index cfe02263ce8..00000000000 --- a/resource-manager/keyvault/2021-10-01/privatelinkresources/version.go +++ /dev/null @@ -1,12 +0,0 @@ -package privatelinkresources - -import "fmt" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -const defaultApiVersion = "2021-10-01" - -func userAgent() string { - return fmt.Sprintf("hashicorp/go-azure-sdk/privatelinkresources/%s", defaultApiVersion) -} diff --git a/resource-manager/keyvault/2021-10-01/secrets/README.md b/resource-manager/keyvault/2021-10-01/secrets/README.md deleted file mode 100644 index 82bce6d36ab..00000000000 --- a/resource-manager/keyvault/2021-10-01/secrets/README.md +++ /dev/null @@ -1,95 +0,0 @@ - -## `github.com/hashicorp/go-azure-sdk/resource-manager/keyvault/2021-10-01/secrets` Documentation - -The `secrets` SDK allows for interaction with the Azure Resource Manager Service `keyvault` (API Version `2021-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/keyvault/2021-10-01/secrets" -``` - - -### Client Initialization - -```go -client := secrets.NewSecretsClientWithBaseURI("https://management.azure.com") -client.Client.Authorizer = authorizer -``` - - -### Example Usage: `SecretsClient.CreateOrUpdate` - -```go -ctx := context.TODO() -id := secrets.NewSecretID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "secretValue") - -payload := secrets.SecretCreateOrUpdateParameters{ - // ... -} - - -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: `SecretsClient.Get` - -```go -ctx := context.TODO() -id := secrets.NewSecretID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "secretValue") - -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: `SecretsClient.List` - -```go -ctx := context.TODO() -id := secrets.NewKeyVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") - -// alternatively `client.List(ctx, id, secrets.DefaultListOperationOptions())` can be used to do batched pagination -items, err := client.ListComplete(ctx, id, secrets.DefaultListOperationOptions()) -if err != nil { - // handle the error -} -for _, item := range items { - // do something -} -``` - - -### Example Usage: `SecretsClient.Update` - -```go -ctx := context.TODO() -id := secrets.NewSecretID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "secretValue") - -payload := secrets.SecretPatchParameters{ - // ... -} - - -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/keyvault/2021-10-01/secrets/client.go b/resource-manager/keyvault/2021-10-01/secrets/client.go deleted file mode 100644 index ab0463026ab..00000000000 --- a/resource-manager/keyvault/2021-10-01/secrets/client.go +++ /dev/null @@ -1,18 +0,0 @@ -package secrets - -import "github.com/Azure/go-autorest/autorest" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type SecretsClient struct { - Client autorest.Client - baseUri string -} - -func NewSecretsClientWithBaseURI(endpoint string) SecretsClient { - return SecretsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/resource-manager/keyvault/2021-10-01/secrets/id_secret.go b/resource-manager/keyvault/2021-10-01/secrets/id_secret.go deleted file mode 100644 index 94dd626c66c..00000000000 --- a/resource-manager/keyvault/2021-10-01/secrets/id_secret.go +++ /dev/null @@ -1,134 +0,0 @@ -package secrets - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -var _ resourceids.ResourceId = &SecretId{} - -// SecretId is a struct representing the Resource ID for a Secret -type SecretId struct { - SubscriptionId string - ResourceGroupName string - VaultName string - SecretName string -} - -// NewSecretID returns a new SecretId struct -func NewSecretID(subscriptionId string, resourceGroupName string, vaultName string, secretName string) SecretId { - return SecretId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - VaultName: vaultName, - SecretName: secretName, - } -} - -// ParseSecretID parses 'input' into a SecretId -func ParseSecretID(input string) (*SecretId, error) { - parser := resourceids.NewParserFromResourceIdType(&SecretId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := SecretId{} - if err := id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -// ParseSecretIDInsensitively parses 'input' case-insensitively into a SecretId -// note: this method should only be used for API response data and not user input -func ParseSecretIDInsensitively(input string) (*SecretId, error) { - parser := resourceids.NewParserFromResourceIdType(&SecretId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := SecretId{} - if err := id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -func (id *SecretId) FromParseResult(input resourceids.ParseResult) error { - var ok bool - - if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) - } - - if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) - } - - if id.VaultName, ok = input.Parsed["vaultName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) - } - - if id.SecretName, ok = input.Parsed["secretName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "secretName", input) - } - - return nil -} - -// ValidateSecretID checks that 'input' can be parsed as a Secret ID -func ValidateSecretID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParseSecretID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Secret ID -func (id SecretId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.KeyVault/vaults/%s/secrets/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.SecretName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Secret ID -func (id SecretId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftKeyVault", "Microsoft.KeyVault", "Microsoft.KeyVault"), - resourceids.StaticSegment("staticVaults", "vaults", "vaults"), - resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), - resourceids.StaticSegment("staticSecrets", "secrets", "secrets"), - resourceids.UserSpecifiedSegment("secretName", "secretValue"), - } -} - -// String returns a human-readable description of this Secret ID -func (id SecretId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Vault Name: %q", id.VaultName), - fmt.Sprintf("Secret Name: %q", id.SecretName), - } - return fmt.Sprintf("Secret (%s)", strings.Join(components, "\n")) -} diff --git a/resource-manager/keyvault/2021-10-01/secrets/id_secret_test.go b/resource-manager/keyvault/2021-10-01/secrets/id_secret_test.go deleted file mode 100644 index a6c6e872056..00000000000 --- a/resource-manager/keyvault/2021-10-01/secrets/id_secret_test.go +++ /dev/null @@ -1,327 +0,0 @@ -package secrets - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -var _ resourceids.ResourceId = &SecretId{} - -func TestNewSecretID(t *testing.T) { - id := NewSecretID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "secretValue") - - if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { - t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") - } - - if id.ResourceGroupName != "example-resource-group" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") - } - - if id.VaultName != "vaultValue" { - t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") - } - - if id.SecretName != "secretValue" { - t.Fatalf("Expected %q but got %q for Segment 'SecretName'", id.SecretName, "secretValue") - } -} - -func TestFormatSecretID(t *testing.T) { - actual := NewSecretID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "secretValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/vaults/vaultValue/secrets/secretValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseSecretID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *SecretId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/vaults", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/vaults/vaultValue", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/vaults/vaultValue/secrets", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/vaults/vaultValue/secrets/secretValue", - Expected: &SecretId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - VaultName: "vaultValue", - SecretName: "secretValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/vaults/vaultValue/secrets/secretValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseSecretID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.VaultName != v.Expected.VaultName { - t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) - } - - if actual.SecretName != v.Expected.SecretName { - t.Fatalf("Expected %q but got %q for SecretName", v.Expected.SecretName, actual.SecretName) - } - - } -} - -func TestParseSecretIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *SecretId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/vaults", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/vAuLtS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/vaults/vaultValue", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/vAuLtS/vAuLtVaLuE", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/vaults/vaultValue/secrets", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/vAuLtS/vAuLtVaLuE/sEcReTs", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/vaults/vaultValue/secrets/secretValue", - Expected: &SecretId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - VaultName: "vaultValue", - SecretName: "secretValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/vaults/vaultValue/secrets/secretValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/vAuLtS/vAuLtVaLuE/sEcReTs/sEcReTvAlUe", - Expected: &SecretId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - VaultName: "vAuLtVaLuE", - SecretName: "sEcReTvAlUe", - }, - }, - { - // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/vAuLtS/vAuLtVaLuE/sEcReTs/sEcReTvAlUe/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseSecretIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.VaultName != v.Expected.VaultName { - t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) - } - - if actual.SecretName != v.Expected.SecretName { - t.Fatalf("Expected %q but got %q for SecretName", v.Expected.SecretName, actual.SecretName) - } - - } -} - -func TestSegmentsForSecretId(t *testing.T) { - segments := SecretId{}.Segments() - if len(segments) == 0 { - t.Fatalf("SecretId has no segments") - } - - uniqueNames := make(map[string]struct{}, 0) - for _, segment := range segments { - uniqueNames[segment.Name] = struct{}{} - } - if len(uniqueNames) != len(segments) { - t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) - } -} diff --git a/resource-manager/keyvault/2021-10-01/secrets/method_createorupdate_autorest.go b/resource-manager/keyvault/2021-10-01/secrets/method_createorupdate_autorest.go deleted file mode 100644 index dd60760906f..00000000000 --- a/resource-manager/keyvault/2021-10-01/secrets/method_createorupdate_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package secrets - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateOperationResponse struct { - HttpResponse *http.Response - Model *Secret -} - -// CreateOrUpdate ... -func (c SecretsClient) CreateOrUpdate(ctx context.Context, id SecretId, input SecretCreateOrUpdateParameters) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "secrets.SecretsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "secrets.SecretsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "secrets.SecretsClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c SecretsClient) preparerForCreateOrUpdate(ctx context.Context, id SecretId, input SecretCreateOrUpdateParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdate handles the response to the CreateOrUpdate request. The method always -// closes the http.Response Body. -func (c SecretsClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2021-10-01/secrets/method_get_autorest.go b/resource-manager/keyvault/2021-10-01/secrets/method_get_autorest.go deleted file mode 100644 index 3f83dfd6db7..00000000000 --- a/resource-manager/keyvault/2021-10-01/secrets/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package secrets - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *Secret -} - -// Get ... -func (c SecretsClient) Get(ctx context.Context, id SecretId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "secrets.SecretsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "secrets.SecretsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "secrets.SecretsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c SecretsClient) preparerForGet(ctx context.Context, id SecretId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c SecretsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2021-10-01/secrets/method_list_autorest.go b/resource-manager/keyvault/2021-10-01/secrets/method_list_autorest.go deleted file mode 100644 index e00c01e9111..00000000000 --- a/resource-manager/keyvault/2021-10-01/secrets/method_list_autorest.go +++ /dev/null @@ -1,216 +0,0 @@ -package secrets - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *[]Secret - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []Secret -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListOperationOptions struct { - Top *int64 -} - -func DefaultListOperationOptions() ListOperationOptions { - return ListOperationOptions{} -} - -func (o ListOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// List ... -func (c SecretsClient) List(ctx context.Context, id commonids.KeyVaultId, options ListOperationOptions) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "secrets.SecretsClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "secrets.SecretsClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "secrets.SecretsClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c SecretsClient) preparerForList(ctx context.Context, id commonids.KeyVaultId, options ListOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/secrets", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c SecretsClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c SecretsClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []Secret `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { - req, err := c.preparerForListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "secrets.SecretsClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "secrets.SecretsClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "secrets.SecretsClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c SecretsClient) ListComplete(ctx context.Context, id commonids.KeyVaultId, options ListOperationOptions) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, options, SecretOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c SecretsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.KeyVaultId, options ListOperationOptions, predicate SecretOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]Secret, 0) - - page, err := c.List(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/keyvault/2021-10-01/secrets/method_update_autorest.go b/resource-manager/keyvault/2021-10-01/secrets/method_update_autorest.go deleted file mode 100644 index 8d1da9199de..00000000000 --- a/resource-manager/keyvault/2021-10-01/secrets/method_update_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package secrets - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateOperationResponse struct { - HttpResponse *http.Response - Model *Secret -} - -// Update ... -func (c SecretsClient) Update(ctx context.Context, id SecretId, input SecretPatchParameters) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "secrets.SecretsClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "secrets.SecretsClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "secrets.SecretsClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c SecretsClient) preparerForUpdate(ctx context.Context, id SecretId, input SecretPatchParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdate handles the response to the Update request. The method always -// closes the http.Response Body. -func (c SecretsClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2021-10-01/secrets/model_attributes.go b/resource-manager/keyvault/2021-10-01/secrets/model_attributes.go deleted file mode 100644 index 7f0df4ceec4..00000000000 --- a/resource-manager/keyvault/2021-10-01/secrets/model_attributes.go +++ /dev/null @@ -1,12 +0,0 @@ -package secrets - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type Attributes struct { - Created *int64 `json:"created,omitempty"` - Enabled *bool `json:"enabled,omitempty"` - Exp *int64 `json:"exp,omitempty"` - Nbf *int64 `json:"nbf,omitempty"` - Updated *int64 `json:"updated,omitempty"` -} diff --git a/resource-manager/keyvault/2021-10-01/secrets/model_secret.go b/resource-manager/keyvault/2021-10-01/secrets/model_secret.go deleted file mode 100644 index 08ae4eaf41c..00000000000 --- a/resource-manager/keyvault/2021-10-01/secrets/model_secret.go +++ /dev/null @@ -1,13 +0,0 @@ -package secrets - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type Secret struct { - Id *string `json:"id,omitempty"` - Location *string `json:"location,omitempty"` - Name *string `json:"name,omitempty"` - Properties SecretProperties `json:"properties"` - Tags *map[string]string `json:"tags,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/resource-manager/keyvault/2021-10-01/secrets/model_secretcreateorupdateparameters.go b/resource-manager/keyvault/2021-10-01/secrets/model_secretcreateorupdateparameters.go deleted file mode 100644 index 490bd25485b..00000000000 --- a/resource-manager/keyvault/2021-10-01/secrets/model_secretcreateorupdateparameters.go +++ /dev/null @@ -1,9 +0,0 @@ -package secrets - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type SecretCreateOrUpdateParameters struct { - Properties SecretProperties `json:"properties"` - Tags *map[string]string `json:"tags,omitempty"` -} diff --git a/resource-manager/keyvault/2021-10-01/secrets/model_secretpatchparameters.go b/resource-manager/keyvault/2021-10-01/secrets/model_secretpatchparameters.go deleted file mode 100644 index cb0d643f77a..00000000000 --- a/resource-manager/keyvault/2021-10-01/secrets/model_secretpatchparameters.go +++ /dev/null @@ -1,9 +0,0 @@ -package secrets - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type SecretPatchParameters struct { - Properties *SecretPatchProperties `json:"properties,omitempty"` - Tags *map[string]string `json:"tags,omitempty"` -} diff --git a/resource-manager/keyvault/2021-10-01/secrets/model_secretpatchproperties.go b/resource-manager/keyvault/2021-10-01/secrets/model_secretpatchproperties.go deleted file mode 100644 index d5fb8bddecf..00000000000 --- a/resource-manager/keyvault/2021-10-01/secrets/model_secretpatchproperties.go +++ /dev/null @@ -1,10 +0,0 @@ -package secrets - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type SecretPatchProperties struct { - Attributes *Attributes `json:"attributes,omitempty"` - ContentType *string `json:"contentType,omitempty"` - Value *string `json:"value,omitempty"` -} diff --git a/resource-manager/keyvault/2021-10-01/secrets/model_secretproperties.go b/resource-manager/keyvault/2021-10-01/secrets/model_secretproperties.go deleted file mode 100644 index a11f76f93b9..00000000000 --- a/resource-manager/keyvault/2021-10-01/secrets/model_secretproperties.go +++ /dev/null @@ -1,12 +0,0 @@ -package secrets - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type SecretProperties struct { - Attributes *Attributes `json:"attributes,omitempty"` - ContentType *string `json:"contentType,omitempty"` - SecretUri *string `json:"secretUri,omitempty"` - SecretUriWithVersion *string `json:"secretUriWithVersion,omitempty"` - Value *string `json:"value,omitempty"` -} diff --git a/resource-manager/keyvault/2021-10-01/secrets/predicates.go b/resource-manager/keyvault/2021-10-01/secrets/predicates.go deleted file mode 100644 index 1eb8d4feaa8..00000000000 --- a/resource-manager/keyvault/2021-10-01/secrets/predicates.go +++ /dev/null @@ -1,32 +0,0 @@ -package secrets - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type SecretOperationPredicate struct { - Id *string - Location *string - Name *string - Type *string -} - -func (p SecretOperationPredicate) Matches(input Secret) 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/keyvault/2021-10-01/secrets/version.go b/resource-manager/keyvault/2021-10-01/secrets/version.go deleted file mode 100644 index 091bf1f941b..00000000000 --- a/resource-manager/keyvault/2021-10-01/secrets/version.go +++ /dev/null @@ -1,12 +0,0 @@ -package secrets - -import "fmt" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -const defaultApiVersion = "2021-10-01" - -func userAgent() string { - return fmt.Sprintf("hashicorp/go-azure-sdk/secrets/%s", defaultApiVersion) -} diff --git a/resource-manager/keyvault/2021-10-01/vaults/README.md b/resource-manager/keyvault/2021-10-01/vaults/README.md deleted file mode 100644 index 6976066d75f..00000000000 --- a/resource-manager/keyvault/2021-10-01/vaults/README.md +++ /dev/null @@ -1,228 +0,0 @@ - -## `github.com/hashicorp/go-azure-sdk/resource-manager/keyvault/2021-10-01/vaults` Documentation - -The `vaults` SDK allows for interaction with the Azure Resource Manager Service `keyvault` (API Version `2021-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/keyvault/2021-10-01/vaults" -``` - - -### Client Initialization - -```go -client := vaults.NewVaultsClientWithBaseURI("https://management.azure.com") -client.Client.Authorizer = authorizer -``` - - -### Example Usage: `VaultsClient.CheckNameAvailability` - -```go -ctx := context.TODO() -id := vaults.NewSubscriptionID("12345678-1234-9876-4563-123456789012") - -payload := vaults.VaultCheckNameAvailabilityParameters{ - // ... -} - - -read, err := client.CheckNameAvailability(ctx, id, payload) -if err != nil { - // handle the error -} -if model := read.Model; model != nil { - // do something with the model/response object -} -``` - - -### Example Usage: `VaultsClient.CreateOrUpdate` - -```go -ctx := context.TODO() -id := vaults.NewKeyVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") - -payload := vaults.VaultCreateOrUpdateParameters{ - // ... -} - - -if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { - // handle the error -} -``` - - -### Example Usage: `VaultsClient.Delete` - -```go -ctx := context.TODO() -id := vaults.NewKeyVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") - -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: `VaultsClient.Get` - -```go -ctx := context.TODO() -id := vaults.NewKeyVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") - -read, err := client.Get(ctx, id) -if err != nil { - // handle the error -} -if model := read.Model; model != nil { - // do something with the model/response object -} -``` - - -### Example Usage: `VaultsClient.GetDeleted` - -```go -ctx := context.TODO() -id := vaults.NewDeletedVaultID("12345678-1234-9876-4563-123456789012", "locationValue", "deletedVaultValue") - -read, err := client.GetDeleted(ctx, id) -if err != nil { - // handle the error -} -if model := read.Model; model != nil { - // do something with the model/response object -} -``` - - -### Example Usage: `VaultsClient.List` - -```go -ctx := context.TODO() -id := vaults.NewSubscriptionID("12345678-1234-9876-4563-123456789012") - -// alternatively `client.List(ctx, id, vaults.DefaultListOperationOptions())` can be used to do batched pagination -items, err := client.ListComplete(ctx, id, vaults.DefaultListOperationOptions()) -if err != nil { - // handle the error -} -for _, item := range items { - // do something -} -``` - - -### Example Usage: `VaultsClient.ListByResourceGroup` - -```go -ctx := context.TODO() -id := vaults.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") - -// alternatively `client.ListByResourceGroup(ctx, id, vaults.DefaultListByResourceGroupOperationOptions())` can be used to do batched pagination -items, err := client.ListByResourceGroupComplete(ctx, id, vaults.DefaultListByResourceGroupOperationOptions()) -if err != nil { - // handle the error -} -for _, item := range items { - // do something -} -``` - - -### Example Usage: `VaultsClient.ListBySubscription` - -```go -ctx := context.TODO() -id := vaults.NewSubscriptionID("12345678-1234-9876-4563-123456789012") - -// alternatively `client.ListBySubscription(ctx, id, vaults.DefaultListBySubscriptionOperationOptions())` can be used to do batched pagination -items, err := client.ListBySubscriptionComplete(ctx, id, vaults.DefaultListBySubscriptionOperationOptions()) -if err != nil { - // handle the error -} -for _, item := range items { - // do something -} -``` - - -### Example Usage: `VaultsClient.ListDeleted` - -```go -ctx := context.TODO() -id := vaults.NewSubscriptionID("12345678-1234-9876-4563-123456789012") - -// alternatively `client.ListDeleted(ctx, id)` can be used to do batched pagination -items, err := client.ListDeletedComplete(ctx, id) -if err != nil { - // handle the error -} -for _, item := range items { - // do something -} -``` - - -### Example Usage: `VaultsClient.PurgeDeleted` - -```go -ctx := context.TODO() -id := vaults.NewDeletedVaultID("12345678-1234-9876-4563-123456789012", "locationValue", "deletedVaultValue") - -if err := client.PurgeDeletedThenPoll(ctx, id); err != nil { - // handle the error -} -``` - - -### Example Usage: `VaultsClient.Update` - -```go -ctx := context.TODO() -id := vaults.NewKeyVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") - -payload := vaults.VaultPatchParameters{ - // ... -} - - -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: `VaultsClient.UpdateAccessPolicy` - -```go -ctx := context.TODO() -id := vaults.NewOperationKindID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "add") - -payload := vaults.VaultAccessPolicyParameters{ - // ... -} - - -read, err := client.UpdateAccessPolicy(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/keyvault/2021-10-01/vaults/client.go b/resource-manager/keyvault/2021-10-01/vaults/client.go deleted file mode 100644 index 6cad2ef703e..00000000000 --- a/resource-manager/keyvault/2021-10-01/vaults/client.go +++ /dev/null @@ -1,18 +0,0 @@ -package vaults - -import "github.com/Azure/go-autorest/autorest" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type VaultsClient struct { - Client autorest.Client - baseUri string -} - -func NewVaultsClientWithBaseURI(endpoint string) VaultsClient { - return VaultsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/resource-manager/keyvault/2021-10-01/vaults/constants.go b/resource-manager/keyvault/2021-10-01/vaults/constants.go deleted file mode 100644 index 0e9e4122165..00000000000 --- a/resource-manager/keyvault/2021-10-01/vaults/constants.go +++ /dev/null @@ -1,641 +0,0 @@ -package vaults - -import "strings" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type AccessPolicyUpdateKind string - -const ( - AccessPolicyUpdateKindAdd AccessPolicyUpdateKind = "add" - AccessPolicyUpdateKindRemove AccessPolicyUpdateKind = "remove" - AccessPolicyUpdateKindReplace AccessPolicyUpdateKind = "replace" -) - -func PossibleValuesForAccessPolicyUpdateKind() []string { - return []string{ - string(AccessPolicyUpdateKindAdd), - string(AccessPolicyUpdateKindRemove), - string(AccessPolicyUpdateKindReplace), - } -} - -func parseAccessPolicyUpdateKind(input string) (*AccessPolicyUpdateKind, error) { - vals := map[string]AccessPolicyUpdateKind{ - "add": AccessPolicyUpdateKindAdd, - "remove": AccessPolicyUpdateKindRemove, - "replace": AccessPolicyUpdateKindReplace, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := AccessPolicyUpdateKind(input) - return &out, nil -} - -type ActionsRequired string - -const ( - ActionsRequiredNone ActionsRequired = "None" -) - -func PossibleValuesForActionsRequired() []string { - return []string{ - string(ActionsRequiredNone), - } -} - -func parseActionsRequired(input string) (*ActionsRequired, error) { - vals := map[string]ActionsRequired{ - "none": ActionsRequiredNone, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ActionsRequired(input) - return &out, nil -} - -type CertificatePermissions string - -const ( - CertificatePermissionsAll CertificatePermissions = "all" - CertificatePermissionsBackup CertificatePermissions = "backup" - CertificatePermissionsCreate CertificatePermissions = "create" - CertificatePermissionsDelete CertificatePermissions = "delete" - CertificatePermissionsDeleteissuers CertificatePermissions = "deleteissuers" - CertificatePermissionsGet CertificatePermissions = "get" - CertificatePermissionsGetissuers CertificatePermissions = "getissuers" - CertificatePermissionsImport CertificatePermissions = "import" - CertificatePermissionsList CertificatePermissions = "list" - CertificatePermissionsListissuers CertificatePermissions = "listissuers" - CertificatePermissionsManagecontacts CertificatePermissions = "managecontacts" - CertificatePermissionsManageissuers CertificatePermissions = "manageissuers" - CertificatePermissionsPurge CertificatePermissions = "purge" - CertificatePermissionsRecover CertificatePermissions = "recover" - CertificatePermissionsRestore CertificatePermissions = "restore" - CertificatePermissionsSetissuers CertificatePermissions = "setissuers" - CertificatePermissionsUpdate CertificatePermissions = "update" -) - -func PossibleValuesForCertificatePermissions() []string { - return []string{ - string(CertificatePermissionsAll), - string(CertificatePermissionsBackup), - string(CertificatePermissionsCreate), - string(CertificatePermissionsDelete), - string(CertificatePermissionsDeleteissuers), - string(CertificatePermissionsGet), - string(CertificatePermissionsGetissuers), - string(CertificatePermissionsImport), - string(CertificatePermissionsList), - string(CertificatePermissionsListissuers), - string(CertificatePermissionsManagecontacts), - string(CertificatePermissionsManageissuers), - string(CertificatePermissionsPurge), - string(CertificatePermissionsRecover), - string(CertificatePermissionsRestore), - string(CertificatePermissionsSetissuers), - string(CertificatePermissionsUpdate), - } -} - -func parseCertificatePermissions(input string) (*CertificatePermissions, error) { - vals := map[string]CertificatePermissions{ - "all": CertificatePermissionsAll, - "backup": CertificatePermissionsBackup, - "create": CertificatePermissionsCreate, - "delete": CertificatePermissionsDelete, - "deleteissuers": CertificatePermissionsDeleteissuers, - "get": CertificatePermissionsGet, - "getissuers": CertificatePermissionsGetissuers, - "import": CertificatePermissionsImport, - "list": CertificatePermissionsList, - "listissuers": CertificatePermissionsListissuers, - "managecontacts": CertificatePermissionsManagecontacts, - "manageissuers": CertificatePermissionsManageissuers, - "purge": CertificatePermissionsPurge, - "recover": CertificatePermissionsRecover, - "restore": CertificatePermissionsRestore, - "setissuers": CertificatePermissionsSetissuers, - "update": CertificatePermissionsUpdate, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := CertificatePermissions(input) - return &out, nil -} - -type CreateMode string - -const ( - CreateModeDefault CreateMode = "default" - CreateModeRecover CreateMode = "recover" -) - -func PossibleValuesForCreateMode() []string { - return []string{ - string(CreateModeDefault), - string(CreateModeRecover), - } -} - -func parseCreateMode(input string) (*CreateMode, error) { - vals := map[string]CreateMode{ - "default": CreateModeDefault, - "recover": CreateModeRecover, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := CreateMode(input) - return &out, nil -} - -type KeyPermissions string - -const ( - KeyPermissionsAll KeyPermissions = "all" - KeyPermissionsBackup KeyPermissions = "backup" - KeyPermissionsCreate KeyPermissions = "create" - KeyPermissionsDecrypt KeyPermissions = "decrypt" - KeyPermissionsDelete KeyPermissions = "delete" - KeyPermissionsEncrypt KeyPermissions = "encrypt" - KeyPermissionsGet KeyPermissions = "get" - KeyPermissionsImport KeyPermissions = "import" - KeyPermissionsList KeyPermissions = "list" - KeyPermissionsPurge KeyPermissions = "purge" - KeyPermissionsRecover KeyPermissions = "recover" - KeyPermissionsRestore KeyPermissions = "restore" - KeyPermissionsSign KeyPermissions = "sign" - KeyPermissionsUnwrapKey KeyPermissions = "unwrapKey" - KeyPermissionsUpdate KeyPermissions = "update" - KeyPermissionsVerify KeyPermissions = "verify" - KeyPermissionsWrapKey KeyPermissions = "wrapKey" -) - -func PossibleValuesForKeyPermissions() []string { - return []string{ - string(KeyPermissionsAll), - string(KeyPermissionsBackup), - string(KeyPermissionsCreate), - string(KeyPermissionsDecrypt), - string(KeyPermissionsDelete), - string(KeyPermissionsEncrypt), - string(KeyPermissionsGet), - string(KeyPermissionsImport), - string(KeyPermissionsList), - string(KeyPermissionsPurge), - string(KeyPermissionsRecover), - string(KeyPermissionsRestore), - string(KeyPermissionsSign), - string(KeyPermissionsUnwrapKey), - string(KeyPermissionsUpdate), - string(KeyPermissionsVerify), - string(KeyPermissionsWrapKey), - } -} - -func parseKeyPermissions(input string) (*KeyPermissions, error) { - vals := map[string]KeyPermissions{ - "all": KeyPermissionsAll, - "backup": KeyPermissionsBackup, - "create": KeyPermissionsCreate, - "decrypt": KeyPermissionsDecrypt, - "delete": KeyPermissionsDelete, - "encrypt": KeyPermissionsEncrypt, - "get": KeyPermissionsGet, - "import": KeyPermissionsImport, - "list": KeyPermissionsList, - "purge": KeyPermissionsPurge, - "recover": KeyPermissionsRecover, - "restore": KeyPermissionsRestore, - "sign": KeyPermissionsSign, - "unwrapkey": KeyPermissionsUnwrapKey, - "update": KeyPermissionsUpdate, - "verify": KeyPermissionsVerify, - "wrapkey": KeyPermissionsWrapKey, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := KeyPermissions(input) - return &out, nil -} - -type NetworkRuleAction string - -const ( - NetworkRuleActionAllow NetworkRuleAction = "Allow" - NetworkRuleActionDeny NetworkRuleAction = "Deny" -) - -func PossibleValuesForNetworkRuleAction() []string { - return []string{ - string(NetworkRuleActionAllow), - string(NetworkRuleActionDeny), - } -} - -func parseNetworkRuleAction(input string) (*NetworkRuleAction, error) { - vals := map[string]NetworkRuleAction{ - "allow": NetworkRuleActionAllow, - "deny": NetworkRuleActionDeny, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := NetworkRuleAction(input) - return &out, nil -} - -type NetworkRuleBypassOptions string - -const ( - NetworkRuleBypassOptionsAzureServices NetworkRuleBypassOptions = "AzureServices" - NetworkRuleBypassOptionsNone NetworkRuleBypassOptions = "None" -) - -func PossibleValuesForNetworkRuleBypassOptions() []string { - return []string{ - string(NetworkRuleBypassOptionsAzureServices), - string(NetworkRuleBypassOptionsNone), - } -} - -func parseNetworkRuleBypassOptions(input string) (*NetworkRuleBypassOptions, error) { - vals := map[string]NetworkRuleBypassOptions{ - "azureservices": NetworkRuleBypassOptionsAzureServices, - "none": NetworkRuleBypassOptionsNone, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := NetworkRuleBypassOptions(input) - return &out, nil -} - -type PrivateEndpointConnectionProvisioningState string - -const ( - PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" - PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" - PrivateEndpointConnectionProvisioningStateDisconnected PrivateEndpointConnectionProvisioningState = "Disconnected" - PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" - PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" - PrivateEndpointConnectionProvisioningStateUpdating PrivateEndpointConnectionProvisioningState = "Updating" -) - -func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { - return []string{ - string(PrivateEndpointConnectionProvisioningStateCreating), - string(PrivateEndpointConnectionProvisioningStateDeleting), - string(PrivateEndpointConnectionProvisioningStateDisconnected), - string(PrivateEndpointConnectionProvisioningStateFailed), - string(PrivateEndpointConnectionProvisioningStateSucceeded), - string(PrivateEndpointConnectionProvisioningStateUpdating), - } -} - -func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { - vals := map[string]PrivateEndpointConnectionProvisioningState{ - "creating": PrivateEndpointConnectionProvisioningStateCreating, - "deleting": PrivateEndpointConnectionProvisioningStateDeleting, - "disconnected": PrivateEndpointConnectionProvisioningStateDisconnected, - "failed": PrivateEndpointConnectionProvisioningStateFailed, - "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, - "updating": PrivateEndpointConnectionProvisioningStateUpdating, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := PrivateEndpointConnectionProvisioningState(input) - return &out, nil -} - -type PrivateEndpointServiceConnectionStatus string - -const ( - PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" - PrivateEndpointServiceConnectionStatusDisconnected PrivateEndpointServiceConnectionStatus = "Disconnected" - PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" - PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" -) - -func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { - return []string{ - string(PrivateEndpointServiceConnectionStatusApproved), - string(PrivateEndpointServiceConnectionStatusDisconnected), - string(PrivateEndpointServiceConnectionStatusPending), - string(PrivateEndpointServiceConnectionStatusRejected), - } -} - -func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { - vals := map[string]PrivateEndpointServiceConnectionStatus{ - "approved": PrivateEndpointServiceConnectionStatusApproved, - "disconnected": PrivateEndpointServiceConnectionStatusDisconnected, - "pending": PrivateEndpointServiceConnectionStatusPending, - "rejected": PrivateEndpointServiceConnectionStatusRejected, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := PrivateEndpointServiceConnectionStatus(input) - return &out, nil -} - -type Reason string - -const ( - ReasonAccountNameInvalid Reason = "AccountNameInvalid" - ReasonAlreadyExists Reason = "AlreadyExists" -) - -func PossibleValuesForReason() []string { - return []string{ - string(ReasonAccountNameInvalid), - string(ReasonAlreadyExists), - } -} - -func parseReason(input string) (*Reason, error) { - vals := map[string]Reason{ - "accountnameinvalid": ReasonAccountNameInvalid, - "alreadyexists": ReasonAlreadyExists, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := Reason(input) - return &out, nil -} - -type SecretPermissions string - -const ( - SecretPermissionsAll SecretPermissions = "all" - SecretPermissionsBackup SecretPermissions = "backup" - SecretPermissionsDelete SecretPermissions = "delete" - SecretPermissionsGet SecretPermissions = "get" - SecretPermissionsList SecretPermissions = "list" - SecretPermissionsPurge SecretPermissions = "purge" - SecretPermissionsRecover SecretPermissions = "recover" - SecretPermissionsRestore SecretPermissions = "restore" - SecretPermissionsSet SecretPermissions = "set" -) - -func PossibleValuesForSecretPermissions() []string { - return []string{ - string(SecretPermissionsAll), - string(SecretPermissionsBackup), - string(SecretPermissionsDelete), - string(SecretPermissionsGet), - string(SecretPermissionsList), - string(SecretPermissionsPurge), - string(SecretPermissionsRecover), - string(SecretPermissionsRestore), - string(SecretPermissionsSet), - } -} - -func parseSecretPermissions(input string) (*SecretPermissions, error) { - vals := map[string]SecretPermissions{ - "all": SecretPermissionsAll, - "backup": SecretPermissionsBackup, - "delete": SecretPermissionsDelete, - "get": SecretPermissionsGet, - "list": SecretPermissionsList, - "purge": SecretPermissionsPurge, - "recover": SecretPermissionsRecover, - "restore": SecretPermissionsRestore, - "set": SecretPermissionsSet, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := SecretPermissions(input) - return &out, nil -} - -type SkuFamily string - -const ( - SkuFamilyA SkuFamily = "A" -) - -func PossibleValuesForSkuFamily() []string { - return []string{ - string(SkuFamilyA), - } -} - -func parseSkuFamily(input string) (*SkuFamily, error) { - vals := map[string]SkuFamily{ - "a": SkuFamilyA, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := SkuFamily(input) - return &out, nil -} - -type SkuName string - -const ( - SkuNamePremium SkuName = "premium" - SkuNameStandard SkuName = "standard" -) - -func PossibleValuesForSkuName() []string { - return []string{ - string(SkuNamePremium), - string(SkuNameStandard), - } -} - -func parseSkuName(input string) (*SkuName, error) { - vals := map[string]SkuName{ - "premium": SkuNamePremium, - "standard": SkuNameStandard, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := SkuName(input) - return &out, nil -} - -type StoragePermissions string - -const ( - StoragePermissionsAll StoragePermissions = "all" - StoragePermissionsBackup StoragePermissions = "backup" - StoragePermissionsDelete StoragePermissions = "delete" - StoragePermissionsDeletesas StoragePermissions = "deletesas" - StoragePermissionsGet StoragePermissions = "get" - StoragePermissionsGetsas StoragePermissions = "getsas" - StoragePermissionsList StoragePermissions = "list" - StoragePermissionsListsas StoragePermissions = "listsas" - StoragePermissionsPurge StoragePermissions = "purge" - StoragePermissionsRecover StoragePermissions = "recover" - StoragePermissionsRegeneratekey StoragePermissions = "regeneratekey" - StoragePermissionsRestore StoragePermissions = "restore" - StoragePermissionsSet StoragePermissions = "set" - StoragePermissionsSetsas StoragePermissions = "setsas" - StoragePermissionsUpdate StoragePermissions = "update" -) - -func PossibleValuesForStoragePermissions() []string { - return []string{ - string(StoragePermissionsAll), - string(StoragePermissionsBackup), - string(StoragePermissionsDelete), - string(StoragePermissionsDeletesas), - string(StoragePermissionsGet), - string(StoragePermissionsGetsas), - string(StoragePermissionsList), - string(StoragePermissionsListsas), - string(StoragePermissionsPurge), - string(StoragePermissionsRecover), - string(StoragePermissionsRegeneratekey), - string(StoragePermissionsRestore), - string(StoragePermissionsSet), - string(StoragePermissionsSetsas), - string(StoragePermissionsUpdate), - } -} - -func parseStoragePermissions(input string) (*StoragePermissions, error) { - vals := map[string]StoragePermissions{ - "all": StoragePermissionsAll, - "backup": StoragePermissionsBackup, - "delete": StoragePermissionsDelete, - "deletesas": StoragePermissionsDeletesas, - "get": StoragePermissionsGet, - "getsas": StoragePermissionsGetsas, - "list": StoragePermissionsList, - "listsas": StoragePermissionsListsas, - "purge": StoragePermissionsPurge, - "recover": StoragePermissionsRecover, - "regeneratekey": StoragePermissionsRegeneratekey, - "restore": StoragePermissionsRestore, - "set": StoragePermissionsSet, - "setsas": StoragePermissionsSetsas, - "update": StoragePermissionsUpdate, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := StoragePermissions(input) - return &out, nil -} - -type Type string - -const ( - TypeMicrosoftPointKeyVaultVaults Type = "Microsoft.KeyVault/vaults" -) - -func PossibleValuesForType() []string { - return []string{ - string(TypeMicrosoftPointKeyVaultVaults), - } -} - -func parseType(input string) (*Type, error) { - vals := map[string]Type{ - "microsoft.keyvault/vaults": TypeMicrosoftPointKeyVaultVaults, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := Type(input) - return &out, nil -} - -type VaultListFilterTypes string - -const ( - VaultListFilterTypesResourceTypeEqMicrosoftPointKeyVaultVaults VaultListFilterTypes = "resourceType eq 'Microsoft.KeyVault/vaults'" -) - -func PossibleValuesForVaultListFilterTypes() []string { - return []string{ - string(VaultListFilterTypesResourceTypeEqMicrosoftPointKeyVaultVaults), - } -} - -func parseVaultListFilterTypes(input string) (*VaultListFilterTypes, error) { - vals := map[string]VaultListFilterTypes{ - "resourcetype eq 'microsoft.keyvault/vaults'": VaultListFilterTypesResourceTypeEqMicrosoftPointKeyVaultVaults, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := VaultListFilterTypes(input) - return &out, nil -} - -type VaultProvisioningState string - -const ( - VaultProvisioningStateRegisteringDns VaultProvisioningState = "RegisteringDns" - VaultProvisioningStateSucceeded VaultProvisioningState = "Succeeded" -) - -func PossibleValuesForVaultProvisioningState() []string { - return []string{ - string(VaultProvisioningStateRegisteringDns), - string(VaultProvisioningStateSucceeded), - } -} - -func parseVaultProvisioningState(input string) (*VaultProvisioningState, error) { - vals := map[string]VaultProvisioningState{ - "registeringdns": VaultProvisioningStateRegisteringDns, - "succeeded": VaultProvisioningStateSucceeded, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := VaultProvisioningState(input) - return &out, nil -} diff --git a/resource-manager/keyvault/2021-10-01/vaults/id_deletedvault.go b/resource-manager/keyvault/2021-10-01/vaults/id_deletedvault.go deleted file mode 100644 index 4575767c2e2..00000000000 --- a/resource-manager/keyvault/2021-10-01/vaults/id_deletedvault.go +++ /dev/null @@ -1,125 +0,0 @@ -package vaults - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -var _ resourceids.ResourceId = &DeletedVaultId{} - -// DeletedVaultId is a struct representing the Resource ID for a Deleted Vault -type DeletedVaultId struct { - SubscriptionId string - LocationName string - DeletedVaultName string -} - -// NewDeletedVaultID returns a new DeletedVaultId struct -func NewDeletedVaultID(subscriptionId string, locationName string, deletedVaultName string) DeletedVaultId { - return DeletedVaultId{ - SubscriptionId: subscriptionId, - LocationName: locationName, - DeletedVaultName: deletedVaultName, - } -} - -// ParseDeletedVaultID parses 'input' into a DeletedVaultId -func ParseDeletedVaultID(input string) (*DeletedVaultId, error) { - parser := resourceids.NewParserFromResourceIdType(&DeletedVaultId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := DeletedVaultId{} - if err := id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -// ParseDeletedVaultIDInsensitively parses 'input' case-insensitively into a DeletedVaultId -// note: this method should only be used for API response data and not user input -func ParseDeletedVaultIDInsensitively(input string) (*DeletedVaultId, error) { - parser := resourceids.NewParserFromResourceIdType(&DeletedVaultId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := DeletedVaultId{} - if err := id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -func (id *DeletedVaultId) FromParseResult(input resourceids.ParseResult) error { - var ok bool - - if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) - } - - if id.LocationName, ok = input.Parsed["locationName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) - } - - if id.DeletedVaultName, ok = input.Parsed["deletedVaultName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "deletedVaultName", input) - } - - return nil -} - -// ValidateDeletedVaultID checks that 'input' can be parsed as a Deleted Vault ID -func ValidateDeletedVaultID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParseDeletedVaultID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Deleted Vault ID -func (id DeletedVaultId) ID() string { - fmtString := "/subscriptions/%s/providers/Microsoft.KeyVault/locations/%s/deletedVaults/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName, id.DeletedVaultName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Deleted Vault ID -func (id DeletedVaultId) 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("staticMicrosoftKeyVault", "Microsoft.KeyVault", "Microsoft.KeyVault"), - resourceids.StaticSegment("staticLocations", "locations", "locations"), - resourceids.UserSpecifiedSegment("locationName", "locationValue"), - resourceids.StaticSegment("staticDeletedVaults", "deletedVaults", "deletedVaults"), - resourceids.UserSpecifiedSegment("deletedVaultName", "deletedVaultValue"), - } -} - -// String returns a human-readable description of this Deleted Vault ID -func (id DeletedVaultId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Location Name: %q", id.LocationName), - fmt.Sprintf("Deleted Vault Name: %q", id.DeletedVaultName), - } - return fmt.Sprintf("Deleted Vault (%s)", strings.Join(components, "\n")) -} diff --git a/resource-manager/keyvault/2021-10-01/vaults/id_deletedvault_test.go b/resource-manager/keyvault/2021-10-01/vaults/id_deletedvault_test.go deleted file mode 100644 index b76e29d4fc7..00000000000 --- a/resource-manager/keyvault/2021-10-01/vaults/id_deletedvault_test.go +++ /dev/null @@ -1,282 +0,0 @@ -package vaults - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -var _ resourceids.ResourceId = &DeletedVaultId{} - -func TestNewDeletedVaultID(t *testing.T) { - id := NewDeletedVaultID("12345678-1234-9876-4563-123456789012", "locationValue", "deletedVaultValue") - - if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { - t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") - } - - if id.LocationName != "locationValue" { - t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationValue") - } - - if id.DeletedVaultName != "deletedVaultValue" { - t.Fatalf("Expected %q but got %q for Segment 'DeletedVaultName'", id.DeletedVaultName, "deletedVaultValue") - } -} - -func TestFormatDeletedVaultID(t *testing.T) { - actual := NewDeletedVaultID("12345678-1234-9876-4563-123456789012", "locationValue", "deletedVaultValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.KeyVault/locations/locationValue/deletedVaults/deletedVaultValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseDeletedVaultID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *DeletedVaultId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - 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.KeyVault", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.KeyVault/locations", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.KeyVault/locations/locationValue", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.KeyVault/locations/locationValue/deletedVaults", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.KeyVault/locations/locationValue/deletedVaults/deletedVaultValue", - Expected: &DeletedVaultId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - LocationName: "locationValue", - DeletedVaultName: "deletedVaultValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.KeyVault/locations/locationValue/deletedVaults/deletedVaultValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseDeletedVaultID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.LocationName != v.Expected.LocationName { - t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) - } - - if actual.DeletedVaultName != v.Expected.DeletedVaultName { - t.Fatalf("Expected %q but got %q for DeletedVaultName", v.Expected.DeletedVaultName, actual.DeletedVaultName) - } - - } -} - -func TestParseDeletedVaultIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *DeletedVaultId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI (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.KeyVault", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.kEyVaUlT", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.KeyVault/locations", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.kEyVaUlT/lOcAtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.KeyVault/locations/locationValue", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.kEyVaUlT/lOcAtIoNs/lOcAtIoNvAlUe", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.KeyVault/locations/locationValue/deletedVaults", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.kEyVaUlT/lOcAtIoNs/lOcAtIoNvAlUe/dElEtEdVaUlTs", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.KeyVault/locations/locationValue/deletedVaults/deletedVaultValue", - Expected: &DeletedVaultId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - LocationName: "locationValue", - DeletedVaultName: "deletedVaultValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.KeyVault/locations/locationValue/deletedVaults/deletedVaultValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.kEyVaUlT/lOcAtIoNs/lOcAtIoNvAlUe/dElEtEdVaUlTs/dElEtEdVaUlTvAlUe", - Expected: &DeletedVaultId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - LocationName: "lOcAtIoNvAlUe", - DeletedVaultName: "dElEtEdVaUlTvAlUe", - }, - }, - { - // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.kEyVaUlT/lOcAtIoNs/lOcAtIoNvAlUe/dElEtEdVaUlTs/dElEtEdVaUlTvAlUe/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseDeletedVaultIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.LocationName != v.Expected.LocationName { - t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) - } - - if actual.DeletedVaultName != v.Expected.DeletedVaultName { - t.Fatalf("Expected %q but got %q for DeletedVaultName", v.Expected.DeletedVaultName, actual.DeletedVaultName) - } - - } -} - -func TestSegmentsForDeletedVaultId(t *testing.T) { - segments := DeletedVaultId{}.Segments() - if len(segments) == 0 { - t.Fatalf("DeletedVaultId has no segments") - } - - uniqueNames := make(map[string]struct{}, 0) - for _, segment := range segments { - uniqueNames[segment.Name] = struct{}{} - } - if len(uniqueNames) != len(segments) { - t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) - } -} diff --git a/resource-manager/keyvault/2021-10-01/vaults/id_operationkind.go b/resource-manager/keyvault/2021-10-01/vaults/id_operationkind.go deleted file mode 100644 index 25708d5d526..00000000000 --- a/resource-manager/keyvault/2021-10-01/vaults/id_operationkind.go +++ /dev/null @@ -1,142 +0,0 @@ -package vaults - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -var _ resourceids.ResourceId = &OperationKindId{} - -// OperationKindId is a struct representing the Resource ID for a Operation Kind -type OperationKindId struct { - SubscriptionId string - ResourceGroupName string - VaultName string - OperationKind AccessPolicyUpdateKind -} - -// NewOperationKindID returns a new OperationKindId struct -func NewOperationKindID(subscriptionId string, resourceGroupName string, vaultName string, operationKind AccessPolicyUpdateKind) OperationKindId { - return OperationKindId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - VaultName: vaultName, - OperationKind: operationKind, - } -} - -// ParseOperationKindID parses 'input' into a OperationKindId -func ParseOperationKindID(input string) (*OperationKindId, error) { - parser := resourceids.NewParserFromResourceIdType(&OperationKindId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := OperationKindId{} - if err := id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -// ParseOperationKindIDInsensitively parses 'input' case-insensitively into a OperationKindId -// note: this method should only be used for API response data and not user input -func ParseOperationKindIDInsensitively(input string) (*OperationKindId, error) { - parser := resourceids.NewParserFromResourceIdType(&OperationKindId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := OperationKindId{} - if err := id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -func (id *OperationKindId) FromParseResult(input resourceids.ParseResult) error { - var ok bool - - if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) - } - - if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) - } - - if id.VaultName, ok = input.Parsed["vaultName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) - } - - if v, ok := input.Parsed["operationKind"]; true { - if !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "operationKind", input) - } - - operationKind, err := parseAccessPolicyUpdateKind(v) - if err != nil { - return fmt.Errorf("parsing %q: %+v", v, err) - } - id.OperationKind = *operationKind - } - - return nil -} - -// ValidateOperationKindID checks that 'input' can be parsed as a Operation Kind ID -func ValidateOperationKindID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParseOperationKindID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Operation Kind ID -func (id OperationKindId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.KeyVault/vaults/%s/accessPolicies/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, string(id.OperationKind)) -} - -// Segments returns a slice of Resource ID Segments which comprise this Operation Kind ID -func (id OperationKindId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftKeyVault", "Microsoft.KeyVault", "Microsoft.KeyVault"), - resourceids.StaticSegment("staticVaults", "vaults", "vaults"), - resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), - resourceids.StaticSegment("staticAccessPolicies", "accessPolicies", "accessPolicies"), - resourceids.ConstantSegment("operationKind", PossibleValuesForAccessPolicyUpdateKind(), "add"), - } -} - -// String returns a human-readable description of this Operation Kind ID -func (id OperationKindId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Vault Name: %q", id.VaultName), - fmt.Sprintf("Operation Kind: %q", string(id.OperationKind)), - } - return fmt.Sprintf("Operation Kind (%s)", strings.Join(components, "\n")) -} diff --git a/resource-manager/keyvault/2021-10-01/vaults/id_operationkind_test.go b/resource-manager/keyvault/2021-10-01/vaults/id_operationkind_test.go deleted file mode 100644 index 97ed59eb4d4..00000000000 --- a/resource-manager/keyvault/2021-10-01/vaults/id_operationkind_test.go +++ /dev/null @@ -1,327 +0,0 @@ -package vaults - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -var _ resourceids.ResourceId = &OperationKindId{} - -func TestNewOperationKindID(t *testing.T) { - id := NewOperationKindID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "add") - - if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { - t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") - } - - if id.ResourceGroupName != "example-resource-group" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") - } - - if id.VaultName != "vaultValue" { - t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") - } - - if id.OperationKind != "add" { - t.Fatalf("Expected %q but got %q for Segment 'OperationKind'", id.OperationKind, "add") - } -} - -func TestFormatOperationKindID(t *testing.T) { - actual := NewOperationKindID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "add").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/vaults/vaultValue/accessPolicies/add" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseOperationKindID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *OperationKindId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/vaults", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/vaults/vaultValue", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/vaults/vaultValue/accessPolicies", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/vaults/vaultValue/accessPolicies/add", - Expected: &OperationKindId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - VaultName: "vaultValue", - OperationKind: "add", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/vaults/vaultValue/accessPolicies/add/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseOperationKindID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.VaultName != v.Expected.VaultName { - t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) - } - - if actual.OperationKind != v.Expected.OperationKind { - t.Fatalf("Expected %q but got %q for OperationKind", v.Expected.OperationKind, actual.OperationKind) - } - - } -} - -func TestParseOperationKindIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *OperationKindId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/vaults", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/vAuLtS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/vaults/vaultValue", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/vAuLtS/vAuLtVaLuE", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/vaults/vaultValue/accessPolicies", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/vAuLtS/vAuLtVaLuE/aCcEsSpOlIcIeS", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/vaults/vaultValue/accessPolicies/add", - Expected: &OperationKindId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - VaultName: "vaultValue", - OperationKind: "add", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/vaults/vaultValue/accessPolicies/add/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/vAuLtS/vAuLtVaLuE/aCcEsSpOlIcIeS/aDd", - Expected: &OperationKindId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - VaultName: "vAuLtVaLuE", - OperationKind: "add", - }, - }, - { - // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/vAuLtS/vAuLtVaLuE/aCcEsSpOlIcIeS/aDd/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseOperationKindIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.VaultName != v.Expected.VaultName { - t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) - } - - if actual.OperationKind != v.Expected.OperationKind { - t.Fatalf("Expected %q but got %q for OperationKind", v.Expected.OperationKind, actual.OperationKind) - } - - } -} - -func TestSegmentsForOperationKindId(t *testing.T) { - segments := OperationKindId{}.Segments() - if len(segments) == 0 { - t.Fatalf("OperationKindId has no segments") - } - - uniqueNames := make(map[string]struct{}, 0) - for _, segment := range segments { - uniqueNames[segment.Name] = struct{}{} - } - if len(uniqueNames) != len(segments) { - t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) - } -} diff --git a/resource-manager/keyvault/2021-10-01/vaults/method_checknameavailability_autorest.go b/resource-manager/keyvault/2021-10-01/vaults/method_checknameavailability_autorest.go deleted file mode 100644 index b6a428f979b..00000000000 --- a/resource-manager/keyvault/2021-10-01/vaults/method_checknameavailability_autorest.go +++ /dev/null @@ -1,71 +0,0 @@ -package vaults - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CheckNameAvailabilityOperationResponse struct { - HttpResponse *http.Response - Model *CheckNameAvailabilityResult -} - -// CheckNameAvailability ... -func (c VaultsClient) CheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input VaultCheckNameAvailabilityParameters) (result CheckNameAvailabilityOperationResponse, err error) { - req, err := c.preparerForCheckNameAvailability(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "CheckNameAvailability", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "CheckNameAvailability", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCheckNameAvailability(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "CheckNameAvailability", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCheckNameAvailability prepares the CheckNameAvailability request. -func (c VaultsClient) preparerForCheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input VaultCheckNameAvailabilityParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.KeyVault/checkNameAvailability", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCheckNameAvailability handles the response to the CheckNameAvailability request. The method always -// closes the http.Response Body. -func (c VaultsClient) responderForCheckNameAvailability(resp *http.Response) (result CheckNameAvailabilityOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2021-10-01/vaults/method_createorupdate_autorest.go b/resource-manager/keyvault/2021-10-01/vaults/method_createorupdate_autorest.go deleted file mode 100644 index b80f3097c1d..00000000000 --- a/resource-manager/keyvault/2021-10-01/vaults/method_createorupdate_autorest.go +++ /dev/null @@ -1,81 +0,0 @@ -package vaults - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response - Model *Vault -} - -// CreateOrUpdate ... -func (c VaultsClient) CreateOrUpdate(ctx context.Context, id commonids.KeyVaultId, input VaultCreateOrUpdateParameters) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c VaultsClient) CreateOrUpdateThenPoll(ctx context.Context, id commonids.KeyVaultId, input VaultCreateOrUpdateParameters) error { - result, err := c.CreateOrUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c VaultsClient) preparerForCreateOrUpdate(ctx context.Context, id commonids.KeyVaultId, input VaultCreateOrUpdateParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c VaultsClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/keyvault/2021-10-01/vaults/method_delete_autorest.go b/resource-manager/keyvault/2021-10-01/vaults/method_delete_autorest.go deleted file mode 100644 index 5eabac1a3f0..00000000000 --- a/resource-manager/keyvault/2021-10-01/vaults/method_delete_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package vaults - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteOperationResponse struct { - HttpResponse *http.Response -} - -// Delete ... -func (c VaultsClient) Delete(ctx context.Context, id commonids.KeyVaultId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c VaultsClient) preparerForDelete(ctx context.Context, id commonids.KeyVaultId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c VaultsClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2021-10-01/vaults/method_get_autorest.go b/resource-manager/keyvault/2021-10-01/vaults/method_get_autorest.go deleted file mode 100644 index 986510ec6d7..00000000000 --- a/resource-manager/keyvault/2021-10-01/vaults/method_get_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package vaults - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *Vault -} - -// Get ... -func (c VaultsClient) Get(ctx context.Context, id commonids.KeyVaultId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c VaultsClient) preparerForGet(ctx context.Context, id commonids.KeyVaultId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c VaultsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2021-10-01/vaults/method_getdeleted_autorest.go b/resource-manager/keyvault/2021-10-01/vaults/method_getdeleted_autorest.go deleted file mode 100644 index b60a7041ea1..00000000000 --- a/resource-manager/keyvault/2021-10-01/vaults/method_getdeleted_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package vaults - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetDeletedOperationResponse struct { - HttpResponse *http.Response - Model *DeletedVault -} - -// GetDeleted ... -func (c VaultsClient) GetDeleted(ctx context.Context, id DeletedVaultId) (result GetDeletedOperationResponse, err error) { - req, err := c.preparerForGetDeleted(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "GetDeleted", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "GetDeleted", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetDeleted(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "GetDeleted", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetDeleted prepares the GetDeleted request. -func (c VaultsClient) preparerForGetDeleted(ctx context.Context, id DeletedVaultId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetDeleted handles the response to the GetDeleted request. The method always -// closes the http.Response Body. -func (c VaultsClient) responderForGetDeleted(resp *http.Response) (result GetDeletedOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2021-10-01/vaults/method_list_autorest.go b/resource-manager/keyvault/2021-10-01/vaults/method_list_autorest.go deleted file mode 100644 index 58b77e07a16..00000000000 --- a/resource-manager/keyvault/2021-10-01/vaults/method_list_autorest.go +++ /dev/null @@ -1,221 +0,0 @@ -package vaults - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *[]Resource - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []Resource -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListOperationOptions struct { - Filter *VaultListFilterTypes - Top *int64 -} - -func DefaultListOperationOptions() ListOperationOptions { - return ListOperationOptions{} -} - -func (o ListOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// List ... -func (c VaultsClient) List(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c VaultsClient) preparerForList(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/resources", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c VaultsClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c VaultsClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []Resource `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { - req, err := c.preparerForListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c VaultsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, options, ResourceOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c VaultsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions, predicate ResourceOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]Resource, 0) - - page, err := c.List(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/keyvault/2021-10-01/vaults/method_listbyresourcegroup_autorest.go b/resource-manager/keyvault/2021-10-01/vaults/method_listbyresourcegroup_autorest.go deleted file mode 100644 index c7f2a4088e7..00000000000 --- a/resource-manager/keyvault/2021-10-01/vaults/method_listbyresourcegroup_autorest.go +++ /dev/null @@ -1,216 +0,0 @@ -package vaults - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// 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 - Model *[]Vault - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByResourceGroupOperationResponse, error) -} - -type ListByResourceGroupCompleteResult struct { - Items []Vault -} - -func (r ListByResourceGroupOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByResourceGroupOperationResponse) LoadMore(ctx context.Context) (resp ListByResourceGroupOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByResourceGroupOperationOptions struct { - Top *int64 -} - -func DefaultListByResourceGroupOperationOptions() ListByResourceGroupOperationOptions { - return ListByResourceGroupOperationOptions{} -} - -func (o ListByResourceGroupOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByResourceGroupOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByResourceGroup ... -func (c VaultsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (resp ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroup(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListByResourceGroup", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByResourceGroup(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListByResourceGroup", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByResourceGroup prepares the ListByResourceGroup request. -func (c VaultsClient) preparerForListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.KeyVault/vaults", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByResourceGroupWithNextLink prepares the ListByResourceGroup request with the given nextLink token. -func (c VaultsClient) preparerForListByResourceGroupWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByResourceGroup handles the response to the ListByResourceGroup request. The method always -// closes the http.Response Body. -func (c VaultsClient) responderForListByResourceGroup(resp *http.Response) (result ListByResourceGroupOperationResponse, err error) { - type page struct { - Values []Vault `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroupWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListByResourceGroup", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByResourceGroup(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListByResourceGroup", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByResourceGroupComplete retrieves all of the results into a single object -func (c VaultsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (ListByResourceGroupCompleteResult, error) { - return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, options, VaultOperationPredicate{}) -} - -// ListByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c VaultsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions, predicate VaultOperationPredicate) (resp ListByResourceGroupCompleteResult, err error) { - items := make([]Vault, 0) - - page, err := c.ListByResourceGroup(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByResourceGroupCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/keyvault/2021-10-01/vaults/method_listbysubscription_autorest.go b/resource-manager/keyvault/2021-10-01/vaults/method_listbysubscription_autorest.go deleted file mode 100644 index 11e2932b29c..00000000000 --- a/resource-manager/keyvault/2021-10-01/vaults/method_listbysubscription_autorest.go +++ /dev/null @@ -1,216 +0,0 @@ -package vaults - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// 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 - Model *[]Vault - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListBySubscriptionOperationResponse, error) -} - -type ListBySubscriptionCompleteResult struct { - Items []Vault -} - -func (r ListBySubscriptionOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListBySubscriptionOperationResponse) LoadMore(ctx context.Context) (resp ListBySubscriptionOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListBySubscriptionOperationOptions struct { - Top *int64 -} - -func DefaultListBySubscriptionOperationOptions() ListBySubscriptionOperationOptions { - return ListBySubscriptionOperationOptions{} -} - -func (o ListBySubscriptionOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListBySubscriptionOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListBySubscription ... -func (c VaultsClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions) (resp ListBySubscriptionOperationResponse, err error) { - req, err := c.preparerForListBySubscription(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListBySubscription", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListBySubscription", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListBySubscription(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListBySubscription", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListBySubscription prepares the ListBySubscription request. -func (c VaultsClient) preparerForListBySubscription(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.KeyVault/vaults", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListBySubscriptionWithNextLink prepares the ListBySubscription request with the given nextLink token. -func (c VaultsClient) preparerForListBySubscriptionWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListBySubscription handles the response to the ListBySubscription request. The method always -// closes the http.Response Body. -func (c VaultsClient) responderForListBySubscription(resp *http.Response) (result ListBySubscriptionOperationResponse, err error) { - type page struct { - Values []Vault `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListBySubscriptionOperationResponse, err error) { - req, err := c.preparerForListBySubscriptionWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListBySubscription", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListBySubscription", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListBySubscription(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListBySubscription", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListBySubscriptionComplete retrieves all of the results into a single object -func (c VaultsClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions) (ListBySubscriptionCompleteResult, error) { - return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, options, VaultOperationPredicate{}) -} - -// ListBySubscriptionCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c VaultsClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions, predicate VaultOperationPredicate) (resp ListBySubscriptionCompleteResult, err error) { - items := make([]Vault, 0) - - page, err := c.ListBySubscription(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListBySubscriptionCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/keyvault/2021-10-01/vaults/method_listdeleted_autorest.go b/resource-manager/keyvault/2021-10-01/vaults/method_listdeleted_autorest.go deleted file mode 100644 index 7f1b889661b..00000000000 --- a/resource-manager/keyvault/2021-10-01/vaults/method_listdeleted_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package vaults - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListDeletedOperationResponse struct { - HttpResponse *http.Response - Model *[]DeletedVault - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListDeletedOperationResponse, error) -} - -type ListDeletedCompleteResult struct { - Items []DeletedVault -} - -func (r ListDeletedOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListDeletedOperationResponse) LoadMore(ctx context.Context) (resp ListDeletedOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListDeleted ... -func (c VaultsClient) ListDeleted(ctx context.Context, id commonids.SubscriptionId) (resp ListDeletedOperationResponse, err error) { - req, err := c.preparerForListDeleted(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListDeleted", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListDeleted", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListDeleted(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListDeleted", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListDeleted prepares the ListDeleted request. -func (c VaultsClient) preparerForListDeleted(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.KeyVault/deletedVaults", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListDeletedWithNextLink prepares the ListDeleted request with the given nextLink token. -func (c VaultsClient) preparerForListDeletedWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListDeleted handles the response to the ListDeleted request. The method always -// closes the http.Response Body. -func (c VaultsClient) responderForListDeleted(resp *http.Response) (result ListDeletedOperationResponse, err error) { - type page struct { - Values []DeletedVault `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListDeletedOperationResponse, err error) { - req, err := c.preparerForListDeletedWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListDeleted", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListDeleted", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListDeleted(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListDeleted", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListDeletedComplete retrieves all of the results into a single object -func (c VaultsClient) ListDeletedComplete(ctx context.Context, id commonids.SubscriptionId) (ListDeletedCompleteResult, error) { - return c.ListDeletedCompleteMatchingPredicate(ctx, id, DeletedVaultOperationPredicate{}) -} - -// ListDeletedCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c VaultsClient) ListDeletedCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate DeletedVaultOperationPredicate) (resp ListDeletedCompleteResult, err error) { - items := make([]DeletedVault, 0) - - page, err := c.ListDeleted(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListDeletedCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/keyvault/2021-10-01/vaults/method_purgedeleted_autorest.go b/resource-manager/keyvault/2021-10-01/vaults/method_purgedeleted_autorest.go deleted file mode 100644 index 17606022668..00000000000 --- a/resource-manager/keyvault/2021-10-01/vaults/method_purgedeleted_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package vaults - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PurgeDeletedOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// PurgeDeleted ... -func (c VaultsClient) PurgeDeleted(ctx context.Context, id DeletedVaultId) (result PurgeDeletedOperationResponse, err error) { - req, err := c.preparerForPurgeDeleted(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "PurgeDeleted", nil, "Failure preparing request") - return - } - - result, err = c.senderForPurgeDeleted(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "PurgeDeleted", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// PurgeDeletedThenPoll performs PurgeDeleted then polls until it's completed -func (c VaultsClient) PurgeDeletedThenPoll(ctx context.Context, id DeletedVaultId) error { - result, err := c.PurgeDeleted(ctx, id) - if err != nil { - return fmt.Errorf("performing PurgeDeleted: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after PurgeDeleted: %+v", err) - } - - return nil -} - -// preparerForPurgeDeleted prepares the PurgeDeleted request. -func (c VaultsClient) preparerForPurgeDeleted(ctx context.Context, id DeletedVaultId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/purge", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForPurgeDeleted sends the PurgeDeleted request. The method will close the -// http.Response Body if it receives an error. -func (c VaultsClient) senderForPurgeDeleted(ctx context.Context, req *http.Request) (future PurgeDeletedOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/keyvault/2021-10-01/vaults/method_update_autorest.go b/resource-manager/keyvault/2021-10-01/vaults/method_update_autorest.go deleted file mode 100644 index b1145cfe089..00000000000 --- a/resource-manager/keyvault/2021-10-01/vaults/method_update_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package vaults - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateOperationResponse struct { - HttpResponse *http.Response - Model *Vault -} - -// Update ... -func (c VaultsClient) Update(ctx context.Context, id commonids.KeyVaultId, input VaultPatchParameters) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c VaultsClient) preparerForUpdate(ctx context.Context, id commonids.KeyVaultId, input VaultPatchParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdate handles the response to the Update request. The method always -// closes the http.Response Body. -func (c VaultsClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2021-10-01/vaults/method_updateaccesspolicy_autorest.go b/resource-manager/keyvault/2021-10-01/vaults/method_updateaccesspolicy_autorest.go deleted file mode 100644 index f76830d71d8..00000000000 --- a/resource-manager/keyvault/2021-10-01/vaults/method_updateaccesspolicy_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package vaults - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateAccessPolicyOperationResponse struct { - HttpResponse *http.Response - Model *VaultAccessPolicyParameters -} - -// UpdateAccessPolicy ... -func (c VaultsClient) UpdateAccessPolicy(ctx context.Context, id OperationKindId, input VaultAccessPolicyParameters) (result UpdateAccessPolicyOperationResponse, err error) { - req, err := c.preparerForUpdateAccessPolicy(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "UpdateAccessPolicy", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "UpdateAccessPolicy", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateAccessPolicy(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "UpdateAccessPolicy", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateAccessPolicy prepares the UpdateAccessPolicy request. -func (c VaultsClient) preparerForUpdateAccessPolicy(ctx context.Context, id OperationKindId, input VaultAccessPolicyParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateAccessPolicy handles the response to the UpdateAccessPolicy request. The method always -// closes the http.Response Body. -func (c VaultsClient) responderForUpdateAccessPolicy(resp *http.Response) (result UpdateAccessPolicyOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2021-10-01/vaults/model_accesspolicyentry.go b/resource-manager/keyvault/2021-10-01/vaults/model_accesspolicyentry.go deleted file mode 100644 index a183e1481b6..00000000000 --- a/resource-manager/keyvault/2021-10-01/vaults/model_accesspolicyentry.go +++ /dev/null @@ -1,11 +0,0 @@ -package vaults - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type AccessPolicyEntry struct { - ApplicationId *string `json:"applicationId,omitempty"` - ObjectId string `json:"objectId"` - Permissions Permissions `json:"permissions"` - TenantId string `json:"tenantId"` -} diff --git a/resource-manager/keyvault/2021-10-01/vaults/model_checknameavailabilityresult.go b/resource-manager/keyvault/2021-10-01/vaults/model_checknameavailabilityresult.go deleted file mode 100644 index 392070c655a..00000000000 --- a/resource-manager/keyvault/2021-10-01/vaults/model_checknameavailabilityresult.go +++ /dev/null @@ -1,10 +0,0 @@ -package vaults - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CheckNameAvailabilityResult struct { - Message *string `json:"message,omitempty"` - NameAvailable *bool `json:"nameAvailable,omitempty"` - Reason *Reason `json:"reason,omitempty"` -} diff --git a/resource-manager/keyvault/2021-10-01/vaults/model_deletedvault.go b/resource-manager/keyvault/2021-10-01/vaults/model_deletedvault.go deleted file mode 100644 index 0516f7fabdc..00000000000 --- a/resource-manager/keyvault/2021-10-01/vaults/model_deletedvault.go +++ /dev/null @@ -1,11 +0,0 @@ -package vaults - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeletedVault struct { - Id *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Properties *DeletedVaultProperties `json:"properties,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/resource-manager/keyvault/2021-10-01/vaults/model_deletedvaultproperties.go b/resource-manager/keyvault/2021-10-01/vaults/model_deletedvaultproperties.go deleted file mode 100644 index e8857532e44..00000000000 --- a/resource-manager/keyvault/2021-10-01/vaults/model_deletedvaultproperties.go +++ /dev/null @@ -1,43 +0,0 @@ -package vaults - -import ( - "time" - - "github.com/hashicorp/go-azure-helpers/lang/dates" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeletedVaultProperties struct { - DeletionDate *string `json:"deletionDate,omitempty"` - Location *string `json:"location,omitempty"` - PurgeProtectionEnabled *bool `json:"purgeProtectionEnabled,omitempty"` - ScheduledPurgeDate *string `json:"scheduledPurgeDate,omitempty"` - Tags *map[string]string `json:"tags,omitempty"` - VaultId *string `json:"vaultId,omitempty"` -} - -func (o *DeletedVaultProperties) GetDeletionDateAsTime() (*time.Time, error) { - if o.DeletionDate == nil { - return nil, nil - } - return dates.ParseAsFormat(o.DeletionDate, "2006-01-02T15:04:05Z07:00") -} - -func (o *DeletedVaultProperties) SetDeletionDateAsTime(input time.Time) { - formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.DeletionDate = &formatted -} - -func (o *DeletedVaultProperties) GetScheduledPurgeDateAsTime() (*time.Time, error) { - if o.ScheduledPurgeDate == nil { - return nil, nil - } - return dates.ParseAsFormat(o.ScheduledPurgeDate, "2006-01-02T15:04:05Z07:00") -} - -func (o *DeletedVaultProperties) SetScheduledPurgeDateAsTime(input time.Time) { - formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.ScheduledPurgeDate = &formatted -} diff --git a/resource-manager/keyvault/2021-10-01/vaults/model_iprule.go b/resource-manager/keyvault/2021-10-01/vaults/model_iprule.go deleted file mode 100644 index 1ef577d7d01..00000000000 --- a/resource-manager/keyvault/2021-10-01/vaults/model_iprule.go +++ /dev/null @@ -1,8 +0,0 @@ -package vaults - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type IPRule struct { - Value string `json:"value"` -} diff --git a/resource-manager/keyvault/2021-10-01/vaults/model_networkruleset.go b/resource-manager/keyvault/2021-10-01/vaults/model_networkruleset.go deleted file mode 100644 index 044635c0f77..00000000000 --- a/resource-manager/keyvault/2021-10-01/vaults/model_networkruleset.go +++ /dev/null @@ -1,11 +0,0 @@ -package vaults - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type NetworkRuleSet struct { - Bypass *NetworkRuleBypassOptions `json:"bypass,omitempty"` - DefaultAction *NetworkRuleAction `json:"defaultAction,omitempty"` - IPRules *[]IPRule `json:"ipRules,omitempty"` - VirtualNetworkRules *[]VirtualNetworkRule `json:"virtualNetworkRules,omitempty"` -} diff --git a/resource-manager/keyvault/2021-10-01/vaults/model_permissions.go b/resource-manager/keyvault/2021-10-01/vaults/model_permissions.go deleted file mode 100644 index b5f9cca4bd6..00000000000 --- a/resource-manager/keyvault/2021-10-01/vaults/model_permissions.go +++ /dev/null @@ -1,11 +0,0 @@ -package vaults - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type Permissions struct { - Certificates *[]CertificatePermissions `json:"certificates,omitempty"` - Keys *[]KeyPermissions `json:"keys,omitempty"` - Secrets *[]SecretPermissions `json:"secrets,omitempty"` - Storage *[]StoragePermissions `json:"storage,omitempty"` -} diff --git a/resource-manager/keyvault/2021-10-01/vaults/model_privateendpoint.go b/resource-manager/keyvault/2021-10-01/vaults/model_privateendpoint.go deleted file mode 100644 index 64ce35a3d98..00000000000 --- a/resource-manager/keyvault/2021-10-01/vaults/model_privateendpoint.go +++ /dev/null @@ -1,8 +0,0 @@ -package vaults - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PrivateEndpoint struct { - Id *string `json:"id,omitempty"` -} diff --git a/resource-manager/keyvault/2021-10-01/vaults/model_privateendpointconnectionitem.go b/resource-manager/keyvault/2021-10-01/vaults/model_privateendpointconnectionitem.go deleted file mode 100644 index a0f6df8359d..00000000000 --- a/resource-manager/keyvault/2021-10-01/vaults/model_privateendpointconnectionitem.go +++ /dev/null @@ -1,10 +0,0 @@ -package vaults - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PrivateEndpointConnectionItem struct { - Etag *string `json:"etag,omitempty"` - Id *string `json:"id,omitempty"` - Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` -} diff --git a/resource-manager/keyvault/2021-10-01/vaults/model_privateendpointconnectionproperties.go b/resource-manager/keyvault/2021-10-01/vaults/model_privateendpointconnectionproperties.go deleted file mode 100644 index 7dd15bb6220..00000000000 --- a/resource-manager/keyvault/2021-10-01/vaults/model_privateendpointconnectionproperties.go +++ /dev/null @@ -1,10 +0,0 @@ -package vaults - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PrivateEndpointConnectionProperties struct { - PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` - PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` - ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` -} diff --git a/resource-manager/keyvault/2021-10-01/vaults/model_privatelinkserviceconnectionstate.go b/resource-manager/keyvault/2021-10-01/vaults/model_privatelinkserviceconnectionstate.go deleted file mode 100644 index ced73fba28c..00000000000 --- a/resource-manager/keyvault/2021-10-01/vaults/model_privatelinkserviceconnectionstate.go +++ /dev/null @@ -1,10 +0,0 @@ -package vaults - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PrivateLinkServiceConnectionState struct { - ActionsRequired *ActionsRequired `json:"actionsRequired,omitempty"` - Description *string `json:"description,omitempty"` - Status *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` -} diff --git a/resource-manager/keyvault/2021-10-01/vaults/model_resource.go b/resource-manager/keyvault/2021-10-01/vaults/model_resource.go deleted file mode 100644 index 2c29e958d53..00000000000 --- a/resource-manager/keyvault/2021-10-01/vaults/model_resource.go +++ /dev/null @@ -1,12 +0,0 @@ -package vaults - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type Resource struct { - Id *string `json:"id,omitempty"` - Location *string `json:"location,omitempty"` - Name *string `json:"name,omitempty"` - Tags *map[string]string `json:"tags,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/resource-manager/keyvault/2021-10-01/vaults/model_sku.go b/resource-manager/keyvault/2021-10-01/vaults/model_sku.go deleted file mode 100644 index 259dd1fce3a..00000000000 --- a/resource-manager/keyvault/2021-10-01/vaults/model_sku.go +++ /dev/null @@ -1,9 +0,0 @@ -package vaults - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type Sku struct { - Family SkuFamily `json:"family"` - Name SkuName `json:"name"` -} diff --git a/resource-manager/keyvault/2021-10-01/vaults/model_vault.go b/resource-manager/keyvault/2021-10-01/vaults/model_vault.go deleted file mode 100644 index cfb5acec999..00000000000 --- a/resource-manager/keyvault/2021-10-01/vaults/model_vault.go +++ /dev/null @@ -1,18 +0,0 @@ -package vaults - -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 Vault struct { - Id *string `json:"id,omitempty"` - Location *string `json:"location,omitempty"` - Name *string `json:"name,omitempty"` - Properties VaultProperties `json:"properties"` - SystemData *systemdata.SystemData `json:"systemData,omitempty"` - Tags *map[string]string `json:"tags,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/resource-manager/keyvault/2021-10-01/vaults/model_vaultaccesspolicyparameters.go b/resource-manager/keyvault/2021-10-01/vaults/model_vaultaccesspolicyparameters.go deleted file mode 100644 index 7353ce39d54..00000000000 --- a/resource-manager/keyvault/2021-10-01/vaults/model_vaultaccesspolicyparameters.go +++ /dev/null @@ -1,12 +0,0 @@ -package vaults - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type VaultAccessPolicyParameters struct { - Id *string `json:"id,omitempty"` - Location *string `json:"location,omitempty"` - Name *string `json:"name,omitempty"` - Properties VaultAccessPolicyProperties `json:"properties"` - Type *string `json:"type,omitempty"` -} diff --git a/resource-manager/keyvault/2021-10-01/vaults/model_vaultaccesspolicyproperties.go b/resource-manager/keyvault/2021-10-01/vaults/model_vaultaccesspolicyproperties.go deleted file mode 100644 index 78525492fd7..00000000000 --- a/resource-manager/keyvault/2021-10-01/vaults/model_vaultaccesspolicyproperties.go +++ /dev/null @@ -1,8 +0,0 @@ -package vaults - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type VaultAccessPolicyProperties struct { - AccessPolicies []AccessPolicyEntry `json:"accessPolicies"` -} diff --git a/resource-manager/keyvault/2021-10-01/vaults/model_vaultchecknameavailabilityparameters.go b/resource-manager/keyvault/2021-10-01/vaults/model_vaultchecknameavailabilityparameters.go deleted file mode 100644 index b9f9c94d368..00000000000 --- a/resource-manager/keyvault/2021-10-01/vaults/model_vaultchecknameavailabilityparameters.go +++ /dev/null @@ -1,9 +0,0 @@ -package vaults - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type VaultCheckNameAvailabilityParameters struct { - Name string `json:"name"` - Type Type `json:"type"` -} diff --git a/resource-manager/keyvault/2021-10-01/vaults/model_vaultcreateorupdateparameters.go b/resource-manager/keyvault/2021-10-01/vaults/model_vaultcreateorupdateparameters.go deleted file mode 100644 index 6e8ca68bd73..00000000000 --- a/resource-manager/keyvault/2021-10-01/vaults/model_vaultcreateorupdateparameters.go +++ /dev/null @@ -1,10 +0,0 @@ -package vaults - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type VaultCreateOrUpdateParameters struct { - Location string `json:"location"` - Properties VaultProperties `json:"properties"` - Tags *map[string]string `json:"tags,omitempty"` -} diff --git a/resource-manager/keyvault/2021-10-01/vaults/model_vaultpatchparameters.go b/resource-manager/keyvault/2021-10-01/vaults/model_vaultpatchparameters.go deleted file mode 100644 index 9352a604c87..00000000000 --- a/resource-manager/keyvault/2021-10-01/vaults/model_vaultpatchparameters.go +++ /dev/null @@ -1,9 +0,0 @@ -package vaults - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type VaultPatchParameters struct { - Properties *VaultPatchProperties `json:"properties,omitempty"` - Tags *map[string]string `json:"tags,omitempty"` -} diff --git a/resource-manager/keyvault/2021-10-01/vaults/model_vaultpatchproperties.go b/resource-manager/keyvault/2021-10-01/vaults/model_vaultpatchproperties.go deleted file mode 100644 index 9a4f85f22a4..00000000000 --- a/resource-manager/keyvault/2021-10-01/vaults/model_vaultpatchproperties.go +++ /dev/null @@ -1,20 +0,0 @@ -package vaults - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type VaultPatchProperties struct { - AccessPolicies *[]AccessPolicyEntry `json:"accessPolicies,omitempty"` - CreateMode *CreateMode `json:"createMode,omitempty"` - EnablePurgeProtection *bool `json:"enablePurgeProtection,omitempty"` - EnableRbacAuthorization *bool `json:"enableRbacAuthorization,omitempty"` - EnableSoftDelete *bool `json:"enableSoftDelete,omitempty"` - EnabledForDeployment *bool `json:"enabledForDeployment,omitempty"` - EnabledForDiskEncryption *bool `json:"enabledForDiskEncryption,omitempty"` - EnabledForTemplateDeployment *bool `json:"enabledForTemplateDeployment,omitempty"` - NetworkAcls *NetworkRuleSet `json:"networkAcls,omitempty"` - PublicNetworkAccess *string `json:"publicNetworkAccess,omitempty"` - Sku *Sku `json:"sku,omitempty"` - SoftDeleteRetentionInDays *int64 `json:"softDeleteRetentionInDays,omitempty"` - TenantId *string `json:"tenantId,omitempty"` -} diff --git a/resource-manager/keyvault/2021-10-01/vaults/model_vaultproperties.go b/resource-manager/keyvault/2021-10-01/vaults/model_vaultproperties.go deleted file mode 100644 index a5e381c4dd9..00000000000 --- a/resource-manager/keyvault/2021-10-01/vaults/model_vaultproperties.go +++ /dev/null @@ -1,24 +0,0 @@ -package vaults - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type VaultProperties struct { - AccessPolicies *[]AccessPolicyEntry `json:"accessPolicies,omitempty"` - CreateMode *CreateMode `json:"createMode,omitempty"` - EnablePurgeProtection *bool `json:"enablePurgeProtection,omitempty"` - EnableRbacAuthorization *bool `json:"enableRbacAuthorization,omitempty"` - EnableSoftDelete *bool `json:"enableSoftDelete,omitempty"` - EnabledForDeployment *bool `json:"enabledForDeployment,omitempty"` - EnabledForDiskEncryption *bool `json:"enabledForDiskEncryption,omitempty"` - EnabledForTemplateDeployment *bool `json:"enabledForTemplateDeployment,omitempty"` - HsmPoolResourceId *string `json:"hsmPoolResourceId,omitempty"` - NetworkAcls *NetworkRuleSet `json:"networkAcls,omitempty"` - PrivateEndpointConnections *[]PrivateEndpointConnectionItem `json:"privateEndpointConnections,omitempty"` - ProvisioningState *VaultProvisioningState `json:"provisioningState,omitempty"` - PublicNetworkAccess *string `json:"publicNetworkAccess,omitempty"` - Sku Sku `json:"sku"` - SoftDeleteRetentionInDays *int64 `json:"softDeleteRetentionInDays,omitempty"` - TenantId string `json:"tenantId"` - VaultUri *string `json:"vaultUri,omitempty"` -} diff --git a/resource-manager/keyvault/2021-10-01/vaults/model_virtualnetworkrule.go b/resource-manager/keyvault/2021-10-01/vaults/model_virtualnetworkrule.go deleted file mode 100644 index cd5b11b8aa7..00000000000 --- a/resource-manager/keyvault/2021-10-01/vaults/model_virtualnetworkrule.go +++ /dev/null @@ -1,9 +0,0 @@ -package vaults - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type VirtualNetworkRule struct { - Id string `json:"id"` - IgnoreMissingVnetServiceEndpoint *bool `json:"ignoreMissingVnetServiceEndpoint,omitempty"` -} diff --git a/resource-manager/keyvault/2021-10-01/vaults/predicates.go b/resource-manager/keyvault/2021-10-01/vaults/predicates.go deleted file mode 100644 index ded74b94926..00000000000 --- a/resource-manager/keyvault/2021-10-01/vaults/predicates.go +++ /dev/null @@ -1,83 +0,0 @@ -package vaults - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeletedVaultOperationPredicate struct { - Id *string - Name *string - Type *string -} - -func (p DeletedVaultOperationPredicate) Matches(input DeletedVault) bool { - - if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { - return false - } - - if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { - return false - } - - if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { - return false - } - - return true -} - -type ResourceOperationPredicate struct { - Id *string - Location *string - Name *string - Type *string -} - -func (p ResourceOperationPredicate) Matches(input Resource) bool { - - if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { - return false - } - - if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { - return false - } - - if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { - return false - } - - if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { - return false - } - - return true -} - -type VaultOperationPredicate struct { - Id *string - Location *string - Name *string - Type *string -} - -func (p VaultOperationPredicate) Matches(input Vault) 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/keyvault/2021-10-01/vaults/version.go b/resource-manager/keyvault/2021-10-01/vaults/version.go deleted file mode 100644 index bc58b328de9..00000000000 --- a/resource-manager/keyvault/2021-10-01/vaults/version.go +++ /dev/null @@ -1,12 +0,0 @@ -package vaults - -import "fmt" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -const defaultApiVersion = "2021-10-01" - -func userAgent() string { - return fmt.Sprintf("hashicorp/go-azure-sdk/vaults/%s", defaultApiVersion) -} diff --git a/resource-manager/keyvault/2022-11-01/client.go b/resource-manager/keyvault/2022-11-01/client.go deleted file mode 100644 index f876e2c8952..00000000000 --- a/resource-manager/keyvault/2022-11-01/client.go +++ /dev/null @@ -1,77 +0,0 @@ -package v2022_11_01 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -import ( - "github.com/Azure/go-autorest/autorest" - "github.com/hashicorp/go-azure-sdk/resource-manager/keyvault/2022-11-01/keys" - "github.com/hashicorp/go-azure-sdk/resource-manager/keyvault/2022-11-01/managedhsmkeys" - "github.com/hashicorp/go-azure-sdk/resource-manager/keyvault/2022-11-01/managedhsms" - "github.com/hashicorp/go-azure-sdk/resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections" - "github.com/hashicorp/go-azure-sdk/resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections" - "github.com/hashicorp/go-azure-sdk/resource-manager/keyvault/2022-11-01/mhsmprivatelinkresources" - "github.com/hashicorp/go-azure-sdk/resource-manager/keyvault/2022-11-01/privateendpointconnections" - "github.com/hashicorp/go-azure-sdk/resource-manager/keyvault/2022-11-01/privatelinkresources" - "github.com/hashicorp/go-azure-sdk/resource-manager/keyvault/2022-11-01/secrets" - "github.com/hashicorp/go-azure-sdk/resource-manager/keyvault/2022-11-01/vaults" -) - -type Client struct { - Keys *keys.KeysClient - MHSMListPrivateEndpointConnections *mhsmlistprivateendpointconnections.MHSMListPrivateEndpointConnectionsClient - MHSMPrivateEndpointConnections *mhsmprivateendpointconnections.MHSMPrivateEndpointConnectionsClient - MHSMPrivateLinkResources *mhsmprivatelinkresources.MHSMPrivateLinkResourcesClient - ManagedHsmKeys *managedhsmkeys.ManagedHsmKeysClient - ManagedHsms *managedhsms.ManagedHsmsClient - PrivateEndpointConnections *privateendpointconnections.PrivateEndpointConnectionsClient - PrivateLinkResources *privatelinkresources.PrivateLinkResourcesClient - Secrets *secrets.SecretsClient - Vaults *vaults.VaultsClient -} - -func NewClientWithBaseURI(endpoint string, configureAuthFunc func(c *autorest.Client)) Client { - - keysClient := keys.NewKeysClientWithBaseURI(endpoint) - configureAuthFunc(&keysClient.Client) - - mHSMListPrivateEndpointConnectionsClient := mhsmlistprivateendpointconnections.NewMHSMListPrivateEndpointConnectionsClientWithBaseURI(endpoint) - configureAuthFunc(&mHSMListPrivateEndpointConnectionsClient.Client) - - mHSMPrivateEndpointConnectionsClient := mhsmprivateendpointconnections.NewMHSMPrivateEndpointConnectionsClientWithBaseURI(endpoint) - configureAuthFunc(&mHSMPrivateEndpointConnectionsClient.Client) - - mHSMPrivateLinkResourcesClient := mhsmprivatelinkresources.NewMHSMPrivateLinkResourcesClientWithBaseURI(endpoint) - configureAuthFunc(&mHSMPrivateLinkResourcesClient.Client) - - managedHsmKeysClient := managedhsmkeys.NewManagedHsmKeysClientWithBaseURI(endpoint) - configureAuthFunc(&managedHsmKeysClient.Client) - - managedHsmsClient := managedhsms.NewManagedHsmsClientWithBaseURI(endpoint) - configureAuthFunc(&managedHsmsClient.Client) - - privateEndpointConnectionsClient := privateendpointconnections.NewPrivateEndpointConnectionsClientWithBaseURI(endpoint) - configureAuthFunc(&privateEndpointConnectionsClient.Client) - - privateLinkResourcesClient := privatelinkresources.NewPrivateLinkResourcesClientWithBaseURI(endpoint) - configureAuthFunc(&privateLinkResourcesClient.Client) - - secretsClient := secrets.NewSecretsClientWithBaseURI(endpoint) - configureAuthFunc(&secretsClient.Client) - - vaultsClient := vaults.NewVaultsClientWithBaseURI(endpoint) - configureAuthFunc(&vaultsClient.Client) - - return Client{ - Keys: &keysClient, - MHSMListPrivateEndpointConnections: &mHSMListPrivateEndpointConnectionsClient, - MHSMPrivateEndpointConnections: &mHSMPrivateEndpointConnectionsClient, - MHSMPrivateLinkResources: &mHSMPrivateLinkResourcesClient, - ManagedHsmKeys: &managedHsmKeysClient, - ManagedHsms: &managedHsmsClient, - PrivateEndpointConnections: &privateEndpointConnectionsClient, - PrivateLinkResources: &privateLinkResourcesClient, - Secrets: &secretsClient, - Vaults: &vaultsClient, - } -} diff --git a/resource-manager/keyvault/2022-11-01/keys/README.md b/resource-manager/keyvault/2022-11-01/keys/README.md deleted file mode 100644 index 96f8185b3ad..00000000000 --- a/resource-manager/keyvault/2022-11-01/keys/README.md +++ /dev/null @@ -1,107 +0,0 @@ - -## `github.com/hashicorp/go-azure-sdk/resource-manager/keyvault/2022-11-01/keys` Documentation - -The `keys` SDK allows for interaction with the Azure Resource Manager Service `keyvault` (API Version `2022-11-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/keyvault/2022-11-01/keys" -``` - - -### Client Initialization - -```go -client := keys.NewKeysClientWithBaseURI("https://management.azure.com") -client.Client.Authorizer = authorizer -``` - - -### Example Usage: `KeysClient.CreateIfNotExist` - -```go -ctx := context.TODO() -id := keys.NewKeyVaultKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "keyValue") - -payload := keys.KeyCreateParameters{ - // ... -} - - -read, err := client.CreateIfNotExist(ctx, id, payload) -if err != nil { - // handle the error -} -if model := read.Model; model != nil { - // do something with the model/response object -} -``` - - -### Example Usage: `KeysClient.Get` - -```go -ctx := context.TODO() -id := keys.NewKeyVaultKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "keyValue") - -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: `KeysClient.GetVersion` - -```go -ctx := context.TODO() -id := keys.NewKeyVaultKeyVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "keyValue", "versionValue") - -read, err := client.GetVersion(ctx, id) -if err != nil { - // handle the error -} -if model := read.Model; model != nil { - // do something with the model/response object -} -``` - - -### Example Usage: `KeysClient.List` - -```go -ctx := context.TODO() -id := keys.NewKeyVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") - -// 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: `KeysClient.ListVersions` - -```go -ctx := context.TODO() -id := keys.NewKeyVaultKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "keyValue") - -// alternatively `client.ListVersions(ctx, id)` can be used to do batched pagination -items, err := client.ListVersionsComplete(ctx, id) -if err != nil { - // handle the error -} -for _, item := range items { - // do something -} -``` diff --git a/resource-manager/keyvault/2022-11-01/keys/client.go b/resource-manager/keyvault/2022-11-01/keys/client.go deleted file mode 100644 index bc451013a0b..00000000000 --- a/resource-manager/keyvault/2022-11-01/keys/client.go +++ /dev/null @@ -1,18 +0,0 @@ -package keys - -import "github.com/Azure/go-autorest/autorest" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type KeysClient struct { - Client autorest.Client - baseUri string -} - -func NewKeysClientWithBaseURI(endpoint string) KeysClient { - return KeysClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/resource-manager/keyvault/2022-11-01/keys/constants.go b/resource-manager/keyvault/2022-11-01/keys/constants.go deleted file mode 100644 index b72b139f6e8..00000000000 --- a/resource-manager/keyvault/2022-11-01/keys/constants.go +++ /dev/null @@ -1,182 +0,0 @@ -package keys - -import "strings" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeletionRecoveryLevel string - -const ( - DeletionRecoveryLevelPurgeable DeletionRecoveryLevel = "Purgeable" - DeletionRecoveryLevelRecoverable DeletionRecoveryLevel = "Recoverable" - DeletionRecoveryLevelRecoverablePositiveProtectedSubscription DeletionRecoveryLevel = "Recoverable+ProtectedSubscription" - DeletionRecoveryLevelRecoverablePositivePurgeable DeletionRecoveryLevel = "Recoverable+Purgeable" -) - -func PossibleValuesForDeletionRecoveryLevel() []string { - return []string{ - string(DeletionRecoveryLevelPurgeable), - string(DeletionRecoveryLevelRecoverable), - string(DeletionRecoveryLevelRecoverablePositiveProtectedSubscription), - string(DeletionRecoveryLevelRecoverablePositivePurgeable), - } -} - -func parseDeletionRecoveryLevel(input string) (*DeletionRecoveryLevel, error) { - vals := map[string]DeletionRecoveryLevel{ - "purgeable": DeletionRecoveryLevelPurgeable, - "recoverable": DeletionRecoveryLevelRecoverable, - "recoverable+protectedsubscription": DeletionRecoveryLevelRecoverablePositiveProtectedSubscription, - "recoverable+purgeable": DeletionRecoveryLevelRecoverablePositivePurgeable, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := DeletionRecoveryLevel(input) - return &out, nil -} - -type JsonWebKeyCurveName string - -const ( - JsonWebKeyCurveNamePNegativeFiveTwoOne JsonWebKeyCurveName = "P-521" - JsonWebKeyCurveNamePNegativeThreeEightFour JsonWebKeyCurveName = "P-384" - JsonWebKeyCurveNamePNegativeTwoFiveSix JsonWebKeyCurveName = "P-256" - JsonWebKeyCurveNamePNegativeTwoFiveSixK JsonWebKeyCurveName = "P-256K" -) - -func PossibleValuesForJsonWebKeyCurveName() []string { - return []string{ - string(JsonWebKeyCurveNamePNegativeFiveTwoOne), - string(JsonWebKeyCurveNamePNegativeThreeEightFour), - string(JsonWebKeyCurveNamePNegativeTwoFiveSix), - string(JsonWebKeyCurveNamePNegativeTwoFiveSixK), - } -} - -func parseJsonWebKeyCurveName(input string) (*JsonWebKeyCurveName, error) { - vals := map[string]JsonWebKeyCurveName{ - "p-521": JsonWebKeyCurveNamePNegativeFiveTwoOne, - "p-384": JsonWebKeyCurveNamePNegativeThreeEightFour, - "p-256": JsonWebKeyCurveNamePNegativeTwoFiveSix, - "p-256k": JsonWebKeyCurveNamePNegativeTwoFiveSixK, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := JsonWebKeyCurveName(input) - return &out, nil -} - -type JsonWebKeyOperation string - -const ( - JsonWebKeyOperationDecrypt JsonWebKeyOperation = "decrypt" - JsonWebKeyOperationEncrypt JsonWebKeyOperation = "encrypt" - JsonWebKeyOperationImport JsonWebKeyOperation = "import" - JsonWebKeyOperationRelease JsonWebKeyOperation = "release" - JsonWebKeyOperationSign JsonWebKeyOperation = "sign" - JsonWebKeyOperationUnwrapKey JsonWebKeyOperation = "unwrapKey" - JsonWebKeyOperationVerify JsonWebKeyOperation = "verify" - JsonWebKeyOperationWrapKey JsonWebKeyOperation = "wrapKey" -) - -func PossibleValuesForJsonWebKeyOperation() []string { - return []string{ - string(JsonWebKeyOperationDecrypt), - string(JsonWebKeyOperationEncrypt), - string(JsonWebKeyOperationImport), - string(JsonWebKeyOperationRelease), - string(JsonWebKeyOperationSign), - string(JsonWebKeyOperationUnwrapKey), - string(JsonWebKeyOperationVerify), - string(JsonWebKeyOperationWrapKey), - } -} - -func parseJsonWebKeyOperation(input string) (*JsonWebKeyOperation, error) { - vals := map[string]JsonWebKeyOperation{ - "decrypt": JsonWebKeyOperationDecrypt, - "encrypt": JsonWebKeyOperationEncrypt, - "import": JsonWebKeyOperationImport, - "release": JsonWebKeyOperationRelease, - "sign": JsonWebKeyOperationSign, - "unwrapkey": JsonWebKeyOperationUnwrapKey, - "verify": JsonWebKeyOperationVerify, - "wrapkey": JsonWebKeyOperationWrapKey, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := JsonWebKeyOperation(input) - return &out, nil -} - -type JsonWebKeyType string - -const ( - JsonWebKeyTypeEC JsonWebKeyType = "EC" - JsonWebKeyTypeECNegativeHSM JsonWebKeyType = "EC-HSM" - JsonWebKeyTypeRSA JsonWebKeyType = "RSA" - JsonWebKeyTypeRSANegativeHSM JsonWebKeyType = "RSA-HSM" -) - -func PossibleValuesForJsonWebKeyType() []string { - return []string{ - string(JsonWebKeyTypeEC), - string(JsonWebKeyTypeECNegativeHSM), - string(JsonWebKeyTypeRSA), - string(JsonWebKeyTypeRSANegativeHSM), - } -} - -func parseJsonWebKeyType(input string) (*JsonWebKeyType, error) { - vals := map[string]JsonWebKeyType{ - "ec": JsonWebKeyTypeEC, - "ec-hsm": JsonWebKeyTypeECNegativeHSM, - "rsa": JsonWebKeyTypeRSA, - "rsa-hsm": JsonWebKeyTypeRSANegativeHSM, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := JsonWebKeyType(input) - return &out, nil -} - -type KeyRotationPolicyActionType string - -const ( - KeyRotationPolicyActionTypeNotify KeyRotationPolicyActionType = "Notify" - KeyRotationPolicyActionTypeRotate KeyRotationPolicyActionType = "Rotate" -) - -func PossibleValuesForKeyRotationPolicyActionType() []string { - return []string{ - string(KeyRotationPolicyActionTypeNotify), - string(KeyRotationPolicyActionTypeRotate), - } -} - -func parseKeyRotationPolicyActionType(input string) (*KeyRotationPolicyActionType, error) { - vals := map[string]KeyRotationPolicyActionType{ - "notify": KeyRotationPolicyActionTypeNotify, - "rotate": KeyRotationPolicyActionTypeRotate, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := KeyRotationPolicyActionType(input) - return &out, nil -} diff --git a/resource-manager/keyvault/2022-11-01/keys/method_createifnotexist_autorest.go b/resource-manager/keyvault/2022-11-01/keys/method_createifnotexist_autorest.go deleted file mode 100644 index 638f6c1d6b1..00000000000 --- a/resource-manager/keyvault/2022-11-01/keys/method_createifnotexist_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package keys - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateIfNotExistOperationResponse struct { - HttpResponse *http.Response - Model *Key -} - -// CreateIfNotExist ... -func (c KeysClient) CreateIfNotExist(ctx context.Context, id commonids.KeyVaultKeyId, input KeyCreateParameters) (result CreateIfNotExistOperationResponse, err error) { - req, err := c.preparerForCreateIfNotExist(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "CreateIfNotExist", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "CreateIfNotExist", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateIfNotExist(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "CreateIfNotExist", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateIfNotExist prepares the CreateIfNotExist request. -func (c KeysClient) preparerForCreateIfNotExist(ctx context.Context, id commonids.KeyVaultKeyId, input KeyCreateParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateIfNotExist handles the response to the CreateIfNotExist request. The method always -// closes the http.Response Body. -func (c KeysClient) responderForCreateIfNotExist(resp *http.Response) (result CreateIfNotExistOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2022-11-01/keys/method_get_autorest.go b/resource-manager/keyvault/2022-11-01/keys/method_get_autorest.go deleted file mode 100644 index 5d081998ae6..00000000000 --- a/resource-manager/keyvault/2022-11-01/keys/method_get_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package keys - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *Key -} - -// Get ... -func (c KeysClient) Get(ctx context.Context, id commonids.KeyVaultKeyId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c KeysClient) preparerForGet(ctx context.Context, id commonids.KeyVaultKeyId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c KeysClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2022-11-01/keys/method_getversion_autorest.go b/resource-manager/keyvault/2022-11-01/keys/method_getversion_autorest.go deleted file mode 100644 index 97ea758183b..00000000000 --- a/resource-manager/keyvault/2022-11-01/keys/method_getversion_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package keys - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetVersionOperationResponse struct { - HttpResponse *http.Response - Model *Key -} - -// GetVersion ... -func (c KeysClient) GetVersion(ctx context.Context, id commonids.KeyVaultKeyVersionId) (result GetVersionOperationResponse, err error) { - req, err := c.preparerForGetVersion(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "GetVersion", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "GetVersion", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetVersion(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "GetVersion", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetVersion prepares the GetVersion request. -func (c KeysClient) preparerForGetVersion(ctx context.Context, id commonids.KeyVaultKeyVersionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetVersion handles the response to the GetVersion request. The method always -// closes the http.Response Body. -func (c KeysClient) responderForGetVersion(resp *http.Response) (result GetVersionOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2022-11-01/keys/method_list_autorest.go b/resource-manager/keyvault/2022-11-01/keys/method_list_autorest.go deleted file mode 100644 index c0ac89d60ff..00000000000 --- a/resource-manager/keyvault/2022-11-01/keys/method_list_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package keys - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *[]Key - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []Key -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// List ... -func (c KeysClient) List(ctx context.Context, id commonids.KeyVaultId) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c KeysClient) preparerForList(ctx context.Context, id commonids.KeyVaultId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/keys", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c KeysClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c KeysClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []Key `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { - req, err := c.preparerForListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c KeysClient) ListComplete(ctx context.Context, id commonids.KeyVaultId) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, KeyOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c KeysClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.KeyVaultId, predicate KeyOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]Key, 0) - - page, err := c.List(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/keyvault/2022-11-01/keys/method_listversions_autorest.go b/resource-manager/keyvault/2022-11-01/keys/method_listversions_autorest.go deleted file mode 100644 index f88803ad5ef..00000000000 --- a/resource-manager/keyvault/2022-11-01/keys/method_listversions_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package keys - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListVersionsOperationResponse struct { - HttpResponse *http.Response - Model *[]Key - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListVersionsOperationResponse, error) -} - -type ListVersionsCompleteResult struct { - Items []Key -} - -func (r ListVersionsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListVersionsOperationResponse) LoadMore(ctx context.Context) (resp ListVersionsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListVersions ... -func (c KeysClient) ListVersions(ctx context.Context, id commonids.KeyVaultKeyId) (resp ListVersionsOperationResponse, err error) { - req, err := c.preparerForListVersions(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "ListVersions", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "ListVersions", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListVersions(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "ListVersions", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListVersions prepares the ListVersions request. -func (c KeysClient) preparerForListVersions(ctx context.Context, id commonids.KeyVaultKeyId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/versions", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListVersionsWithNextLink prepares the ListVersions request with the given nextLink token. -func (c KeysClient) preparerForListVersionsWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListVersions handles the response to the ListVersions request. The method always -// closes the http.Response Body. -func (c KeysClient) responderForListVersions(resp *http.Response) (result ListVersionsOperationResponse, err error) { - type page struct { - Values []Key `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListVersionsOperationResponse, err error) { - req, err := c.preparerForListVersionsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "ListVersions", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "ListVersions", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListVersions(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "ListVersions", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListVersionsComplete retrieves all of the results into a single object -func (c KeysClient) ListVersionsComplete(ctx context.Context, id commonids.KeyVaultKeyId) (ListVersionsCompleteResult, error) { - return c.ListVersionsCompleteMatchingPredicate(ctx, id, KeyOperationPredicate{}) -} - -// ListVersionsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c KeysClient) ListVersionsCompleteMatchingPredicate(ctx context.Context, id commonids.KeyVaultKeyId, predicate KeyOperationPredicate) (resp ListVersionsCompleteResult, err error) { - items := make([]Key, 0) - - page, err := c.ListVersions(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListVersionsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/keyvault/2022-11-01/keys/model_action.go b/resource-manager/keyvault/2022-11-01/keys/model_action.go deleted file mode 100644 index 50250a0db9b..00000000000 --- a/resource-manager/keyvault/2022-11-01/keys/model_action.go +++ /dev/null @@ -1,8 +0,0 @@ -package keys - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type Action struct { - Type *KeyRotationPolicyActionType `json:"type,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/keys/model_key.go b/resource-manager/keyvault/2022-11-01/keys/model_key.go deleted file mode 100644 index 60f6d4257d8..00000000000 --- a/resource-manager/keyvault/2022-11-01/keys/model_key.go +++ /dev/null @@ -1,13 +0,0 @@ -package keys - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type Key struct { - Id *string `json:"id,omitempty"` - Location *string `json:"location,omitempty"` - Name *string `json:"name,omitempty"` - Properties KeyProperties `json:"properties"` - Tags *map[string]string `json:"tags,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/keys/model_keyattributes.go b/resource-manager/keyvault/2022-11-01/keys/model_keyattributes.go deleted file mode 100644 index ba14a8921b0..00000000000 --- a/resource-manager/keyvault/2022-11-01/keys/model_keyattributes.go +++ /dev/null @@ -1,14 +0,0 @@ -package keys - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type KeyAttributes struct { - Created *int64 `json:"created,omitempty"` - Enabled *bool `json:"enabled,omitempty"` - Exp *int64 `json:"exp,omitempty"` - Exportable *bool `json:"exportable,omitempty"` - Nbf *int64 `json:"nbf,omitempty"` - RecoveryLevel *DeletionRecoveryLevel `json:"recoveryLevel,omitempty"` - Updated *int64 `json:"updated,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/keys/model_keycreateparameters.go b/resource-manager/keyvault/2022-11-01/keys/model_keycreateparameters.go deleted file mode 100644 index 4ce00d53412..00000000000 --- a/resource-manager/keyvault/2022-11-01/keys/model_keycreateparameters.go +++ /dev/null @@ -1,9 +0,0 @@ -package keys - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type KeyCreateParameters struct { - Properties KeyProperties `json:"properties"` - Tags *map[string]string `json:"tags,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/keys/model_keyproperties.go b/resource-manager/keyvault/2022-11-01/keys/model_keyproperties.go deleted file mode 100644 index e81a89b5f5f..00000000000 --- a/resource-manager/keyvault/2022-11-01/keys/model_keyproperties.go +++ /dev/null @@ -1,16 +0,0 @@ -package keys - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type KeyProperties struct { - Attributes *KeyAttributes `json:"attributes,omitempty"` - CurveName *JsonWebKeyCurveName `json:"curveName,omitempty"` - KeyOps *[]JsonWebKeyOperation `json:"keyOps,omitempty"` - KeySize *int64 `json:"keySize,omitempty"` - KeyUri *string `json:"keyUri,omitempty"` - KeyUriWithVersion *string `json:"keyUriWithVersion,omitempty"` - Kty *JsonWebKeyType `json:"kty,omitempty"` - ReleasePolicy *KeyReleasePolicy `json:"release_policy,omitempty"` - RotationPolicy *RotationPolicy `json:"rotationPolicy,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/keys/model_keyreleasepolicy.go b/resource-manager/keyvault/2022-11-01/keys/model_keyreleasepolicy.go deleted file mode 100644 index 51a28ffb506..00000000000 --- a/resource-manager/keyvault/2022-11-01/keys/model_keyreleasepolicy.go +++ /dev/null @@ -1,9 +0,0 @@ -package keys - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type KeyReleasePolicy struct { - ContentType *string `json:"contentType,omitempty"` - Data *string `json:"data,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/keys/model_keyrotationpolicyattributes.go b/resource-manager/keyvault/2022-11-01/keys/model_keyrotationpolicyattributes.go deleted file mode 100644 index 50254af460c..00000000000 --- a/resource-manager/keyvault/2022-11-01/keys/model_keyrotationpolicyattributes.go +++ /dev/null @@ -1,10 +0,0 @@ -package keys - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type KeyRotationPolicyAttributes struct { - Created *int64 `json:"created,omitempty"` - ExpiryTime *string `json:"expiryTime,omitempty"` - Updated *int64 `json:"updated,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/keys/model_lifetimeaction.go b/resource-manager/keyvault/2022-11-01/keys/model_lifetimeaction.go deleted file mode 100644 index aafb6dd8a07..00000000000 --- a/resource-manager/keyvault/2022-11-01/keys/model_lifetimeaction.go +++ /dev/null @@ -1,9 +0,0 @@ -package keys - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type LifetimeAction struct { - Action *Action `json:"action,omitempty"` - Trigger *Trigger `json:"trigger,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/keys/model_rotationpolicy.go b/resource-manager/keyvault/2022-11-01/keys/model_rotationpolicy.go deleted file mode 100644 index c92fe27f2fb..00000000000 --- a/resource-manager/keyvault/2022-11-01/keys/model_rotationpolicy.go +++ /dev/null @@ -1,9 +0,0 @@ -package keys - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type RotationPolicy struct { - Attributes *KeyRotationPolicyAttributes `json:"attributes,omitempty"` - LifetimeActions *[]LifetimeAction `json:"lifetimeActions,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/keys/model_trigger.go b/resource-manager/keyvault/2022-11-01/keys/model_trigger.go deleted file mode 100644 index ac603309819..00000000000 --- a/resource-manager/keyvault/2022-11-01/keys/model_trigger.go +++ /dev/null @@ -1,9 +0,0 @@ -package keys - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type Trigger struct { - TimeAfterCreate *string `json:"timeAfterCreate,omitempty"` - TimeBeforeExpiry *string `json:"timeBeforeExpiry,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/keys/predicates.go b/resource-manager/keyvault/2022-11-01/keys/predicates.go deleted file mode 100644 index d7bea89219a..00000000000 --- a/resource-manager/keyvault/2022-11-01/keys/predicates.go +++ /dev/null @@ -1,32 +0,0 @@ -package keys - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type KeyOperationPredicate struct { - Id *string - Location *string - Name *string - Type *string -} - -func (p KeyOperationPredicate) Matches(input Key) 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/keyvault/2022-11-01/keys/version.go b/resource-manager/keyvault/2022-11-01/keys/version.go deleted file mode 100644 index dfabe4496e7..00000000000 --- a/resource-manager/keyvault/2022-11-01/keys/version.go +++ /dev/null @@ -1,12 +0,0 @@ -package keys - -import "fmt" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -const defaultApiVersion = "2022-11-01" - -func userAgent() string { - return fmt.Sprintf("hashicorp/go-azure-sdk/keys/%s", defaultApiVersion) -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsmkeys/README.md b/resource-manager/keyvault/2022-11-01/managedhsmkeys/README.md deleted file mode 100644 index d50e0d484aa..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsmkeys/README.md +++ /dev/null @@ -1,107 +0,0 @@ - -## `github.com/hashicorp/go-azure-sdk/resource-manager/keyvault/2022-11-01/managedhsmkeys` Documentation - -The `managedhsmkeys` SDK allows for interaction with the Azure Resource Manager Service `keyvault` (API Version `2022-11-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/keyvault/2022-11-01/managedhsmkeys" -``` - - -### Client Initialization - -```go -client := managedhsmkeys.NewManagedHsmKeysClientWithBaseURI("https://management.azure.com") -client.Client.Authorizer = authorizer -``` - - -### Example Usage: `ManagedHsmKeysClient.CreateIfNotExist` - -```go -ctx := context.TODO() -id := managedhsmkeys.NewKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedHSMValue", "keyValue") - -payload := managedhsmkeys.ManagedHsmKeyCreateParameters{ - // ... -} - - -read, err := client.CreateIfNotExist(ctx, id, payload) -if err != nil { - // handle the error -} -if model := read.Model; model != nil { - // do something with the model/response object -} -``` - - -### Example Usage: `ManagedHsmKeysClient.Get` - -```go -ctx := context.TODO() -id := managedhsmkeys.NewKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedHSMValue", "keyValue") - -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: `ManagedHsmKeysClient.GetVersion` - -```go -ctx := context.TODO() -id := managedhsmkeys.NewVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedHSMValue", "keyValue", "versionValue") - -read, err := client.GetVersion(ctx, id) -if err != nil { - // handle the error -} -if model := read.Model; model != nil { - // do something with the model/response object -} -``` - - -### Example Usage: `ManagedHsmKeysClient.List` - -```go -ctx := context.TODO() -id := managedhsmkeys.NewManagedHSMID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedHSMValue") - -// 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: `ManagedHsmKeysClient.ListVersions` - -```go -ctx := context.TODO() -id := managedhsmkeys.NewKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedHSMValue", "keyValue") - -// alternatively `client.ListVersions(ctx, id)` can be used to do batched pagination -items, err := client.ListVersionsComplete(ctx, id) -if err != nil { - // handle the error -} -for _, item := range items { - // do something -} -``` diff --git a/resource-manager/keyvault/2022-11-01/managedhsmkeys/client.go b/resource-manager/keyvault/2022-11-01/managedhsmkeys/client.go deleted file mode 100644 index 00b1e46fa11..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsmkeys/client.go +++ /dev/null @@ -1,18 +0,0 @@ -package managedhsmkeys - -import "github.com/Azure/go-autorest/autorest" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ManagedHsmKeysClient struct { - Client autorest.Client - baseUri string -} - -func NewManagedHsmKeysClientWithBaseURI(endpoint string) ManagedHsmKeysClient { - return ManagedHsmKeysClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsmkeys/constants.go b/resource-manager/keyvault/2022-11-01/managedhsmkeys/constants.go deleted file mode 100644 index 20142cc93aa..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsmkeys/constants.go +++ /dev/null @@ -1,182 +0,0 @@ -package managedhsmkeys - -import "strings" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeletionRecoveryLevel string - -const ( - DeletionRecoveryLevelPurgeable DeletionRecoveryLevel = "Purgeable" - DeletionRecoveryLevelRecoverable DeletionRecoveryLevel = "Recoverable" - DeletionRecoveryLevelRecoverablePositiveProtectedSubscription DeletionRecoveryLevel = "Recoverable+ProtectedSubscription" - DeletionRecoveryLevelRecoverablePositivePurgeable DeletionRecoveryLevel = "Recoverable+Purgeable" -) - -func PossibleValuesForDeletionRecoveryLevel() []string { - return []string{ - string(DeletionRecoveryLevelPurgeable), - string(DeletionRecoveryLevelRecoverable), - string(DeletionRecoveryLevelRecoverablePositiveProtectedSubscription), - string(DeletionRecoveryLevelRecoverablePositivePurgeable), - } -} - -func parseDeletionRecoveryLevel(input string) (*DeletionRecoveryLevel, error) { - vals := map[string]DeletionRecoveryLevel{ - "purgeable": DeletionRecoveryLevelPurgeable, - "recoverable": DeletionRecoveryLevelRecoverable, - "recoverable+protectedsubscription": DeletionRecoveryLevelRecoverablePositiveProtectedSubscription, - "recoverable+purgeable": DeletionRecoveryLevelRecoverablePositivePurgeable, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := DeletionRecoveryLevel(input) - return &out, nil -} - -type JsonWebKeyCurveName string - -const ( - JsonWebKeyCurveNamePNegativeFiveTwoOne JsonWebKeyCurveName = "P-521" - JsonWebKeyCurveNamePNegativeThreeEightFour JsonWebKeyCurveName = "P-384" - JsonWebKeyCurveNamePNegativeTwoFiveSix JsonWebKeyCurveName = "P-256" - JsonWebKeyCurveNamePNegativeTwoFiveSixK JsonWebKeyCurveName = "P-256K" -) - -func PossibleValuesForJsonWebKeyCurveName() []string { - return []string{ - string(JsonWebKeyCurveNamePNegativeFiveTwoOne), - string(JsonWebKeyCurveNamePNegativeThreeEightFour), - string(JsonWebKeyCurveNamePNegativeTwoFiveSix), - string(JsonWebKeyCurveNamePNegativeTwoFiveSixK), - } -} - -func parseJsonWebKeyCurveName(input string) (*JsonWebKeyCurveName, error) { - vals := map[string]JsonWebKeyCurveName{ - "p-521": JsonWebKeyCurveNamePNegativeFiveTwoOne, - "p-384": JsonWebKeyCurveNamePNegativeThreeEightFour, - "p-256": JsonWebKeyCurveNamePNegativeTwoFiveSix, - "p-256k": JsonWebKeyCurveNamePNegativeTwoFiveSixK, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := JsonWebKeyCurveName(input) - return &out, nil -} - -type JsonWebKeyOperation string - -const ( - JsonWebKeyOperationDecrypt JsonWebKeyOperation = "decrypt" - JsonWebKeyOperationEncrypt JsonWebKeyOperation = "encrypt" - JsonWebKeyOperationImport JsonWebKeyOperation = "import" - JsonWebKeyOperationRelease JsonWebKeyOperation = "release" - JsonWebKeyOperationSign JsonWebKeyOperation = "sign" - JsonWebKeyOperationUnwrapKey JsonWebKeyOperation = "unwrapKey" - JsonWebKeyOperationVerify JsonWebKeyOperation = "verify" - JsonWebKeyOperationWrapKey JsonWebKeyOperation = "wrapKey" -) - -func PossibleValuesForJsonWebKeyOperation() []string { - return []string{ - string(JsonWebKeyOperationDecrypt), - string(JsonWebKeyOperationEncrypt), - string(JsonWebKeyOperationImport), - string(JsonWebKeyOperationRelease), - string(JsonWebKeyOperationSign), - string(JsonWebKeyOperationUnwrapKey), - string(JsonWebKeyOperationVerify), - string(JsonWebKeyOperationWrapKey), - } -} - -func parseJsonWebKeyOperation(input string) (*JsonWebKeyOperation, error) { - vals := map[string]JsonWebKeyOperation{ - "decrypt": JsonWebKeyOperationDecrypt, - "encrypt": JsonWebKeyOperationEncrypt, - "import": JsonWebKeyOperationImport, - "release": JsonWebKeyOperationRelease, - "sign": JsonWebKeyOperationSign, - "unwrapkey": JsonWebKeyOperationUnwrapKey, - "verify": JsonWebKeyOperationVerify, - "wrapkey": JsonWebKeyOperationWrapKey, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := JsonWebKeyOperation(input) - return &out, nil -} - -type JsonWebKeyType string - -const ( - JsonWebKeyTypeEC JsonWebKeyType = "EC" - JsonWebKeyTypeECNegativeHSM JsonWebKeyType = "EC-HSM" - JsonWebKeyTypeRSA JsonWebKeyType = "RSA" - JsonWebKeyTypeRSANegativeHSM JsonWebKeyType = "RSA-HSM" -) - -func PossibleValuesForJsonWebKeyType() []string { - return []string{ - string(JsonWebKeyTypeEC), - string(JsonWebKeyTypeECNegativeHSM), - string(JsonWebKeyTypeRSA), - string(JsonWebKeyTypeRSANegativeHSM), - } -} - -func parseJsonWebKeyType(input string) (*JsonWebKeyType, error) { - vals := map[string]JsonWebKeyType{ - "ec": JsonWebKeyTypeEC, - "ec-hsm": JsonWebKeyTypeECNegativeHSM, - "rsa": JsonWebKeyTypeRSA, - "rsa-hsm": JsonWebKeyTypeRSANegativeHSM, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := JsonWebKeyType(input) - return &out, nil -} - -type KeyRotationPolicyActionType string - -const ( - KeyRotationPolicyActionTypeNotify KeyRotationPolicyActionType = "Notify" - KeyRotationPolicyActionTypeRotate KeyRotationPolicyActionType = "Rotate" -) - -func PossibleValuesForKeyRotationPolicyActionType() []string { - return []string{ - string(KeyRotationPolicyActionTypeNotify), - string(KeyRotationPolicyActionTypeRotate), - } -} - -func parseKeyRotationPolicyActionType(input string) (*KeyRotationPolicyActionType, error) { - vals := map[string]KeyRotationPolicyActionType{ - "notify": KeyRotationPolicyActionTypeNotify, - "rotate": KeyRotationPolicyActionTypeRotate, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := KeyRotationPolicyActionType(input) - return &out, nil -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsmkeys/id_key.go b/resource-manager/keyvault/2022-11-01/managedhsmkeys/id_key.go deleted file mode 100644 index 1b236a770f4..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsmkeys/id_key.go +++ /dev/null @@ -1,134 +0,0 @@ -package managedhsmkeys - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -var _ resourceids.ResourceId = &KeyId{} - -// KeyId is a struct representing the Resource ID for a Key -type KeyId struct { - SubscriptionId string - ResourceGroupName string - ManagedHSMName string - KeyName string -} - -// NewKeyID returns a new KeyId struct -func NewKeyID(subscriptionId string, resourceGroupName string, managedHSMName string, keyName string) KeyId { - return KeyId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - ManagedHSMName: managedHSMName, - KeyName: keyName, - } -} - -// ParseKeyID parses 'input' into a KeyId -func ParseKeyID(input string) (*KeyId, error) { - parser := resourceids.NewParserFromResourceIdType(&KeyId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := KeyId{} - if err := id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -// ParseKeyIDInsensitively parses 'input' case-insensitively into a KeyId -// note: this method should only be used for API response data and not user input -func ParseKeyIDInsensitively(input string) (*KeyId, error) { - parser := resourceids.NewParserFromResourceIdType(&KeyId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := KeyId{} - if err := id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -func (id *KeyId) FromParseResult(input resourceids.ParseResult) error { - var ok bool - - if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) - } - - if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) - } - - if id.ManagedHSMName, ok = input.Parsed["managedHSMName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "managedHSMName", input) - } - - if id.KeyName, ok = input.Parsed["keyName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "keyName", input) - } - - return nil -} - -// ValidateKeyID checks that 'input' can be parsed as a Key ID -func ValidateKeyID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParseKeyID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Key ID -func (id KeyId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.KeyVault/managedHSMs/%s/keys/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedHSMName, id.KeyName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Key ID -func (id KeyId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftKeyVault", "Microsoft.KeyVault", "Microsoft.KeyVault"), - resourceids.StaticSegment("staticManagedHSMs", "managedHSMs", "managedHSMs"), - resourceids.UserSpecifiedSegment("managedHSMName", "managedHSMValue"), - resourceids.StaticSegment("staticKeys", "keys", "keys"), - resourceids.UserSpecifiedSegment("keyName", "keyValue"), - } -} - -// String returns a human-readable description of this Key ID -func (id KeyId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Managed H S M Name: %q", id.ManagedHSMName), - fmt.Sprintf("Key Name: %q", id.KeyName), - } - return fmt.Sprintf("Key (%s)", strings.Join(components, "\n")) -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsmkeys/id_key_test.go b/resource-manager/keyvault/2022-11-01/managedhsmkeys/id_key_test.go deleted file mode 100644 index f41284beb5a..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsmkeys/id_key_test.go +++ /dev/null @@ -1,327 +0,0 @@ -package managedhsmkeys - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -var _ resourceids.ResourceId = &KeyId{} - -func TestNewKeyID(t *testing.T) { - id := NewKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedHSMValue", "keyValue") - - if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { - t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") - } - - if id.ResourceGroupName != "example-resource-group" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") - } - - if id.ManagedHSMName != "managedHSMValue" { - t.Fatalf("Expected %q but got %q for Segment 'ManagedHSMName'", id.ManagedHSMName, "managedHSMValue") - } - - if id.KeyName != "keyValue" { - t.Fatalf("Expected %q but got %q for Segment 'KeyName'", id.KeyName, "keyValue") - } -} - -func TestFormatKeyID(t *testing.T) { - actual := NewKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedHSMValue", "keyValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue/keys/keyValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseKeyID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *KeyId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue/keys", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue/keys/keyValue", - Expected: &KeyId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ManagedHSMName: "managedHSMValue", - KeyName: "keyValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue/keys/keyValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseKeyID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.ManagedHSMName != v.Expected.ManagedHSMName { - t.Fatalf("Expected %q but got %q for ManagedHSMName", v.Expected.ManagedHSMName, actual.ManagedHSMName) - } - - if actual.KeyName != v.Expected.KeyName { - t.Fatalf("Expected %q but got %q for KeyName", v.Expected.KeyName, actual.KeyName) - } - - } -} - -func TestParseKeyIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *KeyId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/mAnAgEdHsMs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/mAnAgEdHsMs/mAnAgEdHsMvAlUe", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue/keys", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/mAnAgEdHsMs/mAnAgEdHsMvAlUe/kEyS", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue/keys/keyValue", - Expected: &KeyId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ManagedHSMName: "managedHSMValue", - KeyName: "keyValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue/keys/keyValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/mAnAgEdHsMs/mAnAgEdHsMvAlUe/kEyS/kEyVaLuE", - Expected: &KeyId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - ManagedHSMName: "mAnAgEdHsMvAlUe", - KeyName: "kEyVaLuE", - }, - }, - { - // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/mAnAgEdHsMs/mAnAgEdHsMvAlUe/kEyS/kEyVaLuE/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseKeyIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.ManagedHSMName != v.Expected.ManagedHSMName { - t.Fatalf("Expected %q but got %q for ManagedHSMName", v.Expected.ManagedHSMName, actual.ManagedHSMName) - } - - if actual.KeyName != v.Expected.KeyName { - t.Fatalf("Expected %q but got %q for KeyName", v.Expected.KeyName, actual.KeyName) - } - - } -} - -func TestSegmentsForKeyId(t *testing.T) { - segments := KeyId{}.Segments() - if len(segments) == 0 { - t.Fatalf("KeyId has no segments") - } - - uniqueNames := make(map[string]struct{}, 0) - for _, segment := range segments { - uniqueNames[segment.Name] = struct{}{} - } - if len(uniqueNames) != len(segments) { - t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) - } -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsmkeys/id_managedhsm.go b/resource-manager/keyvault/2022-11-01/managedhsmkeys/id_managedhsm.go deleted file mode 100644 index 3083766cd7d..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsmkeys/id_managedhsm.go +++ /dev/null @@ -1,125 +0,0 @@ -package managedhsmkeys - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -var _ resourceids.ResourceId = &ManagedHSMId{} - -// ManagedHSMId is a struct representing the Resource ID for a Managed H S M -type ManagedHSMId struct { - SubscriptionId string - ResourceGroupName string - ManagedHSMName string -} - -// NewManagedHSMID returns a new ManagedHSMId struct -func NewManagedHSMID(subscriptionId string, resourceGroupName string, managedHSMName string) ManagedHSMId { - return ManagedHSMId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - ManagedHSMName: managedHSMName, - } -} - -// ParseManagedHSMID parses 'input' into a ManagedHSMId -func ParseManagedHSMID(input string) (*ManagedHSMId, error) { - parser := resourceids.NewParserFromResourceIdType(&ManagedHSMId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := ManagedHSMId{} - if err := id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -// ParseManagedHSMIDInsensitively parses 'input' case-insensitively into a ManagedHSMId -// note: this method should only be used for API response data and not user input -func ParseManagedHSMIDInsensitively(input string) (*ManagedHSMId, error) { - parser := resourceids.NewParserFromResourceIdType(&ManagedHSMId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := ManagedHSMId{} - if err := id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -func (id *ManagedHSMId) FromParseResult(input resourceids.ParseResult) error { - var ok bool - - if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) - } - - if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) - } - - if id.ManagedHSMName, ok = input.Parsed["managedHSMName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "managedHSMName", input) - } - - return nil -} - -// ValidateManagedHSMID checks that 'input' can be parsed as a Managed H S M ID -func ValidateManagedHSMID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParseManagedHSMID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Managed H S M ID -func (id ManagedHSMId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.KeyVault/managedHSMs/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedHSMName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Managed H S M ID -func (id ManagedHSMId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftKeyVault", "Microsoft.KeyVault", "Microsoft.KeyVault"), - resourceids.StaticSegment("staticManagedHSMs", "managedHSMs", "managedHSMs"), - resourceids.UserSpecifiedSegment("managedHSMName", "managedHSMValue"), - } -} - -// String returns a human-readable description of this Managed H S M ID -func (id ManagedHSMId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Managed H S M Name: %q", id.ManagedHSMName), - } - return fmt.Sprintf("Managed H S M (%s)", strings.Join(components, "\n")) -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsmkeys/id_managedhsm_test.go b/resource-manager/keyvault/2022-11-01/managedhsmkeys/id_managedhsm_test.go deleted file mode 100644 index f600a81e035..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsmkeys/id_managedhsm_test.go +++ /dev/null @@ -1,282 +0,0 @@ -package managedhsmkeys - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -var _ resourceids.ResourceId = &ManagedHSMId{} - -func TestNewManagedHSMID(t *testing.T) { - id := NewManagedHSMID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedHSMValue") - - if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { - t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") - } - - if id.ResourceGroupName != "example-resource-group" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") - } - - if id.ManagedHSMName != "managedHSMValue" { - t.Fatalf("Expected %q but got %q for Segment 'ManagedHSMName'", id.ManagedHSMName, "managedHSMValue") - } -} - -func TestFormatManagedHSMID(t *testing.T) { - actual := NewManagedHSMID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedHSMValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseManagedHSMID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *ManagedHSMId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue", - Expected: &ManagedHSMId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ManagedHSMName: "managedHSMValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseManagedHSMID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.ManagedHSMName != v.Expected.ManagedHSMName { - t.Fatalf("Expected %q but got %q for ManagedHSMName", v.Expected.ManagedHSMName, actual.ManagedHSMName) - } - - } -} - -func TestParseManagedHSMIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *ManagedHSMId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/mAnAgEdHsMs", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue", - Expected: &ManagedHSMId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ManagedHSMName: "managedHSMValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/mAnAgEdHsMs/mAnAgEdHsMvAlUe", - Expected: &ManagedHSMId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - ManagedHSMName: "mAnAgEdHsMvAlUe", - }, - }, - { - // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/mAnAgEdHsMs/mAnAgEdHsMvAlUe/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseManagedHSMIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.ManagedHSMName != v.Expected.ManagedHSMName { - t.Fatalf("Expected %q but got %q for ManagedHSMName", v.Expected.ManagedHSMName, actual.ManagedHSMName) - } - - } -} - -func TestSegmentsForManagedHSMId(t *testing.T) { - segments := ManagedHSMId{}.Segments() - if len(segments) == 0 { - t.Fatalf("ManagedHSMId has no segments") - } - - uniqueNames := make(map[string]struct{}, 0) - for _, segment := range segments { - uniqueNames[segment.Name] = struct{}{} - } - if len(uniqueNames) != len(segments) { - t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) - } -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsmkeys/id_version.go b/resource-manager/keyvault/2022-11-01/managedhsmkeys/id_version.go deleted file mode 100644 index 69e5bcd5b82..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsmkeys/id_version.go +++ /dev/null @@ -1,143 +0,0 @@ -package managedhsmkeys - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -var _ resourceids.ResourceId = &VersionId{} - -// VersionId is a struct representing the Resource ID for a Version -type VersionId struct { - SubscriptionId string - ResourceGroupName string - ManagedHSMName string - KeyName string - VersionName string -} - -// NewVersionID returns a new VersionId struct -func NewVersionID(subscriptionId string, resourceGroupName string, managedHSMName string, keyName string, versionName string) VersionId { - return VersionId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - ManagedHSMName: managedHSMName, - KeyName: keyName, - VersionName: versionName, - } -} - -// ParseVersionID parses 'input' into a VersionId -func ParseVersionID(input string) (*VersionId, error) { - parser := resourceids.NewParserFromResourceIdType(&VersionId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := VersionId{} - if err := id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -// ParseVersionIDInsensitively parses 'input' case-insensitively into a VersionId -// note: this method should only be used for API response data and not user input -func ParseVersionIDInsensitively(input string) (*VersionId, error) { - parser := resourceids.NewParserFromResourceIdType(&VersionId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := VersionId{} - if err := id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -func (id *VersionId) FromParseResult(input resourceids.ParseResult) error { - var ok bool - - if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) - } - - if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) - } - - if id.ManagedHSMName, ok = input.Parsed["managedHSMName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "managedHSMName", input) - } - - if id.KeyName, ok = input.Parsed["keyName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "keyName", input) - } - - if id.VersionName, ok = input.Parsed["versionName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "versionName", input) - } - - return nil -} - -// ValidateVersionID checks that 'input' can be parsed as a Version ID -func ValidateVersionID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParseVersionID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Version ID -func (id VersionId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.KeyVault/managedHSMs/%s/keys/%s/versions/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedHSMName, id.KeyName, id.VersionName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Version ID -func (id VersionId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftKeyVault", "Microsoft.KeyVault", "Microsoft.KeyVault"), - resourceids.StaticSegment("staticManagedHSMs", "managedHSMs", "managedHSMs"), - resourceids.UserSpecifiedSegment("managedHSMName", "managedHSMValue"), - resourceids.StaticSegment("staticKeys", "keys", "keys"), - resourceids.UserSpecifiedSegment("keyName", "keyValue"), - resourceids.StaticSegment("staticVersions", "versions", "versions"), - resourceids.UserSpecifiedSegment("versionName", "versionValue"), - } -} - -// String returns a human-readable description of this Version ID -func (id VersionId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Managed H S M Name: %q", id.ManagedHSMName), - fmt.Sprintf("Key Name: %q", id.KeyName), - fmt.Sprintf("Version Name: %q", id.VersionName), - } - return fmt.Sprintf("Version (%s)", strings.Join(components, "\n")) -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsmkeys/id_version_test.go b/resource-manager/keyvault/2022-11-01/managedhsmkeys/id_version_test.go deleted file mode 100644 index e0cbba7b58e..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsmkeys/id_version_test.go +++ /dev/null @@ -1,372 +0,0 @@ -package managedhsmkeys - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -var _ resourceids.ResourceId = &VersionId{} - -func TestNewVersionID(t *testing.T) { - id := NewVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedHSMValue", "keyValue", "versionValue") - - if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { - t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") - } - - if id.ResourceGroupName != "example-resource-group" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") - } - - if id.ManagedHSMName != "managedHSMValue" { - t.Fatalf("Expected %q but got %q for Segment 'ManagedHSMName'", id.ManagedHSMName, "managedHSMValue") - } - - if id.KeyName != "keyValue" { - t.Fatalf("Expected %q but got %q for Segment 'KeyName'", id.KeyName, "keyValue") - } - - if id.VersionName != "versionValue" { - t.Fatalf("Expected %q but got %q for Segment 'VersionName'", id.VersionName, "versionValue") - } -} - -func TestFormatVersionID(t *testing.T) { - actual := NewVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedHSMValue", "keyValue", "versionValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue/keys/keyValue/versions/versionValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseVersionID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *VersionId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue/keys", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue/keys/keyValue", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue/keys/keyValue/versions", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue/keys/keyValue/versions/versionValue", - Expected: &VersionId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ManagedHSMName: "managedHSMValue", - KeyName: "keyValue", - VersionName: "versionValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue/keys/keyValue/versions/versionValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseVersionID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.ManagedHSMName != v.Expected.ManagedHSMName { - t.Fatalf("Expected %q but got %q for ManagedHSMName", v.Expected.ManagedHSMName, actual.ManagedHSMName) - } - - if actual.KeyName != v.Expected.KeyName { - t.Fatalf("Expected %q but got %q for KeyName", v.Expected.KeyName, actual.KeyName) - } - - if actual.VersionName != v.Expected.VersionName { - t.Fatalf("Expected %q but got %q for VersionName", v.Expected.VersionName, actual.VersionName) - } - - } -} - -func TestParseVersionIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *VersionId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/mAnAgEdHsMs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/mAnAgEdHsMs/mAnAgEdHsMvAlUe", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue/keys", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/mAnAgEdHsMs/mAnAgEdHsMvAlUe/kEyS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue/keys/keyValue", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/mAnAgEdHsMs/mAnAgEdHsMvAlUe/kEyS/kEyVaLuE", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue/keys/keyValue/versions", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/mAnAgEdHsMs/mAnAgEdHsMvAlUe/kEyS/kEyVaLuE/vErSiOnS", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue/keys/keyValue/versions/versionValue", - Expected: &VersionId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ManagedHSMName: "managedHSMValue", - KeyName: "keyValue", - VersionName: "versionValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue/keys/keyValue/versions/versionValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/mAnAgEdHsMs/mAnAgEdHsMvAlUe/kEyS/kEyVaLuE/vErSiOnS/vErSiOnVaLuE", - Expected: &VersionId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - ManagedHSMName: "mAnAgEdHsMvAlUe", - KeyName: "kEyVaLuE", - VersionName: "vErSiOnVaLuE", - }, - }, - { - // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/mAnAgEdHsMs/mAnAgEdHsMvAlUe/kEyS/kEyVaLuE/vErSiOnS/vErSiOnVaLuE/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseVersionIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.ManagedHSMName != v.Expected.ManagedHSMName { - t.Fatalf("Expected %q but got %q for ManagedHSMName", v.Expected.ManagedHSMName, actual.ManagedHSMName) - } - - if actual.KeyName != v.Expected.KeyName { - t.Fatalf("Expected %q but got %q for KeyName", v.Expected.KeyName, actual.KeyName) - } - - 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/keyvault/2022-11-01/managedhsmkeys/method_createifnotexist_autorest.go b/resource-manager/keyvault/2022-11-01/managedhsmkeys/method_createifnotexist_autorest.go deleted file mode 100644 index aa82950bb50..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsmkeys/method_createifnotexist_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package managedhsmkeys - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateIfNotExistOperationResponse struct { - HttpResponse *http.Response - Model *ManagedHsmKey -} - -// CreateIfNotExist ... -func (c ManagedHsmKeysClient) CreateIfNotExist(ctx context.Context, id KeyId, input ManagedHsmKeyCreateParameters) (result CreateIfNotExistOperationResponse, err error) { - req, err := c.preparerForCreateIfNotExist(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsmkeys.ManagedHsmKeysClient", "CreateIfNotExist", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsmkeys.ManagedHsmKeysClient", "CreateIfNotExist", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateIfNotExist(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsmkeys.ManagedHsmKeysClient", "CreateIfNotExist", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateIfNotExist prepares the CreateIfNotExist request. -func (c ManagedHsmKeysClient) preparerForCreateIfNotExist(ctx context.Context, id KeyId, input ManagedHsmKeyCreateParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateIfNotExist handles the response to the CreateIfNotExist request. The method always -// closes the http.Response Body. -func (c ManagedHsmKeysClient) responderForCreateIfNotExist(resp *http.Response) (result CreateIfNotExistOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsmkeys/method_get_autorest.go b/resource-manager/keyvault/2022-11-01/managedhsmkeys/method_get_autorest.go deleted file mode 100644 index db30eaf79c9..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsmkeys/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package managedhsmkeys - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *ManagedHsmKey -} - -// Get ... -func (c ManagedHsmKeysClient) Get(ctx context.Context, id KeyId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsmkeys.ManagedHsmKeysClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsmkeys.ManagedHsmKeysClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsmkeys.ManagedHsmKeysClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ManagedHsmKeysClient) preparerForGet(ctx context.Context, id KeyId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c ManagedHsmKeysClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsmkeys/method_getversion_autorest.go b/resource-manager/keyvault/2022-11-01/managedhsmkeys/method_getversion_autorest.go deleted file mode 100644 index 0ae2f0a6a44..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsmkeys/method_getversion_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package managedhsmkeys - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetVersionOperationResponse struct { - HttpResponse *http.Response - Model *ManagedHsmKey -} - -// GetVersion ... -func (c ManagedHsmKeysClient) GetVersion(ctx context.Context, id VersionId) (result GetVersionOperationResponse, err error) { - req, err := c.preparerForGetVersion(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsmkeys.ManagedHsmKeysClient", "GetVersion", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsmkeys.ManagedHsmKeysClient", "GetVersion", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetVersion(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsmkeys.ManagedHsmKeysClient", "GetVersion", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetVersion prepares the GetVersion request. -func (c ManagedHsmKeysClient) preparerForGetVersion(ctx context.Context, id VersionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetVersion handles the response to the GetVersion request. The method always -// closes the http.Response Body. -func (c ManagedHsmKeysClient) responderForGetVersion(resp *http.Response) (result GetVersionOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsmkeys/method_list_autorest.go b/resource-manager/keyvault/2022-11-01/managedhsmkeys/method_list_autorest.go deleted file mode 100644 index ed089028581..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsmkeys/method_list_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package managedhsmkeys - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *[]ManagedHsmKey - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []ManagedHsmKey -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// List ... -func (c ManagedHsmKeysClient) List(ctx context.Context, id ManagedHSMId) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsmkeys.ManagedHsmKeysClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsmkeys.ManagedHsmKeysClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsmkeys.ManagedHsmKeysClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c ManagedHsmKeysClient) preparerForList(ctx context.Context, id ManagedHSMId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/keys", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c ManagedHsmKeysClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c ManagedHsmKeysClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []ManagedHsmKey `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { - req, err := c.preparerForListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsmkeys.ManagedHsmKeysClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsmkeys.ManagedHsmKeysClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsmkeys.ManagedHsmKeysClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c ManagedHsmKeysClient) ListComplete(ctx context.Context, id ManagedHSMId) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, ManagedHsmKeyOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ManagedHsmKeysClient) ListCompleteMatchingPredicate(ctx context.Context, id ManagedHSMId, predicate ManagedHsmKeyOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]ManagedHsmKey, 0) - - page, err := c.List(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsmkeys/method_listversions_autorest.go b/resource-manager/keyvault/2022-11-01/managedhsmkeys/method_listversions_autorest.go deleted file mode 100644 index 58118cbe7ad..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsmkeys/method_listversions_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package managedhsmkeys - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListVersionsOperationResponse struct { - HttpResponse *http.Response - Model *[]ManagedHsmKey - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListVersionsOperationResponse, error) -} - -type ListVersionsCompleteResult struct { - Items []ManagedHsmKey -} - -func (r ListVersionsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListVersionsOperationResponse) LoadMore(ctx context.Context) (resp ListVersionsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListVersions ... -func (c ManagedHsmKeysClient) ListVersions(ctx context.Context, id KeyId) (resp ListVersionsOperationResponse, err error) { - req, err := c.preparerForListVersions(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsmkeys.ManagedHsmKeysClient", "ListVersions", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsmkeys.ManagedHsmKeysClient", "ListVersions", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListVersions(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsmkeys.ManagedHsmKeysClient", "ListVersions", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListVersions prepares the ListVersions request. -func (c ManagedHsmKeysClient) preparerForListVersions(ctx context.Context, id KeyId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/versions", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListVersionsWithNextLink prepares the ListVersions request with the given nextLink token. -func (c ManagedHsmKeysClient) preparerForListVersionsWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListVersions handles the response to the ListVersions request. The method always -// closes the http.Response Body. -func (c ManagedHsmKeysClient) responderForListVersions(resp *http.Response) (result ListVersionsOperationResponse, err error) { - type page struct { - Values []ManagedHsmKey `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListVersionsOperationResponse, err error) { - req, err := c.preparerForListVersionsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsmkeys.ManagedHsmKeysClient", "ListVersions", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsmkeys.ManagedHsmKeysClient", "ListVersions", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListVersions(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsmkeys.ManagedHsmKeysClient", "ListVersions", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListVersionsComplete retrieves all of the results into a single object -func (c ManagedHsmKeysClient) ListVersionsComplete(ctx context.Context, id KeyId) (ListVersionsCompleteResult, error) { - return c.ListVersionsCompleteMatchingPredicate(ctx, id, ManagedHsmKeyOperationPredicate{}) -} - -// ListVersionsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ManagedHsmKeysClient) ListVersionsCompleteMatchingPredicate(ctx context.Context, id KeyId, predicate ManagedHsmKeyOperationPredicate) (resp ListVersionsCompleteResult, err error) { - items := make([]ManagedHsmKey, 0) - - page, err := c.ListVersions(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListVersionsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsmkeys/model_managedhsmaction.go b/resource-manager/keyvault/2022-11-01/managedhsmkeys/model_managedhsmaction.go deleted file mode 100644 index bd63ab71bf5..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsmkeys/model_managedhsmaction.go +++ /dev/null @@ -1,8 +0,0 @@ -package managedhsmkeys - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ManagedHsmAction struct { - Type *KeyRotationPolicyActionType `json:"type,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsmkeys/model_managedhsmkey.go b/resource-manager/keyvault/2022-11-01/managedhsmkeys/model_managedhsmkey.go deleted file mode 100644 index faaabece070..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsmkeys/model_managedhsmkey.go +++ /dev/null @@ -1,12 +0,0 @@ -package managedhsmkeys - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ManagedHsmKey struct { - Id *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Properties ManagedHsmKeyProperties `json:"properties"` - Tags *map[string]string `json:"tags,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsmkeys/model_managedhsmkeyattributes.go b/resource-manager/keyvault/2022-11-01/managedhsmkeys/model_managedhsmkeyattributes.go deleted file mode 100644 index 4fc2ca3827f..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsmkeys/model_managedhsmkeyattributes.go +++ /dev/null @@ -1,14 +0,0 @@ -package managedhsmkeys - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ManagedHsmKeyAttributes struct { - Created *int64 `json:"created,omitempty"` - Enabled *bool `json:"enabled,omitempty"` - Exp *int64 `json:"exp,omitempty"` - Exportable *bool `json:"exportable,omitempty"` - Nbf *int64 `json:"nbf,omitempty"` - RecoveryLevel *DeletionRecoveryLevel `json:"recoveryLevel,omitempty"` - Updated *int64 `json:"updated,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsmkeys/model_managedhsmkeycreateparameters.go b/resource-manager/keyvault/2022-11-01/managedhsmkeys/model_managedhsmkeycreateparameters.go deleted file mode 100644 index c0b466e274b..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsmkeys/model_managedhsmkeycreateparameters.go +++ /dev/null @@ -1,9 +0,0 @@ -package managedhsmkeys - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ManagedHsmKeyCreateParameters struct { - Properties ManagedHsmKeyProperties `json:"properties"` - Tags *map[string]string `json:"tags,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsmkeys/model_managedhsmkeyproperties.go b/resource-manager/keyvault/2022-11-01/managedhsmkeys/model_managedhsmkeyproperties.go deleted file mode 100644 index f2401d5e9ae..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsmkeys/model_managedhsmkeyproperties.go +++ /dev/null @@ -1,16 +0,0 @@ -package managedhsmkeys - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ManagedHsmKeyProperties struct { - Attributes *ManagedHsmKeyAttributes `json:"attributes,omitempty"` - CurveName *JsonWebKeyCurveName `json:"curveName,omitempty"` - KeyOps *[]JsonWebKeyOperation `json:"keyOps,omitempty"` - KeySize *int64 `json:"keySize,omitempty"` - KeyUri *string `json:"keyUri,omitempty"` - KeyUriWithVersion *string `json:"keyUriWithVersion,omitempty"` - Kty *JsonWebKeyType `json:"kty,omitempty"` - ReleasePolicy *ManagedHsmKeyReleasePolicy `json:"release_policy,omitempty"` - RotationPolicy *ManagedHsmRotationPolicy `json:"rotationPolicy,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsmkeys/model_managedhsmkeyreleasepolicy.go b/resource-manager/keyvault/2022-11-01/managedhsmkeys/model_managedhsmkeyreleasepolicy.go deleted file mode 100644 index 11bf1ae9935..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsmkeys/model_managedhsmkeyreleasepolicy.go +++ /dev/null @@ -1,9 +0,0 @@ -package managedhsmkeys - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ManagedHsmKeyReleasePolicy struct { - ContentType *string `json:"contentType,omitempty"` - Data *string `json:"data,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsmkeys/model_managedhsmkeyrotationpolicyattributes.go b/resource-manager/keyvault/2022-11-01/managedhsmkeys/model_managedhsmkeyrotationpolicyattributes.go deleted file mode 100644 index 4b6109ab2f9..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsmkeys/model_managedhsmkeyrotationpolicyattributes.go +++ /dev/null @@ -1,10 +0,0 @@ -package managedhsmkeys - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ManagedHsmKeyRotationPolicyAttributes struct { - Created *int64 `json:"created,omitempty"` - ExpiryTime *string `json:"expiryTime,omitempty"` - Updated *int64 `json:"updated,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsmkeys/model_managedhsmlifetimeaction.go b/resource-manager/keyvault/2022-11-01/managedhsmkeys/model_managedhsmlifetimeaction.go deleted file mode 100644 index 030b340464b..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsmkeys/model_managedhsmlifetimeaction.go +++ /dev/null @@ -1,9 +0,0 @@ -package managedhsmkeys - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ManagedHsmLifetimeAction struct { - Action *ManagedHsmAction `json:"action,omitempty"` - Trigger *ManagedHsmTrigger `json:"trigger,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsmkeys/model_managedhsmrotationpolicy.go b/resource-manager/keyvault/2022-11-01/managedhsmkeys/model_managedhsmrotationpolicy.go deleted file mode 100644 index a45f7da6869..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsmkeys/model_managedhsmrotationpolicy.go +++ /dev/null @@ -1,9 +0,0 @@ -package managedhsmkeys - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ManagedHsmRotationPolicy struct { - Attributes *ManagedHsmKeyRotationPolicyAttributes `json:"attributes,omitempty"` - LifetimeActions *[]ManagedHsmLifetimeAction `json:"lifetimeActions,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsmkeys/model_managedhsmtrigger.go b/resource-manager/keyvault/2022-11-01/managedhsmkeys/model_managedhsmtrigger.go deleted file mode 100644 index a2783185ade..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsmkeys/model_managedhsmtrigger.go +++ /dev/null @@ -1,9 +0,0 @@ -package managedhsmkeys - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ManagedHsmTrigger struct { - TimeAfterCreate *string `json:"timeAfterCreate,omitempty"` - TimeBeforeExpiry *string `json:"timeBeforeExpiry,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsmkeys/predicates.go b/resource-manager/keyvault/2022-11-01/managedhsmkeys/predicates.go deleted file mode 100644 index ed22e02a4b0..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsmkeys/predicates.go +++ /dev/null @@ -1,27 +0,0 @@ -package managedhsmkeys - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ManagedHsmKeyOperationPredicate struct { - Id *string - Name *string - Type *string -} - -func (p ManagedHsmKeyOperationPredicate) Matches(input ManagedHsmKey) 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/keyvault/2022-11-01/managedhsmkeys/version.go b/resource-manager/keyvault/2022-11-01/managedhsmkeys/version.go deleted file mode 100644 index ce7367101fe..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsmkeys/version.go +++ /dev/null @@ -1,12 +0,0 @@ -package managedhsmkeys - -import "fmt" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -const defaultApiVersion = "2022-11-01" - -func userAgent() string { - return fmt.Sprintf("hashicorp/go-azure-sdk/managedhsmkeys/%s", defaultApiVersion) -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsms/README.md b/resource-manager/keyvault/2022-11-01/managedhsms/README.md deleted file mode 100644 index b091e697c5d..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsms/README.md +++ /dev/null @@ -1,182 +0,0 @@ - -## `github.com/hashicorp/go-azure-sdk/resource-manager/keyvault/2022-11-01/managedhsms` Documentation - -The `managedhsms` SDK allows for interaction with the Azure Resource Manager Service `keyvault` (API Version `2022-11-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/keyvault/2022-11-01/managedhsms" -``` - - -### Client Initialization - -```go -client := managedhsms.NewManagedHsmsClientWithBaseURI("https://management.azure.com") -client.Client.Authorizer = authorizer -``` - - -### Example Usage: `ManagedHsmsClient.CheckMhsmNameAvailability` - -```go -ctx := context.TODO() -id := managedhsms.NewSubscriptionID("12345678-1234-9876-4563-123456789012") - -payload := managedhsms.CheckMhsmNameAvailabilityParameters{ - // ... -} - - -read, err := client.CheckMhsmNameAvailability(ctx, id, payload) -if err != nil { - // handle the error -} -if model := read.Model; model != nil { - // do something with the model/response object -} -``` - - -### Example Usage: `ManagedHsmsClient.CreateOrUpdate` - -```go -ctx := context.TODO() -id := managedhsms.NewManagedHSMID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedHSMValue") - -payload := managedhsms.ManagedHsm{ - // ... -} - - -if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { - // handle the error -} -``` - - -### Example Usage: `ManagedHsmsClient.Delete` - -```go -ctx := context.TODO() -id := managedhsms.NewManagedHSMID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedHSMValue") - -if err := client.DeleteThenPoll(ctx, id); err != nil { - // handle the error -} -``` - - -### Example Usage: `ManagedHsmsClient.Get` - -```go -ctx := context.TODO() -id := managedhsms.NewManagedHSMID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedHSMValue") - -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: `ManagedHsmsClient.GetDeleted` - -```go -ctx := context.TODO() -id := managedhsms.NewDeletedManagedHSMID("12345678-1234-9876-4563-123456789012", "locationValue", "deletedManagedHSMValue") - -read, err := client.GetDeleted(ctx, id) -if err != nil { - // handle the error -} -if model := read.Model; model != nil { - // do something with the model/response object -} -``` - - -### Example Usage: `ManagedHsmsClient.ListByResourceGroup` - -```go -ctx := context.TODO() -id := managedhsms.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") - -// alternatively `client.ListByResourceGroup(ctx, id, managedhsms.DefaultListByResourceGroupOperationOptions())` can be used to do batched pagination -items, err := client.ListByResourceGroupComplete(ctx, id, managedhsms.DefaultListByResourceGroupOperationOptions()) -if err != nil { - // handle the error -} -for _, item := range items { - // do something -} -``` - - -### Example Usage: `ManagedHsmsClient.ListBySubscription` - -```go -ctx := context.TODO() -id := managedhsms.NewSubscriptionID("12345678-1234-9876-4563-123456789012") - -// alternatively `client.ListBySubscription(ctx, id, managedhsms.DefaultListBySubscriptionOperationOptions())` can be used to do batched pagination -items, err := client.ListBySubscriptionComplete(ctx, id, managedhsms.DefaultListBySubscriptionOperationOptions()) -if err != nil { - // handle the error -} -for _, item := range items { - // do something -} -``` - - -### Example Usage: `ManagedHsmsClient.ListDeleted` - -```go -ctx := context.TODO() -id := managedhsms.NewSubscriptionID("12345678-1234-9876-4563-123456789012") - -// alternatively `client.ListDeleted(ctx, id)` can be used to do batched pagination -items, err := client.ListDeletedComplete(ctx, id) -if err != nil { - // handle the error -} -for _, item := range items { - // do something -} -``` - - -### Example Usage: `ManagedHsmsClient.PurgeDeleted` - -```go -ctx := context.TODO() -id := managedhsms.NewDeletedManagedHSMID("12345678-1234-9876-4563-123456789012", "locationValue", "deletedManagedHSMValue") - -if err := client.PurgeDeletedThenPoll(ctx, id); err != nil { - // handle the error -} -``` - - -### Example Usage: `ManagedHsmsClient.Update` - -```go -ctx := context.TODO() -id := managedhsms.NewManagedHSMID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedHSMValue") - -payload := managedhsms.ManagedHsm{ - // ... -} - - -if err := client.UpdateThenPoll(ctx, id, payload); err != nil { - // handle the error -} -``` diff --git a/resource-manager/keyvault/2022-11-01/managedhsms/client.go b/resource-manager/keyvault/2022-11-01/managedhsms/client.go deleted file mode 100644 index 3063f136888..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsms/client.go +++ /dev/null @@ -1,18 +0,0 @@ -package managedhsms - -import "github.com/Azure/go-autorest/autorest" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ManagedHsmsClient struct { - Client autorest.Client - baseUri string -} - -func NewManagedHsmsClientWithBaseURI(endpoint string) ManagedHsmsClient { - return ManagedHsmsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsms/constants.go b/resource-manager/keyvault/2022-11-01/managedhsms/constants.go deleted file mode 100644 index 3a62ef19b2e..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsms/constants.go +++ /dev/null @@ -1,381 +0,0 @@ -package managedhsms - -import "strings" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ActionsRequired string - -const ( - ActionsRequiredNone ActionsRequired = "None" -) - -func PossibleValuesForActionsRequired() []string { - return []string{ - string(ActionsRequiredNone), - } -} - -func parseActionsRequired(input string) (*ActionsRequired, error) { - vals := map[string]ActionsRequired{ - "none": ActionsRequiredNone, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ActionsRequired(input) - return &out, nil -} - -type ActivationStatus string - -const ( - ActivationStatusActive ActivationStatus = "Active" - ActivationStatusFailed ActivationStatus = "Failed" - ActivationStatusNotActivated ActivationStatus = "NotActivated" - ActivationStatusUnknown ActivationStatus = "Unknown" -) - -func PossibleValuesForActivationStatus() []string { - return []string{ - string(ActivationStatusActive), - string(ActivationStatusFailed), - string(ActivationStatusNotActivated), - string(ActivationStatusUnknown), - } -} - -func parseActivationStatus(input string) (*ActivationStatus, error) { - vals := map[string]ActivationStatus{ - "active": ActivationStatusActive, - "failed": ActivationStatusFailed, - "notactivated": ActivationStatusNotActivated, - "unknown": ActivationStatusUnknown, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ActivationStatus(input) - return &out, nil -} - -type CreateMode string - -const ( - CreateModeDefault CreateMode = "default" - CreateModeRecover CreateMode = "recover" -) - -func PossibleValuesForCreateMode() []string { - return []string{ - string(CreateModeDefault), - string(CreateModeRecover), - } -} - -func parseCreateMode(input string) (*CreateMode, error) { - vals := map[string]CreateMode{ - "default": CreateModeDefault, - "recover": CreateModeRecover, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := CreateMode(input) - return &out, nil -} - -type ManagedHsmSkuFamily string - -const ( - ManagedHsmSkuFamilyB ManagedHsmSkuFamily = "B" -) - -func PossibleValuesForManagedHsmSkuFamily() []string { - return []string{ - string(ManagedHsmSkuFamilyB), - } -} - -func parseManagedHsmSkuFamily(input string) (*ManagedHsmSkuFamily, error) { - vals := map[string]ManagedHsmSkuFamily{ - "b": ManagedHsmSkuFamilyB, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ManagedHsmSkuFamily(input) - return &out, nil -} - -type ManagedHsmSkuName string - -const ( - ManagedHsmSkuNameCustomBSix ManagedHsmSkuName = "Custom_B6" - ManagedHsmSkuNameCustomBThreeTwo ManagedHsmSkuName = "Custom_B32" - ManagedHsmSkuNameStandardBOne ManagedHsmSkuName = "Standard_B1" -) - -func PossibleValuesForManagedHsmSkuName() []string { - return []string{ - string(ManagedHsmSkuNameCustomBSix), - string(ManagedHsmSkuNameCustomBThreeTwo), - string(ManagedHsmSkuNameStandardBOne), - } -} - -func parseManagedHsmSkuName(input string) (*ManagedHsmSkuName, error) { - vals := map[string]ManagedHsmSkuName{ - "custom_b6": ManagedHsmSkuNameCustomBSix, - "custom_b32": ManagedHsmSkuNameCustomBThreeTwo, - "standard_b1": ManagedHsmSkuNameStandardBOne, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ManagedHsmSkuName(input) - return &out, nil -} - -type NetworkRuleAction string - -const ( - NetworkRuleActionAllow NetworkRuleAction = "Allow" - NetworkRuleActionDeny NetworkRuleAction = "Deny" -) - -func PossibleValuesForNetworkRuleAction() []string { - return []string{ - string(NetworkRuleActionAllow), - string(NetworkRuleActionDeny), - } -} - -func parseNetworkRuleAction(input string) (*NetworkRuleAction, error) { - vals := map[string]NetworkRuleAction{ - "allow": NetworkRuleActionAllow, - "deny": NetworkRuleActionDeny, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := NetworkRuleAction(input) - return &out, nil -} - -type NetworkRuleBypassOptions string - -const ( - NetworkRuleBypassOptionsAzureServices NetworkRuleBypassOptions = "AzureServices" - NetworkRuleBypassOptionsNone NetworkRuleBypassOptions = "None" -) - -func PossibleValuesForNetworkRuleBypassOptions() []string { - return []string{ - string(NetworkRuleBypassOptionsAzureServices), - string(NetworkRuleBypassOptionsNone), - } -} - -func parseNetworkRuleBypassOptions(input string) (*NetworkRuleBypassOptions, error) { - vals := map[string]NetworkRuleBypassOptions{ - "azureservices": NetworkRuleBypassOptionsAzureServices, - "none": NetworkRuleBypassOptionsNone, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := NetworkRuleBypassOptions(input) - return &out, nil -} - -type PrivateEndpointConnectionProvisioningState string - -const ( - PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" - PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" - PrivateEndpointConnectionProvisioningStateDisconnected PrivateEndpointConnectionProvisioningState = "Disconnected" - PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" - PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" - PrivateEndpointConnectionProvisioningStateUpdating PrivateEndpointConnectionProvisioningState = "Updating" -) - -func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { - return []string{ - string(PrivateEndpointConnectionProvisioningStateCreating), - string(PrivateEndpointConnectionProvisioningStateDeleting), - string(PrivateEndpointConnectionProvisioningStateDisconnected), - string(PrivateEndpointConnectionProvisioningStateFailed), - string(PrivateEndpointConnectionProvisioningStateSucceeded), - string(PrivateEndpointConnectionProvisioningStateUpdating), - } -} - -func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { - vals := map[string]PrivateEndpointConnectionProvisioningState{ - "creating": PrivateEndpointConnectionProvisioningStateCreating, - "deleting": PrivateEndpointConnectionProvisioningStateDeleting, - "disconnected": PrivateEndpointConnectionProvisioningStateDisconnected, - "failed": PrivateEndpointConnectionProvisioningStateFailed, - "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, - "updating": PrivateEndpointConnectionProvisioningStateUpdating, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := PrivateEndpointConnectionProvisioningState(input) - return &out, nil -} - -type PrivateEndpointServiceConnectionStatus string - -const ( - PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" - PrivateEndpointServiceConnectionStatusDisconnected PrivateEndpointServiceConnectionStatus = "Disconnected" - PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" - PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" -) - -func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { - return []string{ - string(PrivateEndpointServiceConnectionStatusApproved), - string(PrivateEndpointServiceConnectionStatusDisconnected), - string(PrivateEndpointServiceConnectionStatusPending), - string(PrivateEndpointServiceConnectionStatusRejected), - } -} - -func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { - vals := map[string]PrivateEndpointServiceConnectionStatus{ - "approved": PrivateEndpointServiceConnectionStatusApproved, - "disconnected": PrivateEndpointServiceConnectionStatusDisconnected, - "pending": PrivateEndpointServiceConnectionStatusPending, - "rejected": PrivateEndpointServiceConnectionStatusRejected, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := PrivateEndpointServiceConnectionStatus(input) - return &out, nil -} - -type ProvisioningState string - -const ( - ProvisioningStateActivated ProvisioningState = "Activated" - ProvisioningStateDeleting ProvisioningState = "Deleting" - ProvisioningStateFailed ProvisioningState = "Failed" - ProvisioningStateProvisioning ProvisioningState = "Provisioning" - ProvisioningStateRestoring ProvisioningState = "Restoring" - ProvisioningStateSecurityDomainRestore ProvisioningState = "SecurityDomainRestore" - ProvisioningStateSucceeded ProvisioningState = "Succeeded" - ProvisioningStateUpdating ProvisioningState = "Updating" -) - -func PossibleValuesForProvisioningState() []string { - return []string{ - string(ProvisioningStateActivated), - string(ProvisioningStateDeleting), - string(ProvisioningStateFailed), - string(ProvisioningStateProvisioning), - string(ProvisioningStateRestoring), - string(ProvisioningStateSecurityDomainRestore), - string(ProvisioningStateSucceeded), - string(ProvisioningStateUpdating), - } -} - -func parseProvisioningState(input string) (*ProvisioningState, error) { - vals := map[string]ProvisioningState{ - "activated": ProvisioningStateActivated, - "deleting": ProvisioningStateDeleting, - "failed": ProvisioningStateFailed, - "provisioning": ProvisioningStateProvisioning, - "restoring": ProvisioningStateRestoring, - "securitydomainrestore": ProvisioningStateSecurityDomainRestore, - "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 PublicNetworkAccess string - -const ( - PublicNetworkAccessDisabled PublicNetworkAccess = "Disabled" - PublicNetworkAccessEnabled PublicNetworkAccess = "Enabled" -) - -func PossibleValuesForPublicNetworkAccess() []string { - return []string{ - string(PublicNetworkAccessDisabled), - string(PublicNetworkAccessEnabled), - } -} - -func parsePublicNetworkAccess(input string) (*PublicNetworkAccess, error) { - vals := map[string]PublicNetworkAccess{ - "disabled": PublicNetworkAccessDisabled, - "enabled": PublicNetworkAccessEnabled, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := PublicNetworkAccess(input) - return &out, nil -} - -type Reason string - -const ( - ReasonAccountNameInvalid Reason = "AccountNameInvalid" - ReasonAlreadyExists Reason = "AlreadyExists" -) - -func PossibleValuesForReason() []string { - return []string{ - string(ReasonAccountNameInvalid), - string(ReasonAlreadyExists), - } -} - -func parseReason(input string) (*Reason, error) { - vals := map[string]Reason{ - "accountnameinvalid": ReasonAccountNameInvalid, - "alreadyexists": ReasonAlreadyExists, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := Reason(input) - return &out, nil -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsms/id_deletedmanagedhsm.go b/resource-manager/keyvault/2022-11-01/managedhsms/id_deletedmanagedhsm.go deleted file mode 100644 index 6e8a2447888..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsms/id_deletedmanagedhsm.go +++ /dev/null @@ -1,125 +0,0 @@ -package managedhsms - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -var _ resourceids.ResourceId = &DeletedManagedHSMId{} - -// DeletedManagedHSMId is a struct representing the Resource ID for a Deleted Managed H S M -type DeletedManagedHSMId struct { - SubscriptionId string - LocationName string - DeletedManagedHSMName string -} - -// NewDeletedManagedHSMID returns a new DeletedManagedHSMId struct -func NewDeletedManagedHSMID(subscriptionId string, locationName string, deletedManagedHSMName string) DeletedManagedHSMId { - return DeletedManagedHSMId{ - SubscriptionId: subscriptionId, - LocationName: locationName, - DeletedManagedHSMName: deletedManagedHSMName, - } -} - -// ParseDeletedManagedHSMID parses 'input' into a DeletedManagedHSMId -func ParseDeletedManagedHSMID(input string) (*DeletedManagedHSMId, error) { - parser := resourceids.NewParserFromResourceIdType(&DeletedManagedHSMId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := DeletedManagedHSMId{} - if err := id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -// ParseDeletedManagedHSMIDInsensitively parses 'input' case-insensitively into a DeletedManagedHSMId -// note: this method should only be used for API response data and not user input -func ParseDeletedManagedHSMIDInsensitively(input string) (*DeletedManagedHSMId, error) { - parser := resourceids.NewParserFromResourceIdType(&DeletedManagedHSMId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := DeletedManagedHSMId{} - if err := id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -func (id *DeletedManagedHSMId) FromParseResult(input resourceids.ParseResult) error { - var ok bool - - if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) - } - - if id.LocationName, ok = input.Parsed["locationName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) - } - - if id.DeletedManagedHSMName, ok = input.Parsed["deletedManagedHSMName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "deletedManagedHSMName", input) - } - - return nil -} - -// ValidateDeletedManagedHSMID checks that 'input' can be parsed as a Deleted Managed H S M ID -func ValidateDeletedManagedHSMID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParseDeletedManagedHSMID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Deleted Managed H S M ID -func (id DeletedManagedHSMId) ID() string { - fmtString := "/subscriptions/%s/providers/Microsoft.KeyVault/locations/%s/deletedManagedHSMs/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName, id.DeletedManagedHSMName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Deleted Managed H S M ID -func (id DeletedManagedHSMId) 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("staticMicrosoftKeyVault", "Microsoft.KeyVault", "Microsoft.KeyVault"), - resourceids.StaticSegment("staticLocations", "locations", "locations"), - resourceids.UserSpecifiedSegment("locationName", "locationValue"), - resourceids.StaticSegment("staticDeletedManagedHSMs", "deletedManagedHSMs", "deletedManagedHSMs"), - resourceids.UserSpecifiedSegment("deletedManagedHSMName", "deletedManagedHSMValue"), - } -} - -// String returns a human-readable description of this Deleted Managed H S M ID -func (id DeletedManagedHSMId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Location Name: %q", id.LocationName), - fmt.Sprintf("Deleted Managed H S M Name: %q", id.DeletedManagedHSMName), - } - return fmt.Sprintf("Deleted Managed H S M (%s)", strings.Join(components, "\n")) -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsms/id_deletedmanagedhsm_test.go b/resource-manager/keyvault/2022-11-01/managedhsms/id_deletedmanagedhsm_test.go deleted file mode 100644 index 6657b964ef1..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsms/id_deletedmanagedhsm_test.go +++ /dev/null @@ -1,282 +0,0 @@ -package managedhsms - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -var _ resourceids.ResourceId = &DeletedManagedHSMId{} - -func TestNewDeletedManagedHSMID(t *testing.T) { - id := NewDeletedManagedHSMID("12345678-1234-9876-4563-123456789012", "locationValue", "deletedManagedHSMValue") - - if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { - t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") - } - - if id.LocationName != "locationValue" { - t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationValue") - } - - if id.DeletedManagedHSMName != "deletedManagedHSMValue" { - t.Fatalf("Expected %q but got %q for Segment 'DeletedManagedHSMName'", id.DeletedManagedHSMName, "deletedManagedHSMValue") - } -} - -func TestFormatDeletedManagedHSMID(t *testing.T) { - actual := NewDeletedManagedHSMID("12345678-1234-9876-4563-123456789012", "locationValue", "deletedManagedHSMValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.KeyVault/locations/locationValue/deletedManagedHSMs/deletedManagedHSMValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseDeletedManagedHSMID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *DeletedManagedHSMId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - 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.KeyVault", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.KeyVault/locations", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.KeyVault/locations/locationValue", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.KeyVault/locations/locationValue/deletedManagedHSMs", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.KeyVault/locations/locationValue/deletedManagedHSMs/deletedManagedHSMValue", - Expected: &DeletedManagedHSMId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - LocationName: "locationValue", - DeletedManagedHSMName: "deletedManagedHSMValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.KeyVault/locations/locationValue/deletedManagedHSMs/deletedManagedHSMValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseDeletedManagedHSMID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.LocationName != v.Expected.LocationName { - t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) - } - - if actual.DeletedManagedHSMName != v.Expected.DeletedManagedHSMName { - t.Fatalf("Expected %q but got %q for DeletedManagedHSMName", v.Expected.DeletedManagedHSMName, actual.DeletedManagedHSMName) - } - - } -} - -func TestParseDeletedManagedHSMIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *DeletedManagedHSMId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI (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.KeyVault", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.kEyVaUlT", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.KeyVault/locations", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.kEyVaUlT/lOcAtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.KeyVault/locations/locationValue", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.kEyVaUlT/lOcAtIoNs/lOcAtIoNvAlUe", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.KeyVault/locations/locationValue/deletedManagedHSMs", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.kEyVaUlT/lOcAtIoNs/lOcAtIoNvAlUe/dElEtEdMaNaGeDhSmS", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.KeyVault/locations/locationValue/deletedManagedHSMs/deletedManagedHSMValue", - Expected: &DeletedManagedHSMId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - LocationName: "locationValue", - DeletedManagedHSMName: "deletedManagedHSMValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.KeyVault/locations/locationValue/deletedManagedHSMs/deletedManagedHSMValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.kEyVaUlT/lOcAtIoNs/lOcAtIoNvAlUe/dElEtEdMaNaGeDhSmS/dElEtEdMaNaGeDhSmVaLuE", - Expected: &DeletedManagedHSMId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - LocationName: "lOcAtIoNvAlUe", - DeletedManagedHSMName: "dElEtEdMaNaGeDhSmVaLuE", - }, - }, - { - // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.kEyVaUlT/lOcAtIoNs/lOcAtIoNvAlUe/dElEtEdMaNaGeDhSmS/dElEtEdMaNaGeDhSmVaLuE/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseDeletedManagedHSMIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.LocationName != v.Expected.LocationName { - t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) - } - - if actual.DeletedManagedHSMName != v.Expected.DeletedManagedHSMName { - t.Fatalf("Expected %q but got %q for DeletedManagedHSMName", v.Expected.DeletedManagedHSMName, actual.DeletedManagedHSMName) - } - - } -} - -func TestSegmentsForDeletedManagedHSMId(t *testing.T) { - segments := DeletedManagedHSMId{}.Segments() - if len(segments) == 0 { - t.Fatalf("DeletedManagedHSMId has no segments") - } - - uniqueNames := make(map[string]struct{}, 0) - for _, segment := range segments { - uniqueNames[segment.Name] = struct{}{} - } - if len(uniqueNames) != len(segments) { - t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) - } -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsms/id_managedhsm.go b/resource-manager/keyvault/2022-11-01/managedhsms/id_managedhsm.go deleted file mode 100644 index b317e14bc06..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsms/id_managedhsm.go +++ /dev/null @@ -1,125 +0,0 @@ -package managedhsms - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -var _ resourceids.ResourceId = &ManagedHSMId{} - -// ManagedHSMId is a struct representing the Resource ID for a Managed H S M -type ManagedHSMId struct { - SubscriptionId string - ResourceGroupName string - ManagedHSMName string -} - -// NewManagedHSMID returns a new ManagedHSMId struct -func NewManagedHSMID(subscriptionId string, resourceGroupName string, managedHSMName string) ManagedHSMId { - return ManagedHSMId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - ManagedHSMName: managedHSMName, - } -} - -// ParseManagedHSMID parses 'input' into a ManagedHSMId -func ParseManagedHSMID(input string) (*ManagedHSMId, error) { - parser := resourceids.NewParserFromResourceIdType(&ManagedHSMId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := ManagedHSMId{} - if err := id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -// ParseManagedHSMIDInsensitively parses 'input' case-insensitively into a ManagedHSMId -// note: this method should only be used for API response data and not user input -func ParseManagedHSMIDInsensitively(input string) (*ManagedHSMId, error) { - parser := resourceids.NewParserFromResourceIdType(&ManagedHSMId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := ManagedHSMId{} - if err := id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -func (id *ManagedHSMId) FromParseResult(input resourceids.ParseResult) error { - var ok bool - - if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) - } - - if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) - } - - if id.ManagedHSMName, ok = input.Parsed["managedHSMName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "managedHSMName", input) - } - - return nil -} - -// ValidateManagedHSMID checks that 'input' can be parsed as a Managed H S M ID -func ValidateManagedHSMID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParseManagedHSMID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Managed H S M ID -func (id ManagedHSMId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.KeyVault/managedHSMs/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedHSMName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Managed H S M ID -func (id ManagedHSMId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftKeyVault", "Microsoft.KeyVault", "Microsoft.KeyVault"), - resourceids.StaticSegment("staticManagedHSMs", "managedHSMs", "managedHSMs"), - resourceids.UserSpecifiedSegment("managedHSMName", "managedHSMValue"), - } -} - -// String returns a human-readable description of this Managed H S M ID -func (id ManagedHSMId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Managed H S M Name: %q", id.ManagedHSMName), - } - return fmt.Sprintf("Managed H S M (%s)", strings.Join(components, "\n")) -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsms/id_managedhsm_test.go b/resource-manager/keyvault/2022-11-01/managedhsms/id_managedhsm_test.go deleted file mode 100644 index dfb23a201b7..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsms/id_managedhsm_test.go +++ /dev/null @@ -1,282 +0,0 @@ -package managedhsms - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -var _ resourceids.ResourceId = &ManagedHSMId{} - -func TestNewManagedHSMID(t *testing.T) { - id := NewManagedHSMID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedHSMValue") - - if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { - t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") - } - - if id.ResourceGroupName != "example-resource-group" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") - } - - if id.ManagedHSMName != "managedHSMValue" { - t.Fatalf("Expected %q but got %q for Segment 'ManagedHSMName'", id.ManagedHSMName, "managedHSMValue") - } -} - -func TestFormatManagedHSMID(t *testing.T) { - actual := NewManagedHSMID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedHSMValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseManagedHSMID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *ManagedHSMId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue", - Expected: &ManagedHSMId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ManagedHSMName: "managedHSMValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseManagedHSMID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.ManagedHSMName != v.Expected.ManagedHSMName { - t.Fatalf("Expected %q but got %q for ManagedHSMName", v.Expected.ManagedHSMName, actual.ManagedHSMName) - } - - } -} - -func TestParseManagedHSMIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *ManagedHSMId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/mAnAgEdHsMs", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue", - Expected: &ManagedHSMId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ManagedHSMName: "managedHSMValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/mAnAgEdHsMs/mAnAgEdHsMvAlUe", - Expected: &ManagedHSMId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - ManagedHSMName: "mAnAgEdHsMvAlUe", - }, - }, - { - // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/mAnAgEdHsMs/mAnAgEdHsMvAlUe/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseManagedHSMIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.ManagedHSMName != v.Expected.ManagedHSMName { - t.Fatalf("Expected %q but got %q for ManagedHSMName", v.Expected.ManagedHSMName, actual.ManagedHSMName) - } - - } -} - -func TestSegmentsForManagedHSMId(t *testing.T) { - segments := ManagedHSMId{}.Segments() - if len(segments) == 0 { - t.Fatalf("ManagedHSMId has no segments") - } - - uniqueNames := make(map[string]struct{}, 0) - for _, segment := range segments { - uniqueNames[segment.Name] = struct{}{} - } - if len(uniqueNames) != len(segments) { - t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) - } -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsms/method_checkmhsmnameavailability_autorest.go b/resource-manager/keyvault/2022-11-01/managedhsms/method_checkmhsmnameavailability_autorest.go deleted file mode 100644 index 1d6648210eb..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsms/method_checkmhsmnameavailability_autorest.go +++ /dev/null @@ -1,71 +0,0 @@ -package managedhsms - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CheckMhsmNameAvailabilityOperationResponse struct { - HttpResponse *http.Response - Model *CheckMhsmNameAvailabilityResult -} - -// CheckMhsmNameAvailability ... -func (c ManagedHsmsClient) CheckMhsmNameAvailability(ctx context.Context, id commonids.SubscriptionId, input CheckMhsmNameAvailabilityParameters) (result CheckMhsmNameAvailabilityOperationResponse, err error) { - req, err := c.preparerForCheckMhsmNameAvailability(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "CheckMhsmNameAvailability", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "CheckMhsmNameAvailability", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCheckMhsmNameAvailability(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "CheckMhsmNameAvailability", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCheckMhsmNameAvailability prepares the CheckMhsmNameAvailability request. -func (c ManagedHsmsClient) preparerForCheckMhsmNameAvailability(ctx context.Context, id commonids.SubscriptionId, input CheckMhsmNameAvailabilityParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.KeyVault/checkMhsmNameAvailability", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCheckMhsmNameAvailability handles the response to the CheckMhsmNameAvailability request. The method always -// closes the http.Response Body. -func (c ManagedHsmsClient) responderForCheckMhsmNameAvailability(resp *http.Response) (result CheckMhsmNameAvailabilityOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsms/method_createorupdate_autorest.go b/resource-manager/keyvault/2022-11-01/managedhsms/method_createorupdate_autorest.go deleted file mode 100644 index 13ea1b5b54e..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsms/method_createorupdate_autorest.go +++ /dev/null @@ -1,80 +0,0 @@ -package managedhsms - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response - Model *ManagedHsm -} - -// CreateOrUpdate ... -func (c ManagedHsmsClient) CreateOrUpdate(ctx context.Context, id ManagedHSMId, input ManagedHsm) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c ManagedHsmsClient) CreateOrUpdateThenPoll(ctx context.Context, id ManagedHSMId, input ManagedHsm) error { - result, err := c.CreateOrUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c ManagedHsmsClient) preparerForCreateOrUpdate(ctx context.Context, id ManagedHSMId, input ManagedHsm) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c ManagedHsmsClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsms/method_delete_autorest.go b/resource-manager/keyvault/2022-11-01/managedhsms/method_delete_autorest.go deleted file mode 100644 index 56fa4634de5..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsms/method_delete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package managedhsms - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Delete ... -func (c ManagedHsmsClient) Delete(ctx context.Context, id ManagedHSMId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c ManagedHsmsClient) DeleteThenPoll(ctx context.Context, id ManagedHSMId) error { - result, err := c.Delete(ctx, id) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} - -// preparerForDelete prepares the Delete request. -func (c ManagedHsmsClient) preparerForDelete(ctx context.Context, id ManagedHSMId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDelete sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (c ManagedHsmsClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsms/method_get_autorest.go b/resource-manager/keyvault/2022-11-01/managedhsms/method_get_autorest.go deleted file mode 100644 index 827011f2ea0..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsms/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package managedhsms - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *ManagedHsm -} - -// Get ... -func (c ManagedHsmsClient) Get(ctx context.Context, id ManagedHSMId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ManagedHsmsClient) preparerForGet(ctx context.Context, id ManagedHSMId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c ManagedHsmsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsms/method_getdeleted_autorest.go b/resource-manager/keyvault/2022-11-01/managedhsms/method_getdeleted_autorest.go deleted file mode 100644 index ad43ab79e1b..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsms/method_getdeleted_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package managedhsms - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetDeletedOperationResponse struct { - HttpResponse *http.Response - Model *DeletedManagedHsm -} - -// GetDeleted ... -func (c ManagedHsmsClient) GetDeleted(ctx context.Context, id DeletedManagedHSMId) (result GetDeletedOperationResponse, err error) { - req, err := c.preparerForGetDeleted(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "GetDeleted", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "GetDeleted", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetDeleted(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "GetDeleted", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetDeleted prepares the GetDeleted request. -func (c ManagedHsmsClient) preparerForGetDeleted(ctx context.Context, id DeletedManagedHSMId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetDeleted handles the response to the GetDeleted request. The method always -// closes the http.Response Body. -func (c ManagedHsmsClient) responderForGetDeleted(resp *http.Response) (result GetDeletedOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsms/method_listbyresourcegroup_autorest.go b/resource-manager/keyvault/2022-11-01/managedhsms/method_listbyresourcegroup_autorest.go deleted file mode 100644 index 941be9aa8ee..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsms/method_listbyresourcegroup_autorest.go +++ /dev/null @@ -1,216 +0,0 @@ -package managedhsms - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// 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 - Model *[]ManagedHsm - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByResourceGroupOperationResponse, error) -} - -type ListByResourceGroupCompleteResult struct { - Items []ManagedHsm -} - -func (r ListByResourceGroupOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByResourceGroupOperationResponse) LoadMore(ctx context.Context) (resp ListByResourceGroupOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByResourceGroupOperationOptions struct { - Top *int64 -} - -func DefaultListByResourceGroupOperationOptions() ListByResourceGroupOperationOptions { - return ListByResourceGroupOperationOptions{} -} - -func (o ListByResourceGroupOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByResourceGroupOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByResourceGroup ... -func (c ManagedHsmsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (resp ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroup(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListByResourceGroup", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByResourceGroup(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListByResourceGroup", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByResourceGroup prepares the ListByResourceGroup request. -func (c ManagedHsmsClient) preparerForListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.KeyVault/managedHSMs", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByResourceGroupWithNextLink prepares the ListByResourceGroup request with the given nextLink token. -func (c ManagedHsmsClient) preparerForListByResourceGroupWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByResourceGroup handles the response to the ListByResourceGroup request. The method always -// closes the http.Response Body. -func (c ManagedHsmsClient) responderForListByResourceGroup(resp *http.Response) (result ListByResourceGroupOperationResponse, err error) { - type page struct { - Values []ManagedHsm `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroupWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListByResourceGroup", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByResourceGroup(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListByResourceGroup", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByResourceGroupComplete retrieves all of the results into a single object -func (c ManagedHsmsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (ListByResourceGroupCompleteResult, error) { - return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, options, ManagedHsmOperationPredicate{}) -} - -// ListByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ManagedHsmsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions, predicate ManagedHsmOperationPredicate) (resp ListByResourceGroupCompleteResult, err error) { - items := make([]ManagedHsm, 0) - - page, err := c.ListByResourceGroup(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByResourceGroupCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsms/method_listbysubscription_autorest.go b/resource-manager/keyvault/2022-11-01/managedhsms/method_listbysubscription_autorest.go deleted file mode 100644 index fcf426e915e..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsms/method_listbysubscription_autorest.go +++ /dev/null @@ -1,216 +0,0 @@ -package managedhsms - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// 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 - Model *[]ManagedHsm - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListBySubscriptionOperationResponse, error) -} - -type ListBySubscriptionCompleteResult struct { - Items []ManagedHsm -} - -func (r ListBySubscriptionOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListBySubscriptionOperationResponse) LoadMore(ctx context.Context) (resp ListBySubscriptionOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListBySubscriptionOperationOptions struct { - Top *int64 -} - -func DefaultListBySubscriptionOperationOptions() ListBySubscriptionOperationOptions { - return ListBySubscriptionOperationOptions{} -} - -func (o ListBySubscriptionOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListBySubscriptionOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListBySubscription ... -func (c ManagedHsmsClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions) (resp ListBySubscriptionOperationResponse, err error) { - req, err := c.preparerForListBySubscription(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListBySubscription", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListBySubscription", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListBySubscription(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListBySubscription", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListBySubscription prepares the ListBySubscription request. -func (c ManagedHsmsClient) preparerForListBySubscription(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.KeyVault/managedHSMs", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListBySubscriptionWithNextLink prepares the ListBySubscription request with the given nextLink token. -func (c ManagedHsmsClient) preparerForListBySubscriptionWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListBySubscription handles the response to the ListBySubscription request. The method always -// closes the http.Response Body. -func (c ManagedHsmsClient) responderForListBySubscription(resp *http.Response) (result ListBySubscriptionOperationResponse, err error) { - type page struct { - Values []ManagedHsm `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListBySubscriptionOperationResponse, err error) { - req, err := c.preparerForListBySubscriptionWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListBySubscription", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListBySubscription", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListBySubscription(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListBySubscription", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListBySubscriptionComplete retrieves all of the results into a single object -func (c ManagedHsmsClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions) (ListBySubscriptionCompleteResult, error) { - return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, options, ManagedHsmOperationPredicate{}) -} - -// ListBySubscriptionCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ManagedHsmsClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions, predicate ManagedHsmOperationPredicate) (resp ListBySubscriptionCompleteResult, err error) { - items := make([]ManagedHsm, 0) - - page, err := c.ListBySubscription(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListBySubscriptionCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsms/method_listdeleted_autorest.go b/resource-manager/keyvault/2022-11-01/managedhsms/method_listdeleted_autorest.go deleted file mode 100644 index 72c2fcb6ecb..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsms/method_listdeleted_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package managedhsms - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListDeletedOperationResponse struct { - HttpResponse *http.Response - Model *[]DeletedManagedHsm - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListDeletedOperationResponse, error) -} - -type ListDeletedCompleteResult struct { - Items []DeletedManagedHsm -} - -func (r ListDeletedOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListDeletedOperationResponse) LoadMore(ctx context.Context) (resp ListDeletedOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListDeleted ... -func (c ManagedHsmsClient) ListDeleted(ctx context.Context, id commonids.SubscriptionId) (resp ListDeletedOperationResponse, err error) { - req, err := c.preparerForListDeleted(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListDeleted", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListDeleted", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListDeleted(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListDeleted", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListDeleted prepares the ListDeleted request. -func (c ManagedHsmsClient) preparerForListDeleted(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.KeyVault/deletedManagedHSMs", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListDeletedWithNextLink prepares the ListDeleted request with the given nextLink token. -func (c ManagedHsmsClient) preparerForListDeletedWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListDeleted handles the response to the ListDeleted request. The method always -// closes the http.Response Body. -func (c ManagedHsmsClient) responderForListDeleted(resp *http.Response) (result ListDeletedOperationResponse, err error) { - type page struct { - Values []DeletedManagedHsm `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListDeletedOperationResponse, err error) { - req, err := c.preparerForListDeletedWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListDeleted", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListDeleted", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListDeleted(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListDeleted", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListDeletedComplete retrieves all of the results into a single object -func (c ManagedHsmsClient) ListDeletedComplete(ctx context.Context, id commonids.SubscriptionId) (ListDeletedCompleteResult, error) { - return c.ListDeletedCompleteMatchingPredicate(ctx, id, DeletedManagedHsmOperationPredicate{}) -} - -// ListDeletedCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ManagedHsmsClient) ListDeletedCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate DeletedManagedHsmOperationPredicate) (resp ListDeletedCompleteResult, err error) { - items := make([]DeletedManagedHsm, 0) - - page, err := c.ListDeleted(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListDeletedCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsms/method_purgedeleted_autorest.go b/resource-manager/keyvault/2022-11-01/managedhsms/method_purgedeleted_autorest.go deleted file mode 100644 index 25a1e6e2654..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsms/method_purgedeleted_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package managedhsms - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PurgeDeletedOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// PurgeDeleted ... -func (c ManagedHsmsClient) PurgeDeleted(ctx context.Context, id DeletedManagedHSMId) (result PurgeDeletedOperationResponse, err error) { - req, err := c.preparerForPurgeDeleted(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "PurgeDeleted", nil, "Failure preparing request") - return - } - - result, err = c.senderForPurgeDeleted(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "PurgeDeleted", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// PurgeDeletedThenPoll performs PurgeDeleted then polls until it's completed -func (c ManagedHsmsClient) PurgeDeletedThenPoll(ctx context.Context, id DeletedManagedHSMId) error { - result, err := c.PurgeDeleted(ctx, id) - if err != nil { - return fmt.Errorf("performing PurgeDeleted: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after PurgeDeleted: %+v", err) - } - - return nil -} - -// preparerForPurgeDeleted prepares the PurgeDeleted request. -func (c ManagedHsmsClient) preparerForPurgeDeleted(ctx context.Context, id DeletedManagedHSMId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/purge", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForPurgeDeleted sends the PurgeDeleted request. The method will close the -// http.Response Body if it receives an error. -func (c ManagedHsmsClient) senderForPurgeDeleted(ctx context.Context, req *http.Request) (future PurgeDeletedOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsms/method_update_autorest.go b/resource-manager/keyvault/2022-11-01/managedhsms/method_update_autorest.go deleted file mode 100644 index f0ad60994ca..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsms/method_update_autorest.go +++ /dev/null @@ -1,80 +0,0 @@ -package managedhsms - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response - Model *ManagedHsm -} - -// Update ... -func (c ManagedHsmsClient) Update(ctx context.Context, id ManagedHSMId, input ManagedHsm) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "Update", nil, "Failure preparing request") - return - } - - result, err = c.senderForUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// UpdateThenPoll performs Update then polls until it's completed -func (c ManagedHsmsClient) UpdateThenPoll(ctx context.Context, id ManagedHSMId, input ManagedHsm) error { - result, err := c.Update(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Update: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Update: %+v", err) - } - - return nil -} - -// preparerForUpdate prepares the Update request. -func (c ManagedHsmsClient) preparerForUpdate(ctx context.Context, id ManagedHSMId, input ManagedHsm) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForUpdate sends the Update request. The method will close the -// http.Response Body if it receives an error. -func (c ManagedHsmsClient) senderForUpdate(ctx context.Context, req *http.Request) (future UpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsms/model_checkmhsmnameavailabilityparameters.go b/resource-manager/keyvault/2022-11-01/managedhsms/model_checkmhsmnameavailabilityparameters.go deleted file mode 100644 index a3d8ea5b0e2..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsms/model_checkmhsmnameavailabilityparameters.go +++ /dev/null @@ -1,8 +0,0 @@ -package managedhsms - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CheckMhsmNameAvailabilityParameters struct { - Name string `json:"name"` -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsms/model_checkmhsmnameavailabilityresult.go b/resource-manager/keyvault/2022-11-01/managedhsms/model_checkmhsmnameavailabilityresult.go deleted file mode 100644 index f8c2c2d2995..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsms/model_checkmhsmnameavailabilityresult.go +++ /dev/null @@ -1,10 +0,0 @@ -package managedhsms - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CheckMhsmNameAvailabilityResult struct { - Message *string `json:"message,omitempty"` - NameAvailable *bool `json:"nameAvailable,omitempty"` - Reason *Reason `json:"reason,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsms/model_deletedmanagedhsm.go b/resource-manager/keyvault/2022-11-01/managedhsms/model_deletedmanagedhsm.go deleted file mode 100644 index ae5e8a11615..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsms/model_deletedmanagedhsm.go +++ /dev/null @@ -1,11 +0,0 @@ -package managedhsms - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeletedManagedHsm struct { - Id *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Properties *DeletedManagedHsmProperties `json:"properties,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsms/model_deletedmanagedhsmproperties.go b/resource-manager/keyvault/2022-11-01/managedhsms/model_deletedmanagedhsmproperties.go deleted file mode 100644 index 5093466f02e..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsms/model_deletedmanagedhsmproperties.go +++ /dev/null @@ -1,43 +0,0 @@ -package managedhsms - -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 DeletedManagedHsmProperties struct { - DeletionDate *string `json:"deletionDate,omitempty"` - Location *string `json:"location,omitempty"` - MhsmId *string `json:"mhsmId,omitempty"` - PurgeProtectionEnabled *bool `json:"purgeProtectionEnabled,omitempty"` - ScheduledPurgeDate *string `json:"scheduledPurgeDate,omitempty"` - Tags *map[string]string `json:"tags,omitempty"` -} - -func (o *DeletedManagedHsmProperties) GetDeletionDateAsTime() (*time.Time, error) { - if o.DeletionDate == nil { - return nil, nil - } - return dates.ParseAsFormat(o.DeletionDate, "2006-01-02T15:04:05Z07:00") -} - -func (o *DeletedManagedHsmProperties) SetDeletionDateAsTime(input time.Time) { - formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.DeletionDate = &formatted -} - -func (o *DeletedManagedHsmProperties) GetScheduledPurgeDateAsTime() (*time.Time, error) { - if o.ScheduledPurgeDate == nil { - return nil, nil - } - return dates.ParseAsFormat(o.ScheduledPurgeDate, "2006-01-02T15:04:05Z07:00") -} - -func (o *DeletedManagedHsmProperties) SetScheduledPurgeDateAsTime(input time.Time) { - formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.ScheduledPurgeDate = &formatted -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsms/model_managedhsm.go b/resource-manager/keyvault/2022-11-01/managedhsms/model_managedhsm.go deleted file mode 100644 index 15895c20ae0..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsms/model_managedhsm.go +++ /dev/null @@ -1,19 +0,0 @@ -package managedhsms - -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 ManagedHsm struct { - Id *string `json:"id,omitempty"` - Location *string `json:"location,omitempty"` - Name *string `json:"name,omitempty"` - Properties *ManagedHsmProperties `json:"properties,omitempty"` - Sku *ManagedHsmSku `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/keyvault/2022-11-01/managedhsms/model_managedhsmproperties.go b/resource-manager/keyvault/2022-11-01/managedhsms/model_managedhsmproperties.go deleted file mode 100644 index 837950055a9..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsms/model_managedhsmproperties.go +++ /dev/null @@ -1,39 +0,0 @@ -package managedhsms - -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 ManagedHsmProperties struct { - CreateMode *CreateMode `json:"createMode,omitempty"` - EnablePurgeProtection *bool `json:"enablePurgeProtection,omitempty"` - EnableSoftDelete *bool `json:"enableSoftDelete,omitempty"` - HsmUri *string `json:"hsmUri,omitempty"` - InitialAdminObjectIds *[]string `json:"initialAdminObjectIds,omitempty"` - NetworkAcls *MHSMNetworkRuleSet `json:"networkAcls,omitempty"` - PrivateEndpointConnections *[]MHSMPrivateEndpointConnectionItem `json:"privateEndpointConnections,omitempty"` - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` - PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` - ScheduledPurgeDate *string `json:"scheduledPurgeDate,omitempty"` - SecurityDomainProperties *ManagedHSMSecurityDomainProperties `json:"securityDomainProperties,omitempty"` - SoftDeleteRetentionInDays *int64 `json:"softDeleteRetentionInDays,omitempty"` - StatusMessage *string `json:"statusMessage,omitempty"` - TenantId *string `json:"tenantId,omitempty"` -} - -func (o *ManagedHsmProperties) GetScheduledPurgeDateAsTime() (*time.Time, error) { - if o.ScheduledPurgeDate == nil { - return nil, nil - } - return dates.ParseAsFormat(o.ScheduledPurgeDate, "2006-01-02T15:04:05Z07:00") -} - -func (o *ManagedHsmProperties) SetScheduledPurgeDateAsTime(input time.Time) { - formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.ScheduledPurgeDate = &formatted -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsms/model_managedhsmsecuritydomainproperties.go b/resource-manager/keyvault/2022-11-01/managedhsms/model_managedhsmsecuritydomainproperties.go deleted file mode 100644 index 63842e56813..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsms/model_managedhsmsecuritydomainproperties.go +++ /dev/null @@ -1,9 +0,0 @@ -package managedhsms - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ManagedHSMSecurityDomainProperties struct { - ActivationStatus *ActivationStatus `json:"activationStatus,omitempty"` - ActivationStatusMessage *string `json:"activationStatusMessage,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsms/model_managedhsmsku.go b/resource-manager/keyvault/2022-11-01/managedhsms/model_managedhsmsku.go deleted file mode 100644 index 61dcd5e3b98..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsms/model_managedhsmsku.go +++ /dev/null @@ -1,9 +0,0 @@ -package managedhsms - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ManagedHsmSku struct { - Family ManagedHsmSkuFamily `json:"family"` - Name ManagedHsmSkuName `json:"name"` -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsms/model_mhsmiprule.go b/resource-manager/keyvault/2022-11-01/managedhsms/model_mhsmiprule.go deleted file mode 100644 index 6fb2abdeef9..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsms/model_mhsmiprule.go +++ /dev/null @@ -1,8 +0,0 @@ -package managedhsms - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type MHSMIPRule struct { - Value string `json:"value"` -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsms/model_mhsmnetworkruleset.go b/resource-manager/keyvault/2022-11-01/managedhsms/model_mhsmnetworkruleset.go deleted file mode 100644 index 2fc81ecae8d..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsms/model_mhsmnetworkruleset.go +++ /dev/null @@ -1,11 +0,0 @@ -package managedhsms - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type MHSMNetworkRuleSet struct { - Bypass *NetworkRuleBypassOptions `json:"bypass,omitempty"` - DefaultAction *NetworkRuleAction `json:"defaultAction,omitempty"` - IPRules *[]MHSMIPRule `json:"ipRules,omitempty"` - VirtualNetworkRules *[]MHSMVirtualNetworkRule `json:"virtualNetworkRules,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsms/model_mhsmprivateendpoint.go b/resource-manager/keyvault/2022-11-01/managedhsms/model_mhsmprivateendpoint.go deleted file mode 100644 index dadd1b65b93..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsms/model_mhsmprivateendpoint.go +++ /dev/null @@ -1,8 +0,0 @@ -package managedhsms - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type MHSMPrivateEndpoint struct { - Id *string `json:"id,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsms/model_mhsmprivateendpointconnectionitem.go b/resource-manager/keyvault/2022-11-01/managedhsms/model_mhsmprivateendpointconnectionitem.go deleted file mode 100644 index d7b577af988..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsms/model_mhsmprivateendpointconnectionitem.go +++ /dev/null @@ -1,10 +0,0 @@ -package managedhsms - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type MHSMPrivateEndpointConnectionItem struct { - Etag *string `json:"etag,omitempty"` - Id *string `json:"id,omitempty"` - Properties *MHSMPrivateEndpointConnectionProperties `json:"properties,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsms/model_mhsmprivateendpointconnectionproperties.go b/resource-manager/keyvault/2022-11-01/managedhsms/model_mhsmprivateendpointconnectionproperties.go deleted file mode 100644 index e91a4b16dec..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsms/model_mhsmprivateendpointconnectionproperties.go +++ /dev/null @@ -1,10 +0,0 @@ -package managedhsms - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type MHSMPrivateEndpointConnectionProperties struct { - PrivateEndpoint *MHSMPrivateEndpoint `json:"privateEndpoint,omitempty"` - PrivateLinkServiceConnectionState *MHSMPrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` - ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsms/model_mhsmprivatelinkserviceconnectionstate.go b/resource-manager/keyvault/2022-11-01/managedhsms/model_mhsmprivatelinkserviceconnectionstate.go deleted file mode 100644 index 83b45a02518..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsms/model_mhsmprivatelinkserviceconnectionstate.go +++ /dev/null @@ -1,10 +0,0 @@ -package managedhsms - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type MHSMPrivateLinkServiceConnectionState struct { - ActionsRequired *ActionsRequired `json:"actionsRequired,omitempty"` - Description *string `json:"description,omitempty"` - Status *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsms/model_mhsmvirtualnetworkrule.go b/resource-manager/keyvault/2022-11-01/managedhsms/model_mhsmvirtualnetworkrule.go deleted file mode 100644 index 3daa2f4233b..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsms/model_mhsmvirtualnetworkrule.go +++ /dev/null @@ -1,8 +0,0 @@ -package managedhsms - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type MHSMVirtualNetworkRule struct { - Id string `json:"id"` -} diff --git a/resource-manager/keyvault/2022-11-01/managedhsms/predicates.go b/resource-manager/keyvault/2022-11-01/managedhsms/predicates.go deleted file mode 100644 index 598d2e6d12b..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsms/predicates.go +++ /dev/null @@ -1,55 +0,0 @@ -package managedhsms - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeletedManagedHsmOperationPredicate struct { - Id *string - Name *string - Type *string -} - -func (p DeletedManagedHsmOperationPredicate) Matches(input DeletedManagedHsm) bool { - - if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { - return false - } - - if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { - return false - } - - if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { - return false - } - - return true -} - -type ManagedHsmOperationPredicate struct { - Id *string - Location *string - Name *string - Type *string -} - -func (p ManagedHsmOperationPredicate) Matches(input ManagedHsm) 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/keyvault/2022-11-01/managedhsms/version.go b/resource-manager/keyvault/2022-11-01/managedhsms/version.go deleted file mode 100644 index 51245b1ae57..00000000000 --- a/resource-manager/keyvault/2022-11-01/managedhsms/version.go +++ /dev/null @@ -1,12 +0,0 @@ -package managedhsms - -import "fmt" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -const defaultApiVersion = "2022-11-01" - -func userAgent() string { - return fmt.Sprintf("hashicorp/go-azure-sdk/managedhsms/%s", defaultApiVersion) -} diff --git a/resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/README.md b/resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/README.md deleted file mode 100644 index 48197aab95c..00000000000 --- a/resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/README.md +++ /dev/null @@ -1,37 +0,0 @@ - -## `github.com/hashicorp/go-azure-sdk/resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections` Documentation - -The `mhsmlistprivateendpointconnections` SDK allows for interaction with the Azure Resource Manager Service `keyvault` (API Version `2022-11-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/keyvault/2022-11-01/mhsmlistprivateendpointconnections" -``` - - -### Client Initialization - -```go -client := mhsmlistprivateendpointconnections.NewMHSMListPrivateEndpointConnectionsClientWithBaseURI("https://management.azure.com") -client.Client.Authorizer = authorizer -``` - - -### Example Usage: `MHSMListPrivateEndpointConnectionsClient.MHSMPrivateEndpointConnectionsListByResource` - -```go -ctx := context.TODO() -id := mhsmlistprivateendpointconnections.NewManagedHSMID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedHSMValue") - -// alternatively `client.MHSMPrivateEndpointConnectionsListByResource(ctx, id)` can be used to do batched pagination -items, err := client.MHSMPrivateEndpointConnectionsListByResourceComplete(ctx, id) -if err != nil { - // handle the error -} -for _, item := range items { - // do something -} -``` diff --git a/resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/client.go b/resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/client.go deleted file mode 100644 index e8f5caf9f7b..00000000000 --- a/resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/client.go +++ /dev/null @@ -1,18 +0,0 @@ -package mhsmlistprivateendpointconnections - -import "github.com/Azure/go-autorest/autorest" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type MHSMListPrivateEndpointConnectionsClient struct { - Client autorest.Client - baseUri string -} - -func NewMHSMListPrivateEndpointConnectionsClientWithBaseURI(endpoint string) MHSMListPrivateEndpointConnectionsClient { - return MHSMListPrivateEndpointConnectionsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/constants.go b/resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/constants.go deleted file mode 100644 index 6217f9d1eca..00000000000 --- a/resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/constants.go +++ /dev/null @@ -1,161 +0,0 @@ -package mhsmlistprivateendpointconnections - -import "strings" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ActionsRequired string - -const ( - ActionsRequiredNone ActionsRequired = "None" -) - -func PossibleValuesForActionsRequired() []string { - return []string{ - string(ActionsRequiredNone), - } -} - -func parseActionsRequired(input string) (*ActionsRequired, error) { - vals := map[string]ActionsRequired{ - "none": ActionsRequiredNone, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ActionsRequired(input) - return &out, nil -} - -type ManagedHsmSkuFamily string - -const ( - ManagedHsmSkuFamilyB ManagedHsmSkuFamily = "B" -) - -func PossibleValuesForManagedHsmSkuFamily() []string { - return []string{ - string(ManagedHsmSkuFamilyB), - } -} - -func parseManagedHsmSkuFamily(input string) (*ManagedHsmSkuFamily, error) { - vals := map[string]ManagedHsmSkuFamily{ - "b": ManagedHsmSkuFamilyB, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ManagedHsmSkuFamily(input) - return &out, nil -} - -type ManagedHsmSkuName string - -const ( - ManagedHsmSkuNameCustomBSix ManagedHsmSkuName = "Custom_B6" - ManagedHsmSkuNameCustomBThreeTwo ManagedHsmSkuName = "Custom_B32" - ManagedHsmSkuNameStandardBOne ManagedHsmSkuName = "Standard_B1" -) - -func PossibleValuesForManagedHsmSkuName() []string { - return []string{ - string(ManagedHsmSkuNameCustomBSix), - string(ManagedHsmSkuNameCustomBThreeTwo), - string(ManagedHsmSkuNameStandardBOne), - } -} - -func parseManagedHsmSkuName(input string) (*ManagedHsmSkuName, error) { - vals := map[string]ManagedHsmSkuName{ - "custom_b6": ManagedHsmSkuNameCustomBSix, - "custom_b32": ManagedHsmSkuNameCustomBThreeTwo, - "standard_b1": ManagedHsmSkuNameStandardBOne, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ManagedHsmSkuName(input) - return &out, nil -} - -type PrivateEndpointConnectionProvisioningState string - -const ( - PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" - PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" - PrivateEndpointConnectionProvisioningStateDisconnected PrivateEndpointConnectionProvisioningState = "Disconnected" - PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" - PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" - PrivateEndpointConnectionProvisioningStateUpdating PrivateEndpointConnectionProvisioningState = "Updating" -) - -func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { - return []string{ - string(PrivateEndpointConnectionProvisioningStateCreating), - string(PrivateEndpointConnectionProvisioningStateDeleting), - string(PrivateEndpointConnectionProvisioningStateDisconnected), - string(PrivateEndpointConnectionProvisioningStateFailed), - string(PrivateEndpointConnectionProvisioningStateSucceeded), - string(PrivateEndpointConnectionProvisioningStateUpdating), - } -} - -func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { - vals := map[string]PrivateEndpointConnectionProvisioningState{ - "creating": PrivateEndpointConnectionProvisioningStateCreating, - "deleting": PrivateEndpointConnectionProvisioningStateDeleting, - "disconnected": PrivateEndpointConnectionProvisioningStateDisconnected, - "failed": PrivateEndpointConnectionProvisioningStateFailed, - "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, - "updating": PrivateEndpointConnectionProvisioningStateUpdating, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := PrivateEndpointConnectionProvisioningState(input) - return &out, nil -} - -type PrivateEndpointServiceConnectionStatus string - -const ( - PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" - PrivateEndpointServiceConnectionStatusDisconnected PrivateEndpointServiceConnectionStatus = "Disconnected" - PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" - PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" -) - -func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { - return []string{ - string(PrivateEndpointServiceConnectionStatusApproved), - string(PrivateEndpointServiceConnectionStatusDisconnected), - string(PrivateEndpointServiceConnectionStatusPending), - string(PrivateEndpointServiceConnectionStatusRejected), - } -} - -func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { - vals := map[string]PrivateEndpointServiceConnectionStatus{ - "approved": PrivateEndpointServiceConnectionStatusApproved, - "disconnected": PrivateEndpointServiceConnectionStatusDisconnected, - "pending": PrivateEndpointServiceConnectionStatusPending, - "rejected": PrivateEndpointServiceConnectionStatusRejected, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := PrivateEndpointServiceConnectionStatus(input) - return &out, nil -} diff --git a/resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/id_managedhsm.go b/resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/id_managedhsm.go deleted file mode 100644 index 0a553b86cce..00000000000 --- a/resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/id_managedhsm.go +++ /dev/null @@ -1,125 +0,0 @@ -package mhsmlistprivateendpointconnections - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -var _ resourceids.ResourceId = &ManagedHSMId{} - -// ManagedHSMId is a struct representing the Resource ID for a Managed H S M -type ManagedHSMId struct { - SubscriptionId string - ResourceGroupName string - ManagedHSMName string -} - -// NewManagedHSMID returns a new ManagedHSMId struct -func NewManagedHSMID(subscriptionId string, resourceGroupName string, managedHSMName string) ManagedHSMId { - return ManagedHSMId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - ManagedHSMName: managedHSMName, - } -} - -// ParseManagedHSMID parses 'input' into a ManagedHSMId -func ParseManagedHSMID(input string) (*ManagedHSMId, error) { - parser := resourceids.NewParserFromResourceIdType(&ManagedHSMId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := ManagedHSMId{} - if err := id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -// ParseManagedHSMIDInsensitively parses 'input' case-insensitively into a ManagedHSMId -// note: this method should only be used for API response data and not user input -func ParseManagedHSMIDInsensitively(input string) (*ManagedHSMId, error) { - parser := resourceids.NewParserFromResourceIdType(&ManagedHSMId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := ManagedHSMId{} - if err := id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -func (id *ManagedHSMId) FromParseResult(input resourceids.ParseResult) error { - var ok bool - - if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) - } - - if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) - } - - if id.ManagedHSMName, ok = input.Parsed["managedHSMName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "managedHSMName", input) - } - - return nil -} - -// ValidateManagedHSMID checks that 'input' can be parsed as a Managed H S M ID -func ValidateManagedHSMID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParseManagedHSMID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Managed H S M ID -func (id ManagedHSMId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.KeyVault/managedHSMs/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedHSMName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Managed H S M ID -func (id ManagedHSMId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftKeyVault", "Microsoft.KeyVault", "Microsoft.KeyVault"), - resourceids.StaticSegment("staticManagedHSMs", "managedHSMs", "managedHSMs"), - resourceids.UserSpecifiedSegment("managedHSMName", "managedHSMValue"), - } -} - -// String returns a human-readable description of this Managed H S M ID -func (id ManagedHSMId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Managed H S M Name: %q", id.ManagedHSMName), - } - return fmt.Sprintf("Managed H S M (%s)", strings.Join(components, "\n")) -} diff --git a/resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/id_managedhsm_test.go b/resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/id_managedhsm_test.go deleted file mode 100644 index b65d451df41..00000000000 --- a/resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/id_managedhsm_test.go +++ /dev/null @@ -1,282 +0,0 @@ -package mhsmlistprivateendpointconnections - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -var _ resourceids.ResourceId = &ManagedHSMId{} - -func TestNewManagedHSMID(t *testing.T) { - id := NewManagedHSMID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedHSMValue") - - if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { - t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") - } - - if id.ResourceGroupName != "example-resource-group" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") - } - - if id.ManagedHSMName != "managedHSMValue" { - t.Fatalf("Expected %q but got %q for Segment 'ManagedHSMName'", id.ManagedHSMName, "managedHSMValue") - } -} - -func TestFormatManagedHSMID(t *testing.T) { - actual := NewManagedHSMID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedHSMValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseManagedHSMID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *ManagedHSMId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue", - Expected: &ManagedHSMId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ManagedHSMName: "managedHSMValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseManagedHSMID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.ManagedHSMName != v.Expected.ManagedHSMName { - t.Fatalf("Expected %q but got %q for ManagedHSMName", v.Expected.ManagedHSMName, actual.ManagedHSMName) - } - - } -} - -func TestParseManagedHSMIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *ManagedHSMId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/mAnAgEdHsMs", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue", - Expected: &ManagedHSMId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ManagedHSMName: "managedHSMValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/mAnAgEdHsMs/mAnAgEdHsMvAlUe", - Expected: &ManagedHSMId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - ManagedHSMName: "mAnAgEdHsMvAlUe", - }, - }, - { - // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/mAnAgEdHsMs/mAnAgEdHsMvAlUe/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseManagedHSMIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.ManagedHSMName != v.Expected.ManagedHSMName { - t.Fatalf("Expected %q but got %q for ManagedHSMName", v.Expected.ManagedHSMName, actual.ManagedHSMName) - } - - } -} - -func TestSegmentsForManagedHSMId(t *testing.T) { - segments := ManagedHSMId{}.Segments() - if len(segments) == 0 { - t.Fatalf("ManagedHSMId has no segments") - } - - uniqueNames := make(map[string]struct{}, 0) - for _, segment := range segments { - uniqueNames[segment.Name] = struct{}{} - } - if len(uniqueNames) != len(segments) { - t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) - } -} diff --git a/resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/method_mhsmprivateendpointconnectionslistbyresource_autorest.go b/resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/method_mhsmprivateendpointconnectionslistbyresource_autorest.go deleted file mode 100644 index ee28909928e..00000000000 --- a/resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/method_mhsmprivateendpointconnectionslistbyresource_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package mhsmlistprivateendpointconnections - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type MHSMPrivateEndpointConnectionsListByResourceOperationResponse struct { - HttpResponse *http.Response - Model *[]MHSMPrivateEndpointConnection - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (MHSMPrivateEndpointConnectionsListByResourceOperationResponse, error) -} - -type MHSMPrivateEndpointConnectionsListByResourceCompleteResult struct { - Items []MHSMPrivateEndpointConnection -} - -func (r MHSMPrivateEndpointConnectionsListByResourceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r MHSMPrivateEndpointConnectionsListByResourceOperationResponse) LoadMore(ctx context.Context) (resp MHSMPrivateEndpointConnectionsListByResourceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// MHSMPrivateEndpointConnectionsListByResource ... -func (c MHSMListPrivateEndpointConnectionsClient) MHSMPrivateEndpointConnectionsListByResource(ctx context.Context, id ManagedHSMId) (resp MHSMPrivateEndpointConnectionsListByResourceOperationResponse, err error) { - req, err := c.preparerForMHSMPrivateEndpointConnectionsListByResource(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmlistprivateendpointconnections.MHSMListPrivateEndpointConnectionsClient", "MHSMPrivateEndpointConnectionsListByResource", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmlistprivateendpointconnections.MHSMListPrivateEndpointConnectionsClient", "MHSMPrivateEndpointConnectionsListByResource", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForMHSMPrivateEndpointConnectionsListByResource(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmlistprivateendpointconnections.MHSMListPrivateEndpointConnectionsClient", "MHSMPrivateEndpointConnectionsListByResource", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForMHSMPrivateEndpointConnectionsListByResource prepares the MHSMPrivateEndpointConnectionsListByResource request. -func (c MHSMListPrivateEndpointConnectionsClient) preparerForMHSMPrivateEndpointConnectionsListByResource(ctx context.Context, id ManagedHSMId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/privateEndpointConnections", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForMHSMPrivateEndpointConnectionsListByResourceWithNextLink prepares the MHSMPrivateEndpointConnectionsListByResource request with the given nextLink token. -func (c MHSMListPrivateEndpointConnectionsClient) preparerForMHSMPrivateEndpointConnectionsListByResourceWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForMHSMPrivateEndpointConnectionsListByResource handles the response to the MHSMPrivateEndpointConnectionsListByResource request. The method always -// closes the http.Response Body. -func (c MHSMListPrivateEndpointConnectionsClient) responderForMHSMPrivateEndpointConnectionsListByResource(resp *http.Response) (result MHSMPrivateEndpointConnectionsListByResourceOperationResponse, err error) { - type page struct { - Values []MHSMPrivateEndpointConnection `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result MHSMPrivateEndpointConnectionsListByResourceOperationResponse, err error) { - req, err := c.preparerForMHSMPrivateEndpointConnectionsListByResourceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmlistprivateendpointconnections.MHSMListPrivateEndpointConnectionsClient", "MHSMPrivateEndpointConnectionsListByResource", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmlistprivateendpointconnections.MHSMListPrivateEndpointConnectionsClient", "MHSMPrivateEndpointConnectionsListByResource", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForMHSMPrivateEndpointConnectionsListByResource(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmlistprivateendpointconnections.MHSMListPrivateEndpointConnectionsClient", "MHSMPrivateEndpointConnectionsListByResource", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// MHSMPrivateEndpointConnectionsListByResourceComplete retrieves all of the results into a single object -func (c MHSMListPrivateEndpointConnectionsClient) MHSMPrivateEndpointConnectionsListByResourceComplete(ctx context.Context, id ManagedHSMId) (MHSMPrivateEndpointConnectionsListByResourceCompleteResult, error) { - return c.MHSMPrivateEndpointConnectionsListByResourceCompleteMatchingPredicate(ctx, id, MHSMPrivateEndpointConnectionOperationPredicate{}) -} - -// MHSMPrivateEndpointConnectionsListByResourceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c MHSMListPrivateEndpointConnectionsClient) MHSMPrivateEndpointConnectionsListByResourceCompleteMatchingPredicate(ctx context.Context, id ManagedHSMId, predicate MHSMPrivateEndpointConnectionOperationPredicate) (resp MHSMPrivateEndpointConnectionsListByResourceCompleteResult, err error) { - items := make([]MHSMPrivateEndpointConnection, 0) - - page, err := c.MHSMPrivateEndpointConnectionsListByResource(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := MHSMPrivateEndpointConnectionsListByResourceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/model_managedhsmsku.go b/resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/model_managedhsmsku.go deleted file mode 100644 index 80d6089af8f..00000000000 --- a/resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/model_managedhsmsku.go +++ /dev/null @@ -1,9 +0,0 @@ -package mhsmlistprivateendpointconnections - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ManagedHsmSku struct { - Family ManagedHsmSkuFamily `json:"family"` - Name ManagedHsmSkuName `json:"name"` -} diff --git a/resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/model_mhsmprivateendpoint.go b/resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/model_mhsmprivateendpoint.go deleted file mode 100644 index 584d7931ee7..00000000000 --- a/resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/model_mhsmprivateendpoint.go +++ /dev/null @@ -1,8 +0,0 @@ -package mhsmlistprivateendpointconnections - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type MHSMPrivateEndpoint struct { - Id *string `json:"id,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/model_mhsmprivateendpointconnection.go b/resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/model_mhsmprivateendpointconnection.go deleted file mode 100644 index 194164efde7..00000000000 --- a/resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/model_mhsmprivateendpointconnection.go +++ /dev/null @@ -1,20 +0,0 @@ -package mhsmlistprivateendpointconnections - -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 MHSMPrivateEndpointConnection struct { - Etag *string `json:"etag,omitempty"` - Id *string `json:"id,omitempty"` - Location *string `json:"location,omitempty"` - Name *string `json:"name,omitempty"` - Properties *MHSMPrivateEndpointConnectionProperties `json:"properties,omitempty"` - Sku *ManagedHsmSku `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/keyvault/2022-11-01/mhsmlistprivateendpointconnections/model_mhsmprivateendpointconnectionproperties.go b/resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/model_mhsmprivateendpointconnectionproperties.go deleted file mode 100644 index 983aa57e6bd..00000000000 --- a/resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/model_mhsmprivateendpointconnectionproperties.go +++ /dev/null @@ -1,10 +0,0 @@ -package mhsmlistprivateendpointconnections - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type MHSMPrivateEndpointConnectionProperties struct { - PrivateEndpoint *MHSMPrivateEndpoint `json:"privateEndpoint,omitempty"` - PrivateLinkServiceConnectionState *MHSMPrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` - ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/model_mhsmprivatelinkserviceconnectionstate.go b/resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/model_mhsmprivatelinkserviceconnectionstate.go deleted file mode 100644 index 3a7d8db5ebb..00000000000 --- a/resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/model_mhsmprivatelinkserviceconnectionstate.go +++ /dev/null @@ -1,10 +0,0 @@ -package mhsmlistprivateendpointconnections - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type MHSMPrivateLinkServiceConnectionState struct { - ActionsRequired *ActionsRequired `json:"actionsRequired,omitempty"` - Description *string `json:"description,omitempty"` - Status *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/predicates.go b/resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/predicates.go deleted file mode 100644 index 18e2f2156a7..00000000000 --- a/resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/predicates.go +++ /dev/null @@ -1,37 +0,0 @@ -package mhsmlistprivateendpointconnections - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type MHSMPrivateEndpointConnectionOperationPredicate struct { - Etag *string - Id *string - Location *string - Name *string - Type *string -} - -func (p MHSMPrivateEndpointConnectionOperationPredicate) Matches(input MHSMPrivateEndpointConnection) bool { - - if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { - return false - } - - if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { - return false - } - - if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { - return false - } - - if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { - return false - } - - if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { - return false - } - - return true -} diff --git a/resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/version.go b/resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/version.go deleted file mode 100644 index 902ebaa7663..00000000000 --- a/resource-manager/keyvault/2022-11-01/mhsmlistprivateendpointconnections/version.go +++ /dev/null @@ -1,12 +0,0 @@ -package mhsmlistprivateendpointconnections - -import "fmt" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -const defaultApiVersion = "2022-11-01" - -func userAgent() string { - return fmt.Sprintf("hashicorp/go-azure-sdk/mhsmlistprivateendpointconnections/%s", defaultApiVersion) -} diff --git a/resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/README.md b/resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/README.md deleted file mode 100644 index 92be2feeb8e..00000000000 --- a/resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/README.md +++ /dev/null @@ -1,69 +0,0 @@ - -## `github.com/hashicorp/go-azure-sdk/resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections` Documentation - -The `mhsmprivateendpointconnections` SDK allows for interaction with the Azure Resource Manager Service `keyvault` (API Version `2022-11-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/keyvault/2022-11-01/mhsmprivateendpointconnections" -``` - - -### Client Initialization - -```go -client := mhsmprivateendpointconnections.NewMHSMPrivateEndpointConnectionsClientWithBaseURI("https://management.azure.com") -client.Client.Authorizer = authorizer -``` - - -### Example Usage: `MHSMPrivateEndpointConnectionsClient.Delete` - -```go -ctx := context.TODO() -id := mhsmprivateendpointconnections.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedHSMValue", "privateEndpointConnectionValue") - -if err := client.DeleteThenPoll(ctx, id); err != nil { - // handle the error -} -``` - - -### Example Usage: `MHSMPrivateEndpointConnectionsClient.Get` - -```go -ctx := context.TODO() -id := mhsmprivateendpointconnections.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedHSMValue", "privateEndpointConnectionValue") - -read, err := client.Get(ctx, id) -if err != nil { - // handle the error -} -if model := read.Model; model != nil { - // do something with the model/response object -} -``` - - -### Example Usage: `MHSMPrivateEndpointConnectionsClient.Put` - -```go -ctx := context.TODO() -id := mhsmprivateendpointconnections.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedHSMValue", "privateEndpointConnectionValue") - -payload := mhsmprivateendpointconnections.MHSMPrivateEndpointConnection{ - // ... -} - - -read, err := client.Put(ctx, id, payload) -if err != nil { - // handle the error -} -if model := read.Model; model != nil { - // do something with the model/response object -} -``` diff --git a/resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/client.go b/resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/client.go deleted file mode 100644 index 933a39f9036..00000000000 --- a/resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/client.go +++ /dev/null @@ -1,18 +0,0 @@ -package mhsmprivateendpointconnections - -import "github.com/Azure/go-autorest/autorest" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type MHSMPrivateEndpointConnectionsClient struct { - Client autorest.Client - baseUri string -} - -func NewMHSMPrivateEndpointConnectionsClientWithBaseURI(endpoint string) MHSMPrivateEndpointConnectionsClient { - return MHSMPrivateEndpointConnectionsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/constants.go b/resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/constants.go deleted file mode 100644 index c8d3a4886e3..00000000000 --- a/resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/constants.go +++ /dev/null @@ -1,161 +0,0 @@ -package mhsmprivateendpointconnections - -import "strings" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ActionsRequired string - -const ( - ActionsRequiredNone ActionsRequired = "None" -) - -func PossibleValuesForActionsRequired() []string { - return []string{ - string(ActionsRequiredNone), - } -} - -func parseActionsRequired(input string) (*ActionsRequired, error) { - vals := map[string]ActionsRequired{ - "none": ActionsRequiredNone, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ActionsRequired(input) - return &out, nil -} - -type ManagedHsmSkuFamily string - -const ( - ManagedHsmSkuFamilyB ManagedHsmSkuFamily = "B" -) - -func PossibleValuesForManagedHsmSkuFamily() []string { - return []string{ - string(ManagedHsmSkuFamilyB), - } -} - -func parseManagedHsmSkuFamily(input string) (*ManagedHsmSkuFamily, error) { - vals := map[string]ManagedHsmSkuFamily{ - "b": ManagedHsmSkuFamilyB, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ManagedHsmSkuFamily(input) - return &out, nil -} - -type ManagedHsmSkuName string - -const ( - ManagedHsmSkuNameCustomBSix ManagedHsmSkuName = "Custom_B6" - ManagedHsmSkuNameCustomBThreeTwo ManagedHsmSkuName = "Custom_B32" - ManagedHsmSkuNameStandardBOne ManagedHsmSkuName = "Standard_B1" -) - -func PossibleValuesForManagedHsmSkuName() []string { - return []string{ - string(ManagedHsmSkuNameCustomBSix), - string(ManagedHsmSkuNameCustomBThreeTwo), - string(ManagedHsmSkuNameStandardBOne), - } -} - -func parseManagedHsmSkuName(input string) (*ManagedHsmSkuName, error) { - vals := map[string]ManagedHsmSkuName{ - "custom_b6": ManagedHsmSkuNameCustomBSix, - "custom_b32": ManagedHsmSkuNameCustomBThreeTwo, - "standard_b1": ManagedHsmSkuNameStandardBOne, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ManagedHsmSkuName(input) - return &out, nil -} - -type PrivateEndpointConnectionProvisioningState string - -const ( - PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" - PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" - PrivateEndpointConnectionProvisioningStateDisconnected PrivateEndpointConnectionProvisioningState = "Disconnected" - PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" - PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" - PrivateEndpointConnectionProvisioningStateUpdating PrivateEndpointConnectionProvisioningState = "Updating" -) - -func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { - return []string{ - string(PrivateEndpointConnectionProvisioningStateCreating), - string(PrivateEndpointConnectionProvisioningStateDeleting), - string(PrivateEndpointConnectionProvisioningStateDisconnected), - string(PrivateEndpointConnectionProvisioningStateFailed), - string(PrivateEndpointConnectionProvisioningStateSucceeded), - string(PrivateEndpointConnectionProvisioningStateUpdating), - } -} - -func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { - vals := map[string]PrivateEndpointConnectionProvisioningState{ - "creating": PrivateEndpointConnectionProvisioningStateCreating, - "deleting": PrivateEndpointConnectionProvisioningStateDeleting, - "disconnected": PrivateEndpointConnectionProvisioningStateDisconnected, - "failed": PrivateEndpointConnectionProvisioningStateFailed, - "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, - "updating": PrivateEndpointConnectionProvisioningStateUpdating, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := PrivateEndpointConnectionProvisioningState(input) - return &out, nil -} - -type PrivateEndpointServiceConnectionStatus string - -const ( - PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" - PrivateEndpointServiceConnectionStatusDisconnected PrivateEndpointServiceConnectionStatus = "Disconnected" - PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" - PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" -) - -func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { - return []string{ - string(PrivateEndpointServiceConnectionStatusApproved), - string(PrivateEndpointServiceConnectionStatusDisconnected), - string(PrivateEndpointServiceConnectionStatusPending), - string(PrivateEndpointServiceConnectionStatusRejected), - } -} - -func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { - vals := map[string]PrivateEndpointServiceConnectionStatus{ - "approved": PrivateEndpointServiceConnectionStatusApproved, - "disconnected": PrivateEndpointServiceConnectionStatusDisconnected, - "pending": PrivateEndpointServiceConnectionStatusPending, - "rejected": PrivateEndpointServiceConnectionStatusRejected, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := PrivateEndpointServiceConnectionStatus(input) - return &out, nil -} diff --git a/resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/id_privateendpointconnection.go b/resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/id_privateendpointconnection.go deleted file mode 100644 index 0d174a3978f..00000000000 --- a/resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/id_privateendpointconnection.go +++ /dev/null @@ -1,134 +0,0 @@ -package mhsmprivateendpointconnections - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -var _ resourceids.ResourceId = &PrivateEndpointConnectionId{} - -// PrivateEndpointConnectionId is a struct representing the Resource ID for a Private Endpoint Connection -type PrivateEndpointConnectionId struct { - SubscriptionId string - ResourceGroupName string - ManagedHSMName string - PrivateEndpointConnectionName string -} - -// NewPrivateEndpointConnectionID returns a new PrivateEndpointConnectionId struct -func NewPrivateEndpointConnectionID(subscriptionId string, resourceGroupName string, managedHSMName string, privateEndpointConnectionName string) PrivateEndpointConnectionId { - return PrivateEndpointConnectionId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - ManagedHSMName: managedHSMName, - PrivateEndpointConnectionName: privateEndpointConnectionName, - } -} - -// ParsePrivateEndpointConnectionID parses 'input' into a PrivateEndpointConnectionId -func ParsePrivateEndpointConnectionID(input string) (*PrivateEndpointConnectionId, error) { - parser := resourceids.NewParserFromResourceIdType(&PrivateEndpointConnectionId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := PrivateEndpointConnectionId{} - if err := id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -// ParsePrivateEndpointConnectionIDInsensitively parses 'input' case-insensitively into a PrivateEndpointConnectionId -// note: this method should only be used for API response data and not user input -func ParsePrivateEndpointConnectionIDInsensitively(input string) (*PrivateEndpointConnectionId, error) { - parser := resourceids.NewParserFromResourceIdType(&PrivateEndpointConnectionId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := PrivateEndpointConnectionId{} - if err := id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -func (id *PrivateEndpointConnectionId) FromParseResult(input resourceids.ParseResult) error { - var ok bool - - if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) - } - - if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) - } - - if id.ManagedHSMName, ok = input.Parsed["managedHSMName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "managedHSMName", input) - } - - if id.PrivateEndpointConnectionName, ok = input.Parsed["privateEndpointConnectionName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "privateEndpointConnectionName", input) - } - - return nil -} - -// ValidatePrivateEndpointConnectionID checks that 'input' can be parsed as a Private Endpoint Connection ID -func ValidatePrivateEndpointConnectionID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParsePrivateEndpointConnectionID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Private Endpoint Connection ID -func (id PrivateEndpointConnectionId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.KeyVault/managedHSMs/%s/privateEndpointConnections/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedHSMName, id.PrivateEndpointConnectionName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Private Endpoint Connection ID -func (id PrivateEndpointConnectionId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftKeyVault", "Microsoft.KeyVault", "Microsoft.KeyVault"), - resourceids.StaticSegment("staticManagedHSMs", "managedHSMs", "managedHSMs"), - resourceids.UserSpecifiedSegment("managedHSMName", "managedHSMValue"), - resourceids.StaticSegment("staticPrivateEndpointConnections", "privateEndpointConnections", "privateEndpointConnections"), - resourceids.UserSpecifiedSegment("privateEndpointConnectionName", "privateEndpointConnectionValue"), - } -} - -// String returns a human-readable description of this Private Endpoint Connection ID -func (id PrivateEndpointConnectionId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Managed H S M Name: %q", id.ManagedHSMName), - fmt.Sprintf("Private Endpoint Connection Name: %q", id.PrivateEndpointConnectionName), - } - return fmt.Sprintf("Private Endpoint Connection (%s)", strings.Join(components, "\n")) -} diff --git a/resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/id_privateendpointconnection_test.go b/resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/id_privateendpointconnection_test.go deleted file mode 100644 index 47eafd0f1d8..00000000000 --- a/resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/id_privateendpointconnection_test.go +++ /dev/null @@ -1,327 +0,0 @@ -package mhsmprivateendpointconnections - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -var _ resourceids.ResourceId = &PrivateEndpointConnectionId{} - -func TestNewPrivateEndpointConnectionID(t *testing.T) { - id := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedHSMValue", "privateEndpointConnectionValue") - - if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { - t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") - } - - if id.ResourceGroupName != "example-resource-group" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") - } - - if id.ManagedHSMName != "managedHSMValue" { - t.Fatalf("Expected %q but got %q for Segment 'ManagedHSMName'", id.ManagedHSMName, "managedHSMValue") - } - - if id.PrivateEndpointConnectionName != "privateEndpointConnectionValue" { - t.Fatalf("Expected %q but got %q for Segment 'PrivateEndpointConnectionName'", id.PrivateEndpointConnectionName, "privateEndpointConnectionValue") - } -} - -func TestFormatPrivateEndpointConnectionID(t *testing.T) { - actual := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedHSMValue", "privateEndpointConnectionValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue/privateEndpointConnections/privateEndpointConnectionValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParsePrivateEndpointConnectionID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *PrivateEndpointConnectionId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue/privateEndpointConnections", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue/privateEndpointConnections/privateEndpointConnectionValue", - Expected: &PrivateEndpointConnectionId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ManagedHSMName: "managedHSMValue", - PrivateEndpointConnectionName: "privateEndpointConnectionValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue/privateEndpointConnections/privateEndpointConnectionValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParsePrivateEndpointConnectionID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.ManagedHSMName != v.Expected.ManagedHSMName { - t.Fatalf("Expected %q but got %q for ManagedHSMName", v.Expected.ManagedHSMName, actual.ManagedHSMName) - } - - if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { - t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) - } - - } -} - -func TestParsePrivateEndpointConnectionIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *PrivateEndpointConnectionId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/mAnAgEdHsMs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/mAnAgEdHsMs/mAnAgEdHsMvAlUe", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue/privateEndpointConnections", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/mAnAgEdHsMs/mAnAgEdHsMvAlUe/pRiVaTeEnDpOiNtCoNnEcTiOnS", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue/privateEndpointConnections/privateEndpointConnectionValue", - Expected: &PrivateEndpointConnectionId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ManagedHSMName: "managedHSMValue", - PrivateEndpointConnectionName: "privateEndpointConnectionValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue/privateEndpointConnections/privateEndpointConnectionValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/mAnAgEdHsMs/mAnAgEdHsMvAlUe/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE", - Expected: &PrivateEndpointConnectionId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - ManagedHSMName: "mAnAgEdHsMvAlUe", - PrivateEndpointConnectionName: "pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE", - }, - }, - { - // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/mAnAgEdHsMs/mAnAgEdHsMvAlUe/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParsePrivateEndpointConnectionIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.ManagedHSMName != v.Expected.ManagedHSMName { - t.Fatalf("Expected %q but got %q for ManagedHSMName", v.Expected.ManagedHSMName, actual.ManagedHSMName) - } - - if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { - t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) - } - - } -} - -func TestSegmentsForPrivateEndpointConnectionId(t *testing.T) { - segments := PrivateEndpointConnectionId{}.Segments() - if len(segments) == 0 { - t.Fatalf("PrivateEndpointConnectionId has no segments") - } - - uniqueNames := make(map[string]struct{}, 0) - for _, segment := range segments { - uniqueNames[segment.Name] = struct{}{} - } - if len(uniqueNames) != len(segments) { - t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) - } -} diff --git a/resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/method_delete_autorest.go b/resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/method_delete_autorest.go deleted file mode 100644 index d3eef6a25df..00000000000 --- a/resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/method_delete_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package mhsmprivateendpointconnections - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response - Model *MHSMPrivateEndpointConnection -} - -// Delete ... -func (c MHSMPrivateEndpointConnectionsClient) Delete(ctx context.Context, id PrivateEndpointConnectionId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmprivateendpointconnections.MHSMPrivateEndpointConnectionsClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmprivateendpointconnections.MHSMPrivateEndpointConnectionsClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c MHSMPrivateEndpointConnectionsClient) DeleteThenPoll(ctx context.Context, id PrivateEndpointConnectionId) error { - result, err := c.Delete(ctx, id) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} - -// preparerForDelete prepares the Delete request. -func (c MHSMPrivateEndpointConnectionsClient) preparerForDelete(ctx context.Context, id PrivateEndpointConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDelete sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (c MHSMPrivateEndpointConnectionsClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/method_get_autorest.go b/resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/method_get_autorest.go deleted file mode 100644 index e20835facef..00000000000 --- a/resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package mhsmprivateendpointconnections - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *MHSMPrivateEndpointConnection -} - -// Get ... -func (c MHSMPrivateEndpointConnectionsClient) Get(ctx context.Context, id PrivateEndpointConnectionId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmprivateendpointconnections.MHSMPrivateEndpointConnectionsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmprivateendpointconnections.MHSMPrivateEndpointConnectionsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmprivateendpointconnections.MHSMPrivateEndpointConnectionsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c MHSMPrivateEndpointConnectionsClient) preparerForGet(ctx context.Context, id PrivateEndpointConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c MHSMPrivateEndpointConnectionsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/method_put_autorest.go b/resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/method_put_autorest.go deleted file mode 100644 index 61f1cad7759..00000000000 --- a/resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/method_put_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package mhsmprivateendpointconnections - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PutOperationResponse struct { - HttpResponse *http.Response - Model *MHSMPrivateEndpointConnection -} - -// Put ... -func (c MHSMPrivateEndpointConnectionsClient) Put(ctx context.Context, id PrivateEndpointConnectionId, input MHSMPrivateEndpointConnection) (result PutOperationResponse, err error) { - req, err := c.preparerForPut(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmprivateendpointconnections.MHSMPrivateEndpointConnectionsClient", "Put", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmprivateendpointconnections.MHSMPrivateEndpointConnectionsClient", "Put", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForPut(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmprivateendpointconnections.MHSMPrivateEndpointConnectionsClient", "Put", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForPut prepares the Put request. -func (c MHSMPrivateEndpointConnectionsClient) preparerForPut(ctx context.Context, id PrivateEndpointConnectionId, input MHSMPrivateEndpointConnection) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForPut handles the response to the Put request. The method always -// closes the http.Response Body. -func (c MHSMPrivateEndpointConnectionsClient) responderForPut(resp *http.Response) (result PutOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/model_managedhsmsku.go b/resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/model_managedhsmsku.go deleted file mode 100644 index 846aefa2cd9..00000000000 --- a/resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/model_managedhsmsku.go +++ /dev/null @@ -1,9 +0,0 @@ -package mhsmprivateendpointconnections - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ManagedHsmSku struct { - Family ManagedHsmSkuFamily `json:"family"` - Name ManagedHsmSkuName `json:"name"` -} diff --git a/resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/model_mhsmprivateendpoint.go b/resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/model_mhsmprivateendpoint.go deleted file mode 100644 index efd7da80d73..00000000000 --- a/resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/model_mhsmprivateendpoint.go +++ /dev/null @@ -1,8 +0,0 @@ -package mhsmprivateendpointconnections - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type MHSMPrivateEndpoint struct { - Id *string `json:"id,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/model_mhsmprivateendpointconnection.go b/resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/model_mhsmprivateendpointconnection.go deleted file mode 100644 index d37189be404..00000000000 --- a/resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/model_mhsmprivateendpointconnection.go +++ /dev/null @@ -1,20 +0,0 @@ -package mhsmprivateendpointconnections - -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 MHSMPrivateEndpointConnection struct { - Etag *string `json:"etag,omitempty"` - Id *string `json:"id,omitempty"` - Location *string `json:"location,omitempty"` - Name *string `json:"name,omitempty"` - Properties *MHSMPrivateEndpointConnectionProperties `json:"properties,omitempty"` - Sku *ManagedHsmSku `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/keyvault/2022-11-01/mhsmprivateendpointconnections/model_mhsmprivateendpointconnectionproperties.go b/resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/model_mhsmprivateendpointconnectionproperties.go deleted file mode 100644 index 13ad3394c3e..00000000000 --- a/resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/model_mhsmprivateendpointconnectionproperties.go +++ /dev/null @@ -1,10 +0,0 @@ -package mhsmprivateendpointconnections - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type MHSMPrivateEndpointConnectionProperties struct { - PrivateEndpoint *MHSMPrivateEndpoint `json:"privateEndpoint,omitempty"` - PrivateLinkServiceConnectionState *MHSMPrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` - ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/model_mhsmprivatelinkserviceconnectionstate.go b/resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/model_mhsmprivatelinkserviceconnectionstate.go deleted file mode 100644 index 13353b33837..00000000000 --- a/resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/model_mhsmprivatelinkserviceconnectionstate.go +++ /dev/null @@ -1,10 +0,0 @@ -package mhsmprivateendpointconnections - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type MHSMPrivateLinkServiceConnectionState struct { - ActionsRequired *ActionsRequired `json:"actionsRequired,omitempty"` - Description *string `json:"description,omitempty"` - Status *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/version.go b/resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/version.go deleted file mode 100644 index 52223336c34..00000000000 --- a/resource-manager/keyvault/2022-11-01/mhsmprivateendpointconnections/version.go +++ /dev/null @@ -1,12 +0,0 @@ -package mhsmprivateendpointconnections - -import "fmt" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -const defaultApiVersion = "2022-11-01" - -func userAgent() string { - return fmt.Sprintf("hashicorp/go-azure-sdk/mhsmprivateendpointconnections/%s", defaultApiVersion) -} diff --git a/resource-manager/keyvault/2022-11-01/mhsmprivatelinkresources/README.md b/resource-manager/keyvault/2022-11-01/mhsmprivatelinkresources/README.md deleted file mode 100644 index 61b6d0c565f..00000000000 --- a/resource-manager/keyvault/2022-11-01/mhsmprivatelinkresources/README.md +++ /dev/null @@ -1,36 +0,0 @@ - -## `github.com/hashicorp/go-azure-sdk/resource-manager/keyvault/2022-11-01/mhsmprivatelinkresources` Documentation - -The `mhsmprivatelinkresources` SDK allows for interaction with the Azure Resource Manager Service `keyvault` (API Version `2022-11-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/keyvault/2022-11-01/mhsmprivatelinkresources" -``` - - -### Client Initialization - -```go -client := mhsmprivatelinkresources.NewMHSMPrivateLinkResourcesClientWithBaseURI("https://management.azure.com") -client.Client.Authorizer = authorizer -``` - - -### Example Usage: `MHSMPrivateLinkResourcesClient.ListByMHSMResource` - -```go -ctx := context.TODO() -id := mhsmprivatelinkresources.NewManagedHSMID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedHSMValue") - -read, err := client.ListByMHSMResource(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/keyvault/2022-11-01/mhsmprivatelinkresources/client.go b/resource-manager/keyvault/2022-11-01/mhsmprivatelinkresources/client.go deleted file mode 100644 index 45db1c12858..00000000000 --- a/resource-manager/keyvault/2022-11-01/mhsmprivatelinkresources/client.go +++ /dev/null @@ -1,18 +0,0 @@ -package mhsmprivatelinkresources - -import "github.com/Azure/go-autorest/autorest" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type MHSMPrivateLinkResourcesClient struct { - Client autorest.Client - baseUri string -} - -func NewMHSMPrivateLinkResourcesClientWithBaseURI(endpoint string) MHSMPrivateLinkResourcesClient { - return MHSMPrivateLinkResourcesClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/resource-manager/keyvault/2022-11-01/mhsmprivatelinkresources/constants.go b/resource-manager/keyvault/2022-11-01/mhsmprivatelinkresources/constants.go deleted file mode 100644 index aa5754b95cd..00000000000 --- a/resource-manager/keyvault/2022-11-01/mhsmprivatelinkresources/constants.go +++ /dev/null @@ -1,62 +0,0 @@ -package mhsmprivatelinkresources - -import "strings" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ManagedHsmSkuFamily string - -const ( - ManagedHsmSkuFamilyB ManagedHsmSkuFamily = "B" -) - -func PossibleValuesForManagedHsmSkuFamily() []string { - return []string{ - string(ManagedHsmSkuFamilyB), - } -} - -func parseManagedHsmSkuFamily(input string) (*ManagedHsmSkuFamily, error) { - vals := map[string]ManagedHsmSkuFamily{ - "b": ManagedHsmSkuFamilyB, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ManagedHsmSkuFamily(input) - return &out, nil -} - -type ManagedHsmSkuName string - -const ( - ManagedHsmSkuNameCustomBSix ManagedHsmSkuName = "Custom_B6" - ManagedHsmSkuNameCustomBThreeTwo ManagedHsmSkuName = "Custom_B32" - ManagedHsmSkuNameStandardBOne ManagedHsmSkuName = "Standard_B1" -) - -func PossibleValuesForManagedHsmSkuName() []string { - return []string{ - string(ManagedHsmSkuNameCustomBSix), - string(ManagedHsmSkuNameCustomBThreeTwo), - string(ManagedHsmSkuNameStandardBOne), - } -} - -func parseManagedHsmSkuName(input string) (*ManagedHsmSkuName, error) { - vals := map[string]ManagedHsmSkuName{ - "custom_b6": ManagedHsmSkuNameCustomBSix, - "custom_b32": ManagedHsmSkuNameCustomBThreeTwo, - "standard_b1": ManagedHsmSkuNameStandardBOne, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ManagedHsmSkuName(input) - return &out, nil -} diff --git a/resource-manager/keyvault/2022-11-01/mhsmprivatelinkresources/id_managedhsm.go b/resource-manager/keyvault/2022-11-01/mhsmprivatelinkresources/id_managedhsm.go deleted file mode 100644 index 0b71dcbc99d..00000000000 --- a/resource-manager/keyvault/2022-11-01/mhsmprivatelinkresources/id_managedhsm.go +++ /dev/null @@ -1,125 +0,0 @@ -package mhsmprivatelinkresources - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -var _ resourceids.ResourceId = &ManagedHSMId{} - -// ManagedHSMId is a struct representing the Resource ID for a Managed H S M -type ManagedHSMId struct { - SubscriptionId string - ResourceGroupName string - ManagedHSMName string -} - -// NewManagedHSMID returns a new ManagedHSMId struct -func NewManagedHSMID(subscriptionId string, resourceGroupName string, managedHSMName string) ManagedHSMId { - return ManagedHSMId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - ManagedHSMName: managedHSMName, - } -} - -// ParseManagedHSMID parses 'input' into a ManagedHSMId -func ParseManagedHSMID(input string) (*ManagedHSMId, error) { - parser := resourceids.NewParserFromResourceIdType(&ManagedHSMId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := ManagedHSMId{} - if err := id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -// ParseManagedHSMIDInsensitively parses 'input' case-insensitively into a ManagedHSMId -// note: this method should only be used for API response data and not user input -func ParseManagedHSMIDInsensitively(input string) (*ManagedHSMId, error) { - parser := resourceids.NewParserFromResourceIdType(&ManagedHSMId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := ManagedHSMId{} - if err := id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -func (id *ManagedHSMId) FromParseResult(input resourceids.ParseResult) error { - var ok bool - - if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) - } - - if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) - } - - if id.ManagedHSMName, ok = input.Parsed["managedHSMName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "managedHSMName", input) - } - - return nil -} - -// ValidateManagedHSMID checks that 'input' can be parsed as a Managed H S M ID -func ValidateManagedHSMID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParseManagedHSMID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Managed H S M ID -func (id ManagedHSMId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.KeyVault/managedHSMs/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedHSMName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Managed H S M ID -func (id ManagedHSMId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftKeyVault", "Microsoft.KeyVault", "Microsoft.KeyVault"), - resourceids.StaticSegment("staticManagedHSMs", "managedHSMs", "managedHSMs"), - resourceids.UserSpecifiedSegment("managedHSMName", "managedHSMValue"), - } -} - -// String returns a human-readable description of this Managed H S M ID -func (id ManagedHSMId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Managed H S M Name: %q", id.ManagedHSMName), - } - return fmt.Sprintf("Managed H S M (%s)", strings.Join(components, "\n")) -} diff --git a/resource-manager/keyvault/2022-11-01/mhsmprivatelinkresources/id_managedhsm_test.go b/resource-manager/keyvault/2022-11-01/mhsmprivatelinkresources/id_managedhsm_test.go deleted file mode 100644 index 25de48e1d9a..00000000000 --- a/resource-manager/keyvault/2022-11-01/mhsmprivatelinkresources/id_managedhsm_test.go +++ /dev/null @@ -1,282 +0,0 @@ -package mhsmprivatelinkresources - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -var _ resourceids.ResourceId = &ManagedHSMId{} - -func TestNewManagedHSMID(t *testing.T) { - id := NewManagedHSMID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedHSMValue") - - if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { - t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") - } - - if id.ResourceGroupName != "example-resource-group" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") - } - - if id.ManagedHSMName != "managedHSMValue" { - t.Fatalf("Expected %q but got %q for Segment 'ManagedHSMName'", id.ManagedHSMName, "managedHSMValue") - } -} - -func TestFormatManagedHSMID(t *testing.T) { - actual := NewManagedHSMID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedHSMValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseManagedHSMID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *ManagedHSMId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue", - Expected: &ManagedHSMId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ManagedHSMName: "managedHSMValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseManagedHSMID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.ManagedHSMName != v.Expected.ManagedHSMName { - t.Fatalf("Expected %q but got %q for ManagedHSMName", v.Expected.ManagedHSMName, actual.ManagedHSMName) - } - - } -} - -func TestParseManagedHSMIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *ManagedHSMId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/mAnAgEdHsMs", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue", - Expected: &ManagedHSMId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ManagedHSMName: "managedHSMValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/managedHSMs/managedHSMValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/mAnAgEdHsMs/mAnAgEdHsMvAlUe", - Expected: &ManagedHSMId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - ManagedHSMName: "mAnAgEdHsMvAlUe", - }, - }, - { - // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/mAnAgEdHsMs/mAnAgEdHsMvAlUe/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseManagedHSMIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.ManagedHSMName != v.Expected.ManagedHSMName { - t.Fatalf("Expected %q but got %q for ManagedHSMName", v.Expected.ManagedHSMName, actual.ManagedHSMName) - } - - } -} - -func TestSegmentsForManagedHSMId(t *testing.T) { - segments := ManagedHSMId{}.Segments() - if len(segments) == 0 { - t.Fatalf("ManagedHSMId has no segments") - } - - uniqueNames := make(map[string]struct{}, 0) - for _, segment := range segments { - uniqueNames[segment.Name] = struct{}{} - } - if len(uniqueNames) != len(segments) { - t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) - } -} diff --git a/resource-manager/keyvault/2022-11-01/mhsmprivatelinkresources/method_listbymhsmresource_autorest.go b/resource-manager/keyvault/2022-11-01/mhsmprivatelinkresources/method_listbymhsmresource_autorest.go deleted file mode 100644 index 039d077edfe..00000000000 --- a/resource-manager/keyvault/2022-11-01/mhsmprivatelinkresources/method_listbymhsmresource_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package mhsmprivatelinkresources - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByMHSMResourceOperationResponse struct { - HttpResponse *http.Response - Model *MHSMPrivateLinkResourceListResult -} - -// ListByMHSMResource ... -func (c MHSMPrivateLinkResourcesClient) ListByMHSMResource(ctx context.Context, id ManagedHSMId) (result ListByMHSMResourceOperationResponse, err error) { - req, err := c.preparerForListByMHSMResource(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmprivatelinkresources.MHSMPrivateLinkResourcesClient", "ListByMHSMResource", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmprivatelinkresources.MHSMPrivateLinkResourcesClient", "ListByMHSMResource", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByMHSMResource(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmprivatelinkresources.MHSMPrivateLinkResourcesClient", "ListByMHSMResource", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByMHSMResource prepares the ListByMHSMResource request. -func (c MHSMPrivateLinkResourcesClient) preparerForListByMHSMResource(ctx context.Context, id ManagedHSMId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/privateLinkResources", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByMHSMResource handles the response to the ListByMHSMResource request. The method always -// closes the http.Response Body. -func (c MHSMPrivateLinkResourcesClient) responderForListByMHSMResource(resp *http.Response) (result ListByMHSMResourceOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2022-11-01/mhsmprivatelinkresources/model_managedhsmsku.go b/resource-manager/keyvault/2022-11-01/mhsmprivatelinkresources/model_managedhsmsku.go deleted file mode 100644 index 31124d8e20f..00000000000 --- a/resource-manager/keyvault/2022-11-01/mhsmprivatelinkresources/model_managedhsmsku.go +++ /dev/null @@ -1,9 +0,0 @@ -package mhsmprivatelinkresources - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ManagedHsmSku struct { - Family ManagedHsmSkuFamily `json:"family"` - Name ManagedHsmSkuName `json:"name"` -} diff --git a/resource-manager/keyvault/2022-11-01/mhsmprivatelinkresources/model_mhsmprivatelinkresource.go b/resource-manager/keyvault/2022-11-01/mhsmprivatelinkresources/model_mhsmprivatelinkresource.go deleted file mode 100644 index 292a506a4d5..00000000000 --- a/resource-manager/keyvault/2022-11-01/mhsmprivatelinkresources/model_mhsmprivatelinkresource.go +++ /dev/null @@ -1,19 +0,0 @@ -package mhsmprivatelinkresources - -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 MHSMPrivateLinkResource struct { - Id *string `json:"id,omitempty"` - Location *string `json:"location,omitempty"` - Name *string `json:"name,omitempty"` - Properties *MHSMPrivateLinkResourceProperties `json:"properties,omitempty"` - Sku *ManagedHsmSku `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/keyvault/2022-11-01/mhsmprivatelinkresources/model_mhsmprivatelinkresourcelistresult.go b/resource-manager/keyvault/2022-11-01/mhsmprivatelinkresources/model_mhsmprivatelinkresourcelistresult.go deleted file mode 100644 index 1589954fa56..00000000000 --- a/resource-manager/keyvault/2022-11-01/mhsmprivatelinkresources/model_mhsmprivatelinkresourcelistresult.go +++ /dev/null @@ -1,8 +0,0 @@ -package mhsmprivatelinkresources - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type MHSMPrivateLinkResourceListResult struct { - Value *[]MHSMPrivateLinkResource `json:"value,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/mhsmprivatelinkresources/model_mhsmprivatelinkresourceproperties.go b/resource-manager/keyvault/2022-11-01/mhsmprivatelinkresources/model_mhsmprivatelinkresourceproperties.go deleted file mode 100644 index 318dc85b436..00000000000 --- a/resource-manager/keyvault/2022-11-01/mhsmprivatelinkresources/model_mhsmprivatelinkresourceproperties.go +++ /dev/null @@ -1,10 +0,0 @@ -package mhsmprivatelinkresources - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type MHSMPrivateLinkResourceProperties struct { - GroupId *string `json:"groupId,omitempty"` - RequiredMembers *[]string `json:"requiredMembers,omitempty"` - RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/mhsmprivatelinkresources/version.go b/resource-manager/keyvault/2022-11-01/mhsmprivatelinkresources/version.go deleted file mode 100644 index 257dbfaa52a..00000000000 --- a/resource-manager/keyvault/2022-11-01/mhsmprivatelinkresources/version.go +++ /dev/null @@ -1,12 +0,0 @@ -package mhsmprivatelinkresources - -import "fmt" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -const defaultApiVersion = "2022-11-01" - -func userAgent() string { - return fmt.Sprintf("hashicorp/go-azure-sdk/mhsmprivatelinkresources/%s", defaultApiVersion) -} diff --git a/resource-manager/keyvault/2022-11-01/privateendpointconnections/README.md b/resource-manager/keyvault/2022-11-01/privateendpointconnections/README.md deleted file mode 100644 index 03aedd94503..00000000000 --- a/resource-manager/keyvault/2022-11-01/privateendpointconnections/README.md +++ /dev/null @@ -1,86 +0,0 @@ - -## `github.com/hashicorp/go-azure-sdk/resource-manager/keyvault/2022-11-01/privateendpointconnections` Documentation - -The `privateendpointconnections` SDK allows for interaction with the Azure Resource Manager Service `keyvault` (API Version `2022-11-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/keyvault/2022-11-01/privateendpointconnections" -``` - - -### Client Initialization - -```go -client := privateendpointconnections.NewPrivateEndpointConnectionsClientWithBaseURI("https://management.azure.com") -client.Client.Authorizer = authorizer -``` - - -### Example Usage: `PrivateEndpointConnectionsClient.Delete` - -```go -ctx := context.TODO() -id := privateendpointconnections.NewKeyVaultPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "privateEndpointConnectionValue") - -if err := client.DeleteThenPoll(ctx, id); err != nil { - // handle the error -} -``` - - -### Example Usage: `PrivateEndpointConnectionsClient.Get` - -```go -ctx := context.TODO() -id := privateendpointconnections.NewKeyVaultPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "privateEndpointConnectionValue") - -read, err := client.Get(ctx, id) -if err != nil { - // handle the error -} -if model := read.Model; model != nil { - // do something with the model/response object -} -``` - - -### Example Usage: `PrivateEndpointConnectionsClient.ListByResource` - -```go -ctx := context.TODO() -id := privateendpointconnections.NewKeyVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") - -// alternatively `client.ListByResource(ctx, id)` can be used to do batched pagination -items, err := client.ListByResourceComplete(ctx, id) -if err != nil { - // handle the error -} -for _, item := range items { - // do something -} -``` - - -### Example Usage: `PrivateEndpointConnectionsClient.Put` - -```go -ctx := context.TODO() -id := privateendpointconnections.NewKeyVaultPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "privateEndpointConnectionValue") - -payload := privateendpointconnections.PrivateEndpointConnection{ - // ... -} - - -read, err := client.Put(ctx, id, payload) -if err != nil { - // handle the error -} -if model := read.Model; model != nil { - // do something with the model/response object -} -``` diff --git a/resource-manager/keyvault/2022-11-01/privateendpointconnections/client.go b/resource-manager/keyvault/2022-11-01/privateendpointconnections/client.go deleted file mode 100644 index 1de584406fe..00000000000 --- a/resource-manager/keyvault/2022-11-01/privateendpointconnections/client.go +++ /dev/null @@ -1,18 +0,0 @@ -package privateendpointconnections - -import "github.com/Azure/go-autorest/autorest" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PrivateEndpointConnectionsClient struct { - Client autorest.Client - baseUri string -} - -func NewPrivateEndpointConnectionsClientWithBaseURI(endpoint string) PrivateEndpointConnectionsClient { - return PrivateEndpointConnectionsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/resource-manager/keyvault/2022-11-01/privateendpointconnections/constants.go b/resource-manager/keyvault/2022-11-01/privateendpointconnections/constants.go deleted file mode 100644 index 127a9d9aafd..00000000000 --- a/resource-manager/keyvault/2022-11-01/privateendpointconnections/constants.go +++ /dev/null @@ -1,105 +0,0 @@ -package privateendpointconnections - -import "strings" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ActionsRequired string - -const ( - ActionsRequiredNone ActionsRequired = "None" -) - -func PossibleValuesForActionsRequired() []string { - return []string{ - string(ActionsRequiredNone), - } -} - -func parseActionsRequired(input string) (*ActionsRequired, error) { - vals := map[string]ActionsRequired{ - "none": ActionsRequiredNone, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ActionsRequired(input) - return &out, nil -} - -type PrivateEndpointConnectionProvisioningState string - -const ( - PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" - PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" - PrivateEndpointConnectionProvisioningStateDisconnected PrivateEndpointConnectionProvisioningState = "Disconnected" - PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" - PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" - PrivateEndpointConnectionProvisioningStateUpdating PrivateEndpointConnectionProvisioningState = "Updating" -) - -func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { - return []string{ - string(PrivateEndpointConnectionProvisioningStateCreating), - string(PrivateEndpointConnectionProvisioningStateDeleting), - string(PrivateEndpointConnectionProvisioningStateDisconnected), - string(PrivateEndpointConnectionProvisioningStateFailed), - string(PrivateEndpointConnectionProvisioningStateSucceeded), - string(PrivateEndpointConnectionProvisioningStateUpdating), - } -} - -func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { - vals := map[string]PrivateEndpointConnectionProvisioningState{ - "creating": PrivateEndpointConnectionProvisioningStateCreating, - "deleting": PrivateEndpointConnectionProvisioningStateDeleting, - "disconnected": PrivateEndpointConnectionProvisioningStateDisconnected, - "failed": PrivateEndpointConnectionProvisioningStateFailed, - "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, - "updating": PrivateEndpointConnectionProvisioningStateUpdating, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := PrivateEndpointConnectionProvisioningState(input) - return &out, nil -} - -type PrivateEndpointServiceConnectionStatus string - -const ( - PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" - PrivateEndpointServiceConnectionStatusDisconnected PrivateEndpointServiceConnectionStatus = "Disconnected" - PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" - PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" -) - -func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { - return []string{ - string(PrivateEndpointServiceConnectionStatusApproved), - string(PrivateEndpointServiceConnectionStatusDisconnected), - string(PrivateEndpointServiceConnectionStatusPending), - string(PrivateEndpointServiceConnectionStatusRejected), - } -} - -func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { - vals := map[string]PrivateEndpointServiceConnectionStatus{ - "approved": PrivateEndpointServiceConnectionStatusApproved, - "disconnected": PrivateEndpointServiceConnectionStatusDisconnected, - "pending": PrivateEndpointServiceConnectionStatusPending, - "rejected": PrivateEndpointServiceConnectionStatusRejected, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := PrivateEndpointServiceConnectionStatus(input) - return &out, nil -} diff --git a/resource-manager/keyvault/2022-11-01/privateendpointconnections/method_delete_autorest.go b/resource-manager/keyvault/2022-11-01/privateendpointconnections/method_delete_autorest.go deleted file mode 100644 index 4703a8f08ad..00000000000 --- a/resource-manager/keyvault/2022-11-01/privateendpointconnections/method_delete_autorest.go +++ /dev/null @@ -1,80 +0,0 @@ -package privateendpointconnections - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response - Model *PrivateEndpointConnection -} - -// Delete ... -func (c PrivateEndpointConnectionsClient) Delete(ctx context.Context, id commonids.KeyVaultPrivateEndpointConnectionId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c PrivateEndpointConnectionsClient) DeleteThenPoll(ctx context.Context, id commonids.KeyVaultPrivateEndpointConnectionId) error { - result, err := c.Delete(ctx, id) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} - -// preparerForDelete prepares the Delete request. -func (c PrivateEndpointConnectionsClient) preparerForDelete(ctx context.Context, id commonids.KeyVaultPrivateEndpointConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDelete sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (c PrivateEndpointConnectionsClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/keyvault/2022-11-01/privateendpointconnections/method_get_autorest.go b/resource-manager/keyvault/2022-11-01/privateendpointconnections/method_get_autorest.go deleted file mode 100644 index 6c5953b7a4e..00000000000 --- a/resource-manager/keyvault/2022-11-01/privateendpointconnections/method_get_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package privateendpointconnections - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *PrivateEndpointConnection -} - -// Get ... -func (c PrivateEndpointConnectionsClient) Get(ctx context.Context, id commonids.KeyVaultPrivateEndpointConnectionId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c PrivateEndpointConnectionsClient) preparerForGet(ctx context.Context, id commonids.KeyVaultPrivateEndpointConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c PrivateEndpointConnectionsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2022-11-01/privateendpointconnections/method_listbyresource_autorest.go b/resource-manager/keyvault/2022-11-01/privateendpointconnections/method_listbyresource_autorest.go deleted file mode 100644 index 04d7c90769d..00000000000 --- a/resource-manager/keyvault/2022-11-01/privateendpointconnections/method_listbyresource_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package privateendpointconnections - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByResourceOperationResponse struct { - HttpResponse *http.Response - Model *[]PrivateEndpointConnection - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByResourceOperationResponse, error) -} - -type ListByResourceCompleteResult struct { - Items []PrivateEndpointConnection -} - -func (r ListByResourceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByResourceOperationResponse) LoadMore(ctx context.Context) (resp ListByResourceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByResource ... -func (c PrivateEndpointConnectionsClient) ListByResource(ctx context.Context, id commonids.KeyVaultId) (resp ListByResourceOperationResponse, err error) { - req, err := c.preparerForListByResource(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "ListByResource", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "ListByResource", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByResource(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "ListByResource", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByResource prepares the ListByResource request. -func (c PrivateEndpointConnectionsClient) preparerForListByResource(ctx context.Context, id commonids.KeyVaultId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/privateEndpointConnections", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByResourceWithNextLink prepares the ListByResource request with the given nextLink token. -func (c PrivateEndpointConnectionsClient) preparerForListByResourceWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByResource handles the response to the ListByResource request. The method always -// closes the http.Response Body. -func (c PrivateEndpointConnectionsClient) responderForListByResource(resp *http.Response) (result ListByResourceOperationResponse, err error) { - type page struct { - Values []PrivateEndpointConnection `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByResourceOperationResponse, err error) { - req, err := c.preparerForListByResourceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "ListByResource", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "ListByResource", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByResource(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "ListByResource", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByResourceComplete retrieves all of the results into a single object -func (c PrivateEndpointConnectionsClient) ListByResourceComplete(ctx context.Context, id commonids.KeyVaultId) (ListByResourceCompleteResult, error) { - return c.ListByResourceCompleteMatchingPredicate(ctx, id, PrivateEndpointConnectionOperationPredicate{}) -} - -// ListByResourceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c PrivateEndpointConnectionsClient) ListByResourceCompleteMatchingPredicate(ctx context.Context, id commonids.KeyVaultId, predicate PrivateEndpointConnectionOperationPredicate) (resp ListByResourceCompleteResult, err error) { - items := make([]PrivateEndpointConnection, 0) - - page, err := c.ListByResource(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByResourceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/keyvault/2022-11-01/privateendpointconnections/method_put_autorest.go b/resource-manager/keyvault/2022-11-01/privateendpointconnections/method_put_autorest.go deleted file mode 100644 index 20a86574f4c..00000000000 --- a/resource-manager/keyvault/2022-11-01/privateendpointconnections/method_put_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package privateendpointconnections - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PutOperationResponse struct { - HttpResponse *http.Response - Model *PrivateEndpointConnection -} - -// Put ... -func (c PrivateEndpointConnectionsClient) Put(ctx context.Context, id commonids.KeyVaultPrivateEndpointConnectionId, input PrivateEndpointConnection) (result PutOperationResponse, err error) { - req, err := c.preparerForPut(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Put", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Put", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForPut(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Put", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForPut prepares the Put request. -func (c PrivateEndpointConnectionsClient) preparerForPut(ctx context.Context, id commonids.KeyVaultPrivateEndpointConnectionId, input PrivateEndpointConnection) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForPut handles the response to the Put request. The method always -// closes the http.Response Body. -func (c PrivateEndpointConnectionsClient) responderForPut(resp *http.Response) (result PutOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2022-11-01/privateendpointconnections/model_privateendpoint.go b/resource-manager/keyvault/2022-11-01/privateendpointconnections/model_privateendpoint.go deleted file mode 100644 index 1bc8cf2a97c..00000000000 --- a/resource-manager/keyvault/2022-11-01/privateendpointconnections/model_privateendpoint.go +++ /dev/null @@ -1,8 +0,0 @@ -package privateendpointconnections - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PrivateEndpoint struct { - Id *string `json:"id,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/privateendpointconnections/model_privateendpointconnection.go b/resource-manager/keyvault/2022-11-01/privateendpointconnections/model_privateendpointconnection.go deleted file mode 100644 index 74b0e5c4644..00000000000 --- a/resource-manager/keyvault/2022-11-01/privateendpointconnections/model_privateendpointconnection.go +++ /dev/null @@ -1,14 +0,0 @@ -package privateendpointconnections - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PrivateEndpointConnection struct { - Etag *string `json:"etag,omitempty"` - Id *string `json:"id,omitempty"` - Location *string `json:"location,omitempty"` - Name *string `json:"name,omitempty"` - Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` - Tags *map[string]string `json:"tags,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/privateendpointconnections/model_privateendpointconnectionproperties.go b/resource-manager/keyvault/2022-11-01/privateendpointconnections/model_privateendpointconnectionproperties.go deleted file mode 100644 index 78e87db45fe..00000000000 --- a/resource-manager/keyvault/2022-11-01/privateendpointconnections/model_privateendpointconnectionproperties.go +++ /dev/null @@ -1,10 +0,0 @@ -package privateendpointconnections - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PrivateEndpointConnectionProperties struct { - PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` - PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` - ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/privateendpointconnections/model_privatelinkserviceconnectionstate.go b/resource-manager/keyvault/2022-11-01/privateendpointconnections/model_privatelinkserviceconnectionstate.go deleted file mode 100644 index ca71b62e3ff..00000000000 --- a/resource-manager/keyvault/2022-11-01/privateendpointconnections/model_privatelinkserviceconnectionstate.go +++ /dev/null @@ -1,10 +0,0 @@ -package privateendpointconnections - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PrivateLinkServiceConnectionState struct { - ActionsRequired *ActionsRequired `json:"actionsRequired,omitempty"` - Description *string `json:"description,omitempty"` - Status *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/privateendpointconnections/predicates.go b/resource-manager/keyvault/2022-11-01/privateendpointconnections/predicates.go deleted file mode 100644 index accb20a0cc4..00000000000 --- a/resource-manager/keyvault/2022-11-01/privateendpointconnections/predicates.go +++ /dev/null @@ -1,37 +0,0 @@ -package privateendpointconnections - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PrivateEndpointConnectionOperationPredicate struct { - Etag *string - Id *string - Location *string - Name *string - Type *string -} - -func (p PrivateEndpointConnectionOperationPredicate) Matches(input PrivateEndpointConnection) bool { - - if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { - return false - } - - if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { - return false - } - - if p.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/keyvault/2022-11-01/privateendpointconnections/version.go b/resource-manager/keyvault/2022-11-01/privateendpointconnections/version.go deleted file mode 100644 index bb3f46ca7b6..00000000000 --- a/resource-manager/keyvault/2022-11-01/privateendpointconnections/version.go +++ /dev/null @@ -1,12 +0,0 @@ -package privateendpointconnections - -import "fmt" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -const defaultApiVersion = "2022-11-01" - -func userAgent() string { - return fmt.Sprintf("hashicorp/go-azure-sdk/privateendpointconnections/%s", defaultApiVersion) -} diff --git a/resource-manager/keyvault/2022-11-01/privatelinkresources/README.md b/resource-manager/keyvault/2022-11-01/privatelinkresources/README.md deleted file mode 100644 index 1e9b517227f..00000000000 --- a/resource-manager/keyvault/2022-11-01/privatelinkresources/README.md +++ /dev/null @@ -1,36 +0,0 @@ - -## `github.com/hashicorp/go-azure-sdk/resource-manager/keyvault/2022-11-01/privatelinkresources` Documentation - -The `privatelinkresources` SDK allows for interaction with the Azure Resource Manager Service `keyvault` (API Version `2022-11-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/keyvault/2022-11-01/privatelinkresources" -``` - - -### Client Initialization - -```go -client := privatelinkresources.NewPrivateLinkResourcesClientWithBaseURI("https://management.azure.com") -client.Client.Authorizer = authorizer -``` - - -### Example Usage: `PrivateLinkResourcesClient.ListByVault` - -```go -ctx := context.TODO() -id := privatelinkresources.NewKeyVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") - -read, err := client.ListByVault(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/keyvault/2022-11-01/privatelinkresources/client.go b/resource-manager/keyvault/2022-11-01/privatelinkresources/client.go deleted file mode 100644 index 5f532940700..00000000000 --- a/resource-manager/keyvault/2022-11-01/privatelinkresources/client.go +++ /dev/null @@ -1,18 +0,0 @@ -package privatelinkresources - -import "github.com/Azure/go-autorest/autorest" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PrivateLinkResourcesClient struct { - Client autorest.Client - baseUri string -} - -func NewPrivateLinkResourcesClientWithBaseURI(endpoint string) PrivateLinkResourcesClient { - return PrivateLinkResourcesClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/resource-manager/keyvault/2022-11-01/privatelinkresources/method_listbyvault_autorest.go b/resource-manager/keyvault/2022-11-01/privatelinkresources/method_listbyvault_autorest.go deleted file mode 100644 index ec68e666d4b..00000000000 --- a/resource-manager/keyvault/2022-11-01/privatelinkresources/method_listbyvault_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package privatelinkresources - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByVaultOperationResponse struct { - HttpResponse *http.Response - Model *PrivateLinkResourceListResult -} - -// ListByVault ... -func (c PrivateLinkResourcesClient) ListByVault(ctx context.Context, id commonids.KeyVaultId) (result ListByVaultOperationResponse, err error) { - req, err := c.preparerForListByVault(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "ListByVault", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "ListByVault", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByVault(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "ListByVault", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByVault prepares the ListByVault request. -func (c PrivateLinkResourcesClient) preparerForListByVault(ctx context.Context, id commonids.KeyVaultId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/privateLinkResources", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByVault handles the response to the ListByVault request. The method always -// closes the http.Response Body. -func (c PrivateLinkResourcesClient) responderForListByVault(resp *http.Response) (result ListByVaultOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2022-11-01/privatelinkresources/model_privatelinkresource.go b/resource-manager/keyvault/2022-11-01/privatelinkresources/model_privatelinkresource.go deleted file mode 100644 index 8bcc42fe6ee..00000000000 --- a/resource-manager/keyvault/2022-11-01/privatelinkresources/model_privatelinkresource.go +++ /dev/null @@ -1,13 +0,0 @@ -package privatelinkresources - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PrivateLinkResource struct { - Id *string `json:"id,omitempty"` - Location *string `json:"location,omitempty"` - Name *string `json:"name,omitempty"` - Properties *PrivateLinkResourceProperties `json:"properties,omitempty"` - Tags *map[string]string `json:"tags,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/privatelinkresources/model_privatelinkresourcelistresult.go b/resource-manager/keyvault/2022-11-01/privatelinkresources/model_privatelinkresourcelistresult.go deleted file mode 100644 index fa950217c47..00000000000 --- a/resource-manager/keyvault/2022-11-01/privatelinkresources/model_privatelinkresourcelistresult.go +++ /dev/null @@ -1,8 +0,0 @@ -package privatelinkresources - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PrivateLinkResourceListResult struct { - Value *[]PrivateLinkResource `json:"value,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/privatelinkresources/model_privatelinkresourceproperties.go b/resource-manager/keyvault/2022-11-01/privatelinkresources/model_privatelinkresourceproperties.go deleted file mode 100644 index 3c98012cdd1..00000000000 --- a/resource-manager/keyvault/2022-11-01/privatelinkresources/model_privatelinkresourceproperties.go +++ /dev/null @@ -1,10 +0,0 @@ -package privatelinkresources - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PrivateLinkResourceProperties struct { - GroupId *string `json:"groupId,omitempty"` - RequiredMembers *[]string `json:"requiredMembers,omitempty"` - RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/privatelinkresources/version.go b/resource-manager/keyvault/2022-11-01/privatelinkresources/version.go deleted file mode 100644 index 8a416239999..00000000000 --- a/resource-manager/keyvault/2022-11-01/privatelinkresources/version.go +++ /dev/null @@ -1,12 +0,0 @@ -package privatelinkresources - -import "fmt" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -const defaultApiVersion = "2022-11-01" - -func userAgent() string { - return fmt.Sprintf("hashicorp/go-azure-sdk/privatelinkresources/%s", defaultApiVersion) -} diff --git a/resource-manager/keyvault/2022-11-01/secrets/README.md b/resource-manager/keyvault/2022-11-01/secrets/README.md deleted file mode 100644 index 313e448e846..00000000000 --- a/resource-manager/keyvault/2022-11-01/secrets/README.md +++ /dev/null @@ -1,95 +0,0 @@ - -## `github.com/hashicorp/go-azure-sdk/resource-manager/keyvault/2022-11-01/secrets` Documentation - -The `secrets` SDK allows for interaction with the Azure Resource Manager Service `keyvault` (API Version `2022-11-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/keyvault/2022-11-01/secrets" -``` - - -### Client Initialization - -```go -client := secrets.NewSecretsClientWithBaseURI("https://management.azure.com") -client.Client.Authorizer = authorizer -``` - - -### Example Usage: `SecretsClient.CreateOrUpdate` - -```go -ctx := context.TODO() -id := secrets.NewSecretID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "secretValue") - -payload := secrets.SecretCreateOrUpdateParameters{ - // ... -} - - -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: `SecretsClient.Get` - -```go -ctx := context.TODO() -id := secrets.NewSecretID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "secretValue") - -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: `SecretsClient.List` - -```go -ctx := context.TODO() -id := secrets.NewKeyVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") - -// alternatively `client.List(ctx, id, secrets.DefaultListOperationOptions())` can be used to do batched pagination -items, err := client.ListComplete(ctx, id, secrets.DefaultListOperationOptions()) -if err != nil { - // handle the error -} -for _, item := range items { - // do something -} -``` - - -### Example Usage: `SecretsClient.Update` - -```go -ctx := context.TODO() -id := secrets.NewSecretID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "secretValue") - -payload := secrets.SecretPatchParameters{ - // ... -} - - -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/keyvault/2022-11-01/secrets/client.go b/resource-manager/keyvault/2022-11-01/secrets/client.go deleted file mode 100644 index ab0463026ab..00000000000 --- a/resource-manager/keyvault/2022-11-01/secrets/client.go +++ /dev/null @@ -1,18 +0,0 @@ -package secrets - -import "github.com/Azure/go-autorest/autorest" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type SecretsClient struct { - Client autorest.Client - baseUri string -} - -func NewSecretsClientWithBaseURI(endpoint string) SecretsClient { - return SecretsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/resource-manager/keyvault/2022-11-01/secrets/id_secret.go b/resource-manager/keyvault/2022-11-01/secrets/id_secret.go deleted file mode 100644 index 94dd626c66c..00000000000 --- a/resource-manager/keyvault/2022-11-01/secrets/id_secret.go +++ /dev/null @@ -1,134 +0,0 @@ -package secrets - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -var _ resourceids.ResourceId = &SecretId{} - -// SecretId is a struct representing the Resource ID for a Secret -type SecretId struct { - SubscriptionId string - ResourceGroupName string - VaultName string - SecretName string -} - -// NewSecretID returns a new SecretId struct -func NewSecretID(subscriptionId string, resourceGroupName string, vaultName string, secretName string) SecretId { - return SecretId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - VaultName: vaultName, - SecretName: secretName, - } -} - -// ParseSecretID parses 'input' into a SecretId -func ParseSecretID(input string) (*SecretId, error) { - parser := resourceids.NewParserFromResourceIdType(&SecretId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := SecretId{} - if err := id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -// ParseSecretIDInsensitively parses 'input' case-insensitively into a SecretId -// note: this method should only be used for API response data and not user input -func ParseSecretIDInsensitively(input string) (*SecretId, error) { - parser := resourceids.NewParserFromResourceIdType(&SecretId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := SecretId{} - if err := id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -func (id *SecretId) FromParseResult(input resourceids.ParseResult) error { - var ok bool - - if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) - } - - if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) - } - - if id.VaultName, ok = input.Parsed["vaultName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) - } - - if id.SecretName, ok = input.Parsed["secretName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "secretName", input) - } - - return nil -} - -// ValidateSecretID checks that 'input' can be parsed as a Secret ID -func ValidateSecretID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParseSecretID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Secret ID -func (id SecretId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.KeyVault/vaults/%s/secrets/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.SecretName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Secret ID -func (id SecretId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftKeyVault", "Microsoft.KeyVault", "Microsoft.KeyVault"), - resourceids.StaticSegment("staticVaults", "vaults", "vaults"), - resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), - resourceids.StaticSegment("staticSecrets", "secrets", "secrets"), - resourceids.UserSpecifiedSegment("secretName", "secretValue"), - } -} - -// String returns a human-readable description of this Secret ID -func (id SecretId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Vault Name: %q", id.VaultName), - fmt.Sprintf("Secret Name: %q", id.SecretName), - } - return fmt.Sprintf("Secret (%s)", strings.Join(components, "\n")) -} diff --git a/resource-manager/keyvault/2022-11-01/secrets/id_secret_test.go b/resource-manager/keyvault/2022-11-01/secrets/id_secret_test.go deleted file mode 100644 index a6c6e872056..00000000000 --- a/resource-manager/keyvault/2022-11-01/secrets/id_secret_test.go +++ /dev/null @@ -1,327 +0,0 @@ -package secrets - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -var _ resourceids.ResourceId = &SecretId{} - -func TestNewSecretID(t *testing.T) { - id := NewSecretID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "secretValue") - - if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { - t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") - } - - if id.ResourceGroupName != "example-resource-group" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") - } - - if id.VaultName != "vaultValue" { - t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") - } - - if id.SecretName != "secretValue" { - t.Fatalf("Expected %q but got %q for Segment 'SecretName'", id.SecretName, "secretValue") - } -} - -func TestFormatSecretID(t *testing.T) { - actual := NewSecretID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "secretValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/vaults/vaultValue/secrets/secretValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseSecretID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *SecretId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/vaults", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/vaults/vaultValue", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/vaults/vaultValue/secrets", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/vaults/vaultValue/secrets/secretValue", - Expected: &SecretId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - VaultName: "vaultValue", - SecretName: "secretValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/vaults/vaultValue/secrets/secretValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseSecretID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.VaultName != v.Expected.VaultName { - t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) - } - - if actual.SecretName != v.Expected.SecretName { - t.Fatalf("Expected %q but got %q for SecretName", v.Expected.SecretName, actual.SecretName) - } - - } -} - -func TestParseSecretIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *SecretId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/vaults", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/vAuLtS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/vaults/vaultValue", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/vAuLtS/vAuLtVaLuE", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/vaults/vaultValue/secrets", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/vAuLtS/vAuLtVaLuE/sEcReTs", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/vaults/vaultValue/secrets/secretValue", - Expected: &SecretId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - VaultName: "vaultValue", - SecretName: "secretValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/vaults/vaultValue/secrets/secretValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/vAuLtS/vAuLtVaLuE/sEcReTs/sEcReTvAlUe", - Expected: &SecretId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - VaultName: "vAuLtVaLuE", - SecretName: "sEcReTvAlUe", - }, - }, - { - // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/vAuLtS/vAuLtVaLuE/sEcReTs/sEcReTvAlUe/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseSecretIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.VaultName != v.Expected.VaultName { - t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) - } - - if actual.SecretName != v.Expected.SecretName { - t.Fatalf("Expected %q but got %q for SecretName", v.Expected.SecretName, actual.SecretName) - } - - } -} - -func TestSegmentsForSecretId(t *testing.T) { - segments := SecretId{}.Segments() - if len(segments) == 0 { - t.Fatalf("SecretId has no segments") - } - - uniqueNames := make(map[string]struct{}, 0) - for _, segment := range segments { - uniqueNames[segment.Name] = struct{}{} - } - if len(uniqueNames) != len(segments) { - t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) - } -} diff --git a/resource-manager/keyvault/2022-11-01/secrets/method_createorupdate_autorest.go b/resource-manager/keyvault/2022-11-01/secrets/method_createorupdate_autorest.go deleted file mode 100644 index dd60760906f..00000000000 --- a/resource-manager/keyvault/2022-11-01/secrets/method_createorupdate_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package secrets - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateOperationResponse struct { - HttpResponse *http.Response - Model *Secret -} - -// CreateOrUpdate ... -func (c SecretsClient) CreateOrUpdate(ctx context.Context, id SecretId, input SecretCreateOrUpdateParameters) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "secrets.SecretsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "secrets.SecretsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "secrets.SecretsClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c SecretsClient) preparerForCreateOrUpdate(ctx context.Context, id SecretId, input SecretCreateOrUpdateParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdate handles the response to the CreateOrUpdate request. The method always -// closes the http.Response Body. -func (c SecretsClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2022-11-01/secrets/method_get_autorest.go b/resource-manager/keyvault/2022-11-01/secrets/method_get_autorest.go deleted file mode 100644 index 3f83dfd6db7..00000000000 --- a/resource-manager/keyvault/2022-11-01/secrets/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package secrets - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *Secret -} - -// Get ... -func (c SecretsClient) Get(ctx context.Context, id SecretId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "secrets.SecretsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "secrets.SecretsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "secrets.SecretsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c SecretsClient) preparerForGet(ctx context.Context, id SecretId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c SecretsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2022-11-01/secrets/method_list_autorest.go b/resource-manager/keyvault/2022-11-01/secrets/method_list_autorest.go deleted file mode 100644 index e00c01e9111..00000000000 --- a/resource-manager/keyvault/2022-11-01/secrets/method_list_autorest.go +++ /dev/null @@ -1,216 +0,0 @@ -package secrets - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *[]Secret - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []Secret -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListOperationOptions struct { - Top *int64 -} - -func DefaultListOperationOptions() ListOperationOptions { - return ListOperationOptions{} -} - -func (o ListOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// List ... -func (c SecretsClient) List(ctx context.Context, id commonids.KeyVaultId, options ListOperationOptions) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "secrets.SecretsClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "secrets.SecretsClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "secrets.SecretsClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c SecretsClient) preparerForList(ctx context.Context, id commonids.KeyVaultId, options ListOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/secrets", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c SecretsClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c SecretsClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []Secret `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { - req, err := c.preparerForListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "secrets.SecretsClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "secrets.SecretsClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "secrets.SecretsClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c SecretsClient) ListComplete(ctx context.Context, id commonids.KeyVaultId, options ListOperationOptions) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, options, SecretOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c SecretsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.KeyVaultId, options ListOperationOptions, predicate SecretOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]Secret, 0) - - page, err := c.List(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/keyvault/2022-11-01/secrets/method_update_autorest.go b/resource-manager/keyvault/2022-11-01/secrets/method_update_autorest.go deleted file mode 100644 index 8d1da9199de..00000000000 --- a/resource-manager/keyvault/2022-11-01/secrets/method_update_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package secrets - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateOperationResponse struct { - HttpResponse *http.Response - Model *Secret -} - -// Update ... -func (c SecretsClient) Update(ctx context.Context, id SecretId, input SecretPatchParameters) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "secrets.SecretsClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "secrets.SecretsClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "secrets.SecretsClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c SecretsClient) preparerForUpdate(ctx context.Context, id SecretId, input SecretPatchParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdate handles the response to the Update request. The method always -// closes the http.Response Body. -func (c SecretsClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2022-11-01/secrets/model_attributes.go b/resource-manager/keyvault/2022-11-01/secrets/model_attributes.go deleted file mode 100644 index 7f0df4ceec4..00000000000 --- a/resource-manager/keyvault/2022-11-01/secrets/model_attributes.go +++ /dev/null @@ -1,12 +0,0 @@ -package secrets - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type Attributes struct { - Created *int64 `json:"created,omitempty"` - Enabled *bool `json:"enabled,omitempty"` - Exp *int64 `json:"exp,omitempty"` - Nbf *int64 `json:"nbf,omitempty"` - Updated *int64 `json:"updated,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/secrets/model_secret.go b/resource-manager/keyvault/2022-11-01/secrets/model_secret.go deleted file mode 100644 index 08ae4eaf41c..00000000000 --- a/resource-manager/keyvault/2022-11-01/secrets/model_secret.go +++ /dev/null @@ -1,13 +0,0 @@ -package secrets - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type Secret struct { - Id *string `json:"id,omitempty"` - Location *string `json:"location,omitempty"` - Name *string `json:"name,omitempty"` - Properties SecretProperties `json:"properties"` - Tags *map[string]string `json:"tags,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/secrets/model_secretcreateorupdateparameters.go b/resource-manager/keyvault/2022-11-01/secrets/model_secretcreateorupdateparameters.go deleted file mode 100644 index 490bd25485b..00000000000 --- a/resource-manager/keyvault/2022-11-01/secrets/model_secretcreateorupdateparameters.go +++ /dev/null @@ -1,9 +0,0 @@ -package secrets - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type SecretCreateOrUpdateParameters struct { - Properties SecretProperties `json:"properties"` - Tags *map[string]string `json:"tags,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/secrets/model_secretpatchparameters.go b/resource-manager/keyvault/2022-11-01/secrets/model_secretpatchparameters.go deleted file mode 100644 index cb0d643f77a..00000000000 --- a/resource-manager/keyvault/2022-11-01/secrets/model_secretpatchparameters.go +++ /dev/null @@ -1,9 +0,0 @@ -package secrets - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type SecretPatchParameters struct { - Properties *SecretPatchProperties `json:"properties,omitempty"` - Tags *map[string]string `json:"tags,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/secrets/model_secretpatchproperties.go b/resource-manager/keyvault/2022-11-01/secrets/model_secretpatchproperties.go deleted file mode 100644 index d5fb8bddecf..00000000000 --- a/resource-manager/keyvault/2022-11-01/secrets/model_secretpatchproperties.go +++ /dev/null @@ -1,10 +0,0 @@ -package secrets - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type SecretPatchProperties struct { - Attributes *Attributes `json:"attributes,omitempty"` - ContentType *string `json:"contentType,omitempty"` - Value *string `json:"value,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/secrets/model_secretproperties.go b/resource-manager/keyvault/2022-11-01/secrets/model_secretproperties.go deleted file mode 100644 index a11f76f93b9..00000000000 --- a/resource-manager/keyvault/2022-11-01/secrets/model_secretproperties.go +++ /dev/null @@ -1,12 +0,0 @@ -package secrets - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type SecretProperties struct { - Attributes *Attributes `json:"attributes,omitempty"` - ContentType *string `json:"contentType,omitempty"` - SecretUri *string `json:"secretUri,omitempty"` - SecretUriWithVersion *string `json:"secretUriWithVersion,omitempty"` - Value *string `json:"value,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/secrets/predicates.go b/resource-manager/keyvault/2022-11-01/secrets/predicates.go deleted file mode 100644 index 1eb8d4feaa8..00000000000 --- a/resource-manager/keyvault/2022-11-01/secrets/predicates.go +++ /dev/null @@ -1,32 +0,0 @@ -package secrets - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type SecretOperationPredicate struct { - Id *string - Location *string - Name *string - Type *string -} - -func (p SecretOperationPredicate) Matches(input Secret) 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/keyvault/2022-11-01/secrets/version.go b/resource-manager/keyvault/2022-11-01/secrets/version.go deleted file mode 100644 index 413c8f9172b..00000000000 --- a/resource-manager/keyvault/2022-11-01/secrets/version.go +++ /dev/null @@ -1,12 +0,0 @@ -package secrets - -import "fmt" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -const defaultApiVersion = "2022-11-01" - -func userAgent() string { - return fmt.Sprintf("hashicorp/go-azure-sdk/secrets/%s", defaultApiVersion) -} diff --git a/resource-manager/keyvault/2022-11-01/vaults/README.md b/resource-manager/keyvault/2022-11-01/vaults/README.md deleted file mode 100644 index f4ed147c86d..00000000000 --- a/resource-manager/keyvault/2022-11-01/vaults/README.md +++ /dev/null @@ -1,228 +0,0 @@ - -## `github.com/hashicorp/go-azure-sdk/resource-manager/keyvault/2022-11-01/vaults` Documentation - -The `vaults` SDK allows for interaction with the Azure Resource Manager Service `keyvault` (API Version `2022-11-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/keyvault/2022-11-01/vaults" -``` - - -### Client Initialization - -```go -client := vaults.NewVaultsClientWithBaseURI("https://management.azure.com") -client.Client.Authorizer = authorizer -``` - - -### Example Usage: `VaultsClient.CheckNameAvailability` - -```go -ctx := context.TODO() -id := vaults.NewSubscriptionID("12345678-1234-9876-4563-123456789012") - -payload := vaults.VaultCheckNameAvailabilityParameters{ - // ... -} - - -read, err := client.CheckNameAvailability(ctx, id, payload) -if err != nil { - // handle the error -} -if model := read.Model; model != nil { - // do something with the model/response object -} -``` - - -### Example Usage: `VaultsClient.CreateOrUpdate` - -```go -ctx := context.TODO() -id := vaults.NewKeyVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") - -payload := vaults.VaultCreateOrUpdateParameters{ - // ... -} - - -if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { - // handle the error -} -``` - - -### Example Usage: `VaultsClient.Delete` - -```go -ctx := context.TODO() -id := vaults.NewKeyVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") - -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: `VaultsClient.Get` - -```go -ctx := context.TODO() -id := vaults.NewKeyVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") - -read, err := client.Get(ctx, id) -if err != nil { - // handle the error -} -if model := read.Model; model != nil { - // do something with the model/response object -} -``` - - -### Example Usage: `VaultsClient.GetDeleted` - -```go -ctx := context.TODO() -id := vaults.NewDeletedVaultID("12345678-1234-9876-4563-123456789012", "locationValue", "deletedVaultValue") - -read, err := client.GetDeleted(ctx, id) -if err != nil { - // handle the error -} -if model := read.Model; model != nil { - // do something with the model/response object -} -``` - - -### Example Usage: `VaultsClient.List` - -```go -ctx := context.TODO() -id := vaults.NewSubscriptionID("12345678-1234-9876-4563-123456789012") - -// alternatively `client.List(ctx, id, vaults.DefaultListOperationOptions())` can be used to do batched pagination -items, err := client.ListComplete(ctx, id, vaults.DefaultListOperationOptions()) -if err != nil { - // handle the error -} -for _, item := range items { - // do something -} -``` - - -### Example Usage: `VaultsClient.ListByResourceGroup` - -```go -ctx := context.TODO() -id := vaults.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") - -// alternatively `client.ListByResourceGroup(ctx, id, vaults.DefaultListByResourceGroupOperationOptions())` can be used to do batched pagination -items, err := client.ListByResourceGroupComplete(ctx, id, vaults.DefaultListByResourceGroupOperationOptions()) -if err != nil { - // handle the error -} -for _, item := range items { - // do something -} -``` - - -### Example Usage: `VaultsClient.ListBySubscription` - -```go -ctx := context.TODO() -id := vaults.NewSubscriptionID("12345678-1234-9876-4563-123456789012") - -// alternatively `client.ListBySubscription(ctx, id, vaults.DefaultListBySubscriptionOperationOptions())` can be used to do batched pagination -items, err := client.ListBySubscriptionComplete(ctx, id, vaults.DefaultListBySubscriptionOperationOptions()) -if err != nil { - // handle the error -} -for _, item := range items { - // do something -} -``` - - -### Example Usage: `VaultsClient.ListDeleted` - -```go -ctx := context.TODO() -id := vaults.NewSubscriptionID("12345678-1234-9876-4563-123456789012") - -// alternatively `client.ListDeleted(ctx, id)` can be used to do batched pagination -items, err := client.ListDeletedComplete(ctx, id) -if err != nil { - // handle the error -} -for _, item := range items { - // do something -} -``` - - -### Example Usage: `VaultsClient.PurgeDeleted` - -```go -ctx := context.TODO() -id := vaults.NewDeletedVaultID("12345678-1234-9876-4563-123456789012", "locationValue", "deletedVaultValue") - -if err := client.PurgeDeletedThenPoll(ctx, id); err != nil { - // handle the error -} -``` - - -### Example Usage: `VaultsClient.Update` - -```go -ctx := context.TODO() -id := vaults.NewKeyVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") - -payload := vaults.VaultPatchParameters{ - // ... -} - - -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: `VaultsClient.UpdateAccessPolicy` - -```go -ctx := context.TODO() -id := vaults.NewOperationKindID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "add") - -payload := vaults.VaultAccessPolicyParameters{ - // ... -} - - -read, err := client.UpdateAccessPolicy(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/keyvault/2022-11-01/vaults/client.go b/resource-manager/keyvault/2022-11-01/vaults/client.go deleted file mode 100644 index 6cad2ef703e..00000000000 --- a/resource-manager/keyvault/2022-11-01/vaults/client.go +++ /dev/null @@ -1,18 +0,0 @@ -package vaults - -import "github.com/Azure/go-autorest/autorest" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type VaultsClient struct { - Client autorest.Client - baseUri string -} - -func NewVaultsClientWithBaseURI(endpoint string) VaultsClient { - return VaultsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/resource-manager/keyvault/2022-11-01/vaults/constants.go b/resource-manager/keyvault/2022-11-01/vaults/constants.go deleted file mode 100644 index a9f3fd33ac5..00000000000 --- a/resource-manager/keyvault/2022-11-01/vaults/constants.go +++ /dev/null @@ -1,653 +0,0 @@ -package vaults - -import "strings" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type AccessPolicyUpdateKind string - -const ( - AccessPolicyUpdateKindAdd AccessPolicyUpdateKind = "add" - AccessPolicyUpdateKindRemove AccessPolicyUpdateKind = "remove" - AccessPolicyUpdateKindReplace AccessPolicyUpdateKind = "replace" -) - -func PossibleValuesForAccessPolicyUpdateKind() []string { - return []string{ - string(AccessPolicyUpdateKindAdd), - string(AccessPolicyUpdateKindRemove), - string(AccessPolicyUpdateKindReplace), - } -} - -func parseAccessPolicyUpdateKind(input string) (*AccessPolicyUpdateKind, error) { - vals := map[string]AccessPolicyUpdateKind{ - "add": AccessPolicyUpdateKindAdd, - "remove": AccessPolicyUpdateKindRemove, - "replace": AccessPolicyUpdateKindReplace, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := AccessPolicyUpdateKind(input) - return &out, nil -} - -type ActionsRequired string - -const ( - ActionsRequiredNone ActionsRequired = "None" -) - -func PossibleValuesForActionsRequired() []string { - return []string{ - string(ActionsRequiredNone), - } -} - -func parseActionsRequired(input string) (*ActionsRequired, error) { - vals := map[string]ActionsRequired{ - "none": ActionsRequiredNone, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ActionsRequired(input) - return &out, nil -} - -type CertificatePermissions string - -const ( - CertificatePermissionsAll CertificatePermissions = "all" - CertificatePermissionsBackup CertificatePermissions = "backup" - CertificatePermissionsCreate CertificatePermissions = "create" - CertificatePermissionsDelete CertificatePermissions = "delete" - CertificatePermissionsDeleteissuers CertificatePermissions = "deleteissuers" - CertificatePermissionsGet CertificatePermissions = "get" - CertificatePermissionsGetissuers CertificatePermissions = "getissuers" - CertificatePermissionsImport CertificatePermissions = "import" - CertificatePermissionsList CertificatePermissions = "list" - CertificatePermissionsListissuers CertificatePermissions = "listissuers" - CertificatePermissionsManagecontacts CertificatePermissions = "managecontacts" - CertificatePermissionsManageissuers CertificatePermissions = "manageissuers" - CertificatePermissionsPurge CertificatePermissions = "purge" - CertificatePermissionsRecover CertificatePermissions = "recover" - CertificatePermissionsRestore CertificatePermissions = "restore" - CertificatePermissionsSetissuers CertificatePermissions = "setissuers" - CertificatePermissionsUpdate CertificatePermissions = "update" -) - -func PossibleValuesForCertificatePermissions() []string { - return []string{ - string(CertificatePermissionsAll), - string(CertificatePermissionsBackup), - string(CertificatePermissionsCreate), - string(CertificatePermissionsDelete), - string(CertificatePermissionsDeleteissuers), - string(CertificatePermissionsGet), - string(CertificatePermissionsGetissuers), - string(CertificatePermissionsImport), - string(CertificatePermissionsList), - string(CertificatePermissionsListissuers), - string(CertificatePermissionsManagecontacts), - string(CertificatePermissionsManageissuers), - string(CertificatePermissionsPurge), - string(CertificatePermissionsRecover), - string(CertificatePermissionsRestore), - string(CertificatePermissionsSetissuers), - string(CertificatePermissionsUpdate), - } -} - -func parseCertificatePermissions(input string) (*CertificatePermissions, error) { - vals := map[string]CertificatePermissions{ - "all": CertificatePermissionsAll, - "backup": CertificatePermissionsBackup, - "create": CertificatePermissionsCreate, - "delete": CertificatePermissionsDelete, - "deleteissuers": CertificatePermissionsDeleteissuers, - "get": CertificatePermissionsGet, - "getissuers": CertificatePermissionsGetissuers, - "import": CertificatePermissionsImport, - "list": CertificatePermissionsList, - "listissuers": CertificatePermissionsListissuers, - "managecontacts": CertificatePermissionsManagecontacts, - "manageissuers": CertificatePermissionsManageissuers, - "purge": CertificatePermissionsPurge, - "recover": CertificatePermissionsRecover, - "restore": CertificatePermissionsRestore, - "setissuers": CertificatePermissionsSetissuers, - "update": CertificatePermissionsUpdate, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := CertificatePermissions(input) - return &out, nil -} - -type CreateMode string - -const ( - CreateModeDefault CreateMode = "default" - CreateModeRecover CreateMode = "recover" -) - -func PossibleValuesForCreateMode() []string { - return []string{ - string(CreateModeDefault), - string(CreateModeRecover), - } -} - -func parseCreateMode(input string) (*CreateMode, error) { - vals := map[string]CreateMode{ - "default": CreateModeDefault, - "recover": CreateModeRecover, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := CreateMode(input) - return &out, nil -} - -type KeyPermissions string - -const ( - KeyPermissionsAll KeyPermissions = "all" - KeyPermissionsBackup KeyPermissions = "backup" - KeyPermissionsCreate KeyPermissions = "create" - KeyPermissionsDecrypt KeyPermissions = "decrypt" - KeyPermissionsDelete KeyPermissions = "delete" - KeyPermissionsEncrypt KeyPermissions = "encrypt" - KeyPermissionsGet KeyPermissions = "get" - KeyPermissionsGetrotationpolicy KeyPermissions = "getrotationpolicy" - KeyPermissionsImport KeyPermissions = "import" - KeyPermissionsList KeyPermissions = "list" - KeyPermissionsPurge KeyPermissions = "purge" - KeyPermissionsRecover KeyPermissions = "recover" - KeyPermissionsRelease KeyPermissions = "release" - KeyPermissionsRestore KeyPermissions = "restore" - KeyPermissionsRotate KeyPermissions = "rotate" - KeyPermissionsSetrotationpolicy KeyPermissions = "setrotationpolicy" - KeyPermissionsSign KeyPermissions = "sign" - KeyPermissionsUnwrapKey KeyPermissions = "unwrapKey" - KeyPermissionsUpdate KeyPermissions = "update" - KeyPermissionsVerify KeyPermissions = "verify" - KeyPermissionsWrapKey KeyPermissions = "wrapKey" -) - -func PossibleValuesForKeyPermissions() []string { - return []string{ - string(KeyPermissionsAll), - string(KeyPermissionsBackup), - string(KeyPermissionsCreate), - string(KeyPermissionsDecrypt), - string(KeyPermissionsDelete), - string(KeyPermissionsEncrypt), - string(KeyPermissionsGet), - string(KeyPermissionsGetrotationpolicy), - string(KeyPermissionsImport), - string(KeyPermissionsList), - string(KeyPermissionsPurge), - string(KeyPermissionsRecover), - string(KeyPermissionsRelease), - string(KeyPermissionsRestore), - string(KeyPermissionsRotate), - string(KeyPermissionsSetrotationpolicy), - string(KeyPermissionsSign), - string(KeyPermissionsUnwrapKey), - string(KeyPermissionsUpdate), - string(KeyPermissionsVerify), - string(KeyPermissionsWrapKey), - } -} - -func parseKeyPermissions(input string) (*KeyPermissions, error) { - vals := map[string]KeyPermissions{ - "all": KeyPermissionsAll, - "backup": KeyPermissionsBackup, - "create": KeyPermissionsCreate, - "decrypt": KeyPermissionsDecrypt, - "delete": KeyPermissionsDelete, - "encrypt": KeyPermissionsEncrypt, - "get": KeyPermissionsGet, - "getrotationpolicy": KeyPermissionsGetrotationpolicy, - "import": KeyPermissionsImport, - "list": KeyPermissionsList, - "purge": KeyPermissionsPurge, - "recover": KeyPermissionsRecover, - "release": KeyPermissionsRelease, - "restore": KeyPermissionsRestore, - "rotate": KeyPermissionsRotate, - "setrotationpolicy": KeyPermissionsSetrotationpolicy, - "sign": KeyPermissionsSign, - "unwrapkey": KeyPermissionsUnwrapKey, - "update": KeyPermissionsUpdate, - "verify": KeyPermissionsVerify, - "wrapkey": KeyPermissionsWrapKey, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := KeyPermissions(input) - return &out, nil -} - -type NetworkRuleAction string - -const ( - NetworkRuleActionAllow NetworkRuleAction = "Allow" - NetworkRuleActionDeny NetworkRuleAction = "Deny" -) - -func PossibleValuesForNetworkRuleAction() []string { - return []string{ - string(NetworkRuleActionAllow), - string(NetworkRuleActionDeny), - } -} - -func parseNetworkRuleAction(input string) (*NetworkRuleAction, error) { - vals := map[string]NetworkRuleAction{ - "allow": NetworkRuleActionAllow, - "deny": NetworkRuleActionDeny, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := NetworkRuleAction(input) - return &out, nil -} - -type NetworkRuleBypassOptions string - -const ( - NetworkRuleBypassOptionsAzureServices NetworkRuleBypassOptions = "AzureServices" - NetworkRuleBypassOptionsNone NetworkRuleBypassOptions = "None" -) - -func PossibleValuesForNetworkRuleBypassOptions() []string { - return []string{ - string(NetworkRuleBypassOptionsAzureServices), - string(NetworkRuleBypassOptionsNone), - } -} - -func parseNetworkRuleBypassOptions(input string) (*NetworkRuleBypassOptions, error) { - vals := map[string]NetworkRuleBypassOptions{ - "azureservices": NetworkRuleBypassOptionsAzureServices, - "none": NetworkRuleBypassOptionsNone, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := NetworkRuleBypassOptions(input) - return &out, nil -} - -type PrivateEndpointConnectionProvisioningState string - -const ( - PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" - PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" - PrivateEndpointConnectionProvisioningStateDisconnected PrivateEndpointConnectionProvisioningState = "Disconnected" - PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" - PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" - PrivateEndpointConnectionProvisioningStateUpdating PrivateEndpointConnectionProvisioningState = "Updating" -) - -func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { - return []string{ - string(PrivateEndpointConnectionProvisioningStateCreating), - string(PrivateEndpointConnectionProvisioningStateDeleting), - string(PrivateEndpointConnectionProvisioningStateDisconnected), - string(PrivateEndpointConnectionProvisioningStateFailed), - string(PrivateEndpointConnectionProvisioningStateSucceeded), - string(PrivateEndpointConnectionProvisioningStateUpdating), - } -} - -func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { - vals := map[string]PrivateEndpointConnectionProvisioningState{ - "creating": PrivateEndpointConnectionProvisioningStateCreating, - "deleting": PrivateEndpointConnectionProvisioningStateDeleting, - "disconnected": PrivateEndpointConnectionProvisioningStateDisconnected, - "failed": PrivateEndpointConnectionProvisioningStateFailed, - "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, - "updating": PrivateEndpointConnectionProvisioningStateUpdating, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := PrivateEndpointConnectionProvisioningState(input) - return &out, nil -} - -type PrivateEndpointServiceConnectionStatus string - -const ( - PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" - PrivateEndpointServiceConnectionStatusDisconnected PrivateEndpointServiceConnectionStatus = "Disconnected" - PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" - PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" -) - -func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { - return []string{ - string(PrivateEndpointServiceConnectionStatusApproved), - string(PrivateEndpointServiceConnectionStatusDisconnected), - string(PrivateEndpointServiceConnectionStatusPending), - string(PrivateEndpointServiceConnectionStatusRejected), - } -} - -func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { - vals := map[string]PrivateEndpointServiceConnectionStatus{ - "approved": PrivateEndpointServiceConnectionStatusApproved, - "disconnected": PrivateEndpointServiceConnectionStatusDisconnected, - "pending": PrivateEndpointServiceConnectionStatusPending, - "rejected": PrivateEndpointServiceConnectionStatusRejected, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := PrivateEndpointServiceConnectionStatus(input) - return &out, nil -} - -type Reason string - -const ( - ReasonAccountNameInvalid Reason = "AccountNameInvalid" - ReasonAlreadyExists Reason = "AlreadyExists" -) - -func PossibleValuesForReason() []string { - return []string{ - string(ReasonAccountNameInvalid), - string(ReasonAlreadyExists), - } -} - -func parseReason(input string) (*Reason, error) { - vals := map[string]Reason{ - "accountnameinvalid": ReasonAccountNameInvalid, - "alreadyexists": ReasonAlreadyExists, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := Reason(input) - return &out, nil -} - -type SecretPermissions string - -const ( - SecretPermissionsAll SecretPermissions = "all" - SecretPermissionsBackup SecretPermissions = "backup" - SecretPermissionsDelete SecretPermissions = "delete" - SecretPermissionsGet SecretPermissions = "get" - SecretPermissionsList SecretPermissions = "list" - SecretPermissionsPurge SecretPermissions = "purge" - SecretPermissionsRecover SecretPermissions = "recover" - SecretPermissionsRestore SecretPermissions = "restore" - SecretPermissionsSet SecretPermissions = "set" -) - -func PossibleValuesForSecretPermissions() []string { - return []string{ - string(SecretPermissionsAll), - string(SecretPermissionsBackup), - string(SecretPermissionsDelete), - string(SecretPermissionsGet), - string(SecretPermissionsList), - string(SecretPermissionsPurge), - string(SecretPermissionsRecover), - string(SecretPermissionsRestore), - string(SecretPermissionsSet), - } -} - -func parseSecretPermissions(input string) (*SecretPermissions, error) { - vals := map[string]SecretPermissions{ - "all": SecretPermissionsAll, - "backup": SecretPermissionsBackup, - "delete": SecretPermissionsDelete, - "get": SecretPermissionsGet, - "list": SecretPermissionsList, - "purge": SecretPermissionsPurge, - "recover": SecretPermissionsRecover, - "restore": SecretPermissionsRestore, - "set": SecretPermissionsSet, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := SecretPermissions(input) - return &out, nil -} - -type SkuFamily string - -const ( - SkuFamilyA SkuFamily = "A" -) - -func PossibleValuesForSkuFamily() []string { - return []string{ - string(SkuFamilyA), - } -} - -func parseSkuFamily(input string) (*SkuFamily, error) { - vals := map[string]SkuFamily{ - "a": SkuFamilyA, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := SkuFamily(input) - return &out, nil -} - -type SkuName string - -const ( - SkuNamePremium SkuName = "premium" - SkuNameStandard SkuName = "standard" -) - -func PossibleValuesForSkuName() []string { - return []string{ - string(SkuNamePremium), - string(SkuNameStandard), - } -} - -func parseSkuName(input string) (*SkuName, error) { - vals := map[string]SkuName{ - "premium": SkuNamePremium, - "standard": SkuNameStandard, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := SkuName(input) - return &out, nil -} - -type StoragePermissions string - -const ( - StoragePermissionsAll StoragePermissions = "all" - StoragePermissionsBackup StoragePermissions = "backup" - StoragePermissionsDelete StoragePermissions = "delete" - StoragePermissionsDeletesas StoragePermissions = "deletesas" - StoragePermissionsGet StoragePermissions = "get" - StoragePermissionsGetsas StoragePermissions = "getsas" - StoragePermissionsList StoragePermissions = "list" - StoragePermissionsListsas StoragePermissions = "listsas" - StoragePermissionsPurge StoragePermissions = "purge" - StoragePermissionsRecover StoragePermissions = "recover" - StoragePermissionsRegeneratekey StoragePermissions = "regeneratekey" - StoragePermissionsRestore StoragePermissions = "restore" - StoragePermissionsSet StoragePermissions = "set" - StoragePermissionsSetsas StoragePermissions = "setsas" - StoragePermissionsUpdate StoragePermissions = "update" -) - -func PossibleValuesForStoragePermissions() []string { - return []string{ - string(StoragePermissionsAll), - string(StoragePermissionsBackup), - string(StoragePermissionsDelete), - string(StoragePermissionsDeletesas), - string(StoragePermissionsGet), - string(StoragePermissionsGetsas), - string(StoragePermissionsList), - string(StoragePermissionsListsas), - string(StoragePermissionsPurge), - string(StoragePermissionsRecover), - string(StoragePermissionsRegeneratekey), - string(StoragePermissionsRestore), - string(StoragePermissionsSet), - string(StoragePermissionsSetsas), - string(StoragePermissionsUpdate), - } -} - -func parseStoragePermissions(input string) (*StoragePermissions, error) { - vals := map[string]StoragePermissions{ - "all": StoragePermissionsAll, - "backup": StoragePermissionsBackup, - "delete": StoragePermissionsDelete, - "deletesas": StoragePermissionsDeletesas, - "get": StoragePermissionsGet, - "getsas": StoragePermissionsGetsas, - "list": StoragePermissionsList, - "listsas": StoragePermissionsListsas, - "purge": StoragePermissionsPurge, - "recover": StoragePermissionsRecover, - "regeneratekey": StoragePermissionsRegeneratekey, - "restore": StoragePermissionsRestore, - "set": StoragePermissionsSet, - "setsas": StoragePermissionsSetsas, - "update": StoragePermissionsUpdate, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := StoragePermissions(input) - return &out, nil -} - -type Type string - -const ( - TypeMicrosoftPointKeyVaultVaults Type = "Microsoft.KeyVault/vaults" -) - -func PossibleValuesForType() []string { - return []string{ - string(TypeMicrosoftPointKeyVaultVaults), - } -} - -func parseType(input string) (*Type, error) { - vals := map[string]Type{ - "microsoft.keyvault/vaults": TypeMicrosoftPointKeyVaultVaults, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := Type(input) - return &out, nil -} - -type VaultListFilterTypes string - -const ( - VaultListFilterTypesResourceTypeEqMicrosoftPointKeyVaultVaults VaultListFilterTypes = "resourceType eq 'Microsoft.KeyVault/vaults'" -) - -func PossibleValuesForVaultListFilterTypes() []string { - return []string{ - string(VaultListFilterTypesResourceTypeEqMicrosoftPointKeyVaultVaults), - } -} - -func parseVaultListFilterTypes(input string) (*VaultListFilterTypes, error) { - vals := map[string]VaultListFilterTypes{ - "resourcetype eq 'microsoft.keyvault/vaults'": VaultListFilterTypesResourceTypeEqMicrosoftPointKeyVaultVaults, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := VaultListFilterTypes(input) - return &out, nil -} - -type VaultProvisioningState string - -const ( - VaultProvisioningStateRegisteringDns VaultProvisioningState = "RegisteringDns" - VaultProvisioningStateSucceeded VaultProvisioningState = "Succeeded" -) - -func PossibleValuesForVaultProvisioningState() []string { - return []string{ - string(VaultProvisioningStateRegisteringDns), - string(VaultProvisioningStateSucceeded), - } -} - -func parseVaultProvisioningState(input string) (*VaultProvisioningState, error) { - vals := map[string]VaultProvisioningState{ - "registeringdns": VaultProvisioningStateRegisteringDns, - "succeeded": VaultProvisioningStateSucceeded, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := VaultProvisioningState(input) - return &out, nil -} diff --git a/resource-manager/keyvault/2022-11-01/vaults/id_deletedvault.go b/resource-manager/keyvault/2022-11-01/vaults/id_deletedvault.go deleted file mode 100644 index 4575767c2e2..00000000000 --- a/resource-manager/keyvault/2022-11-01/vaults/id_deletedvault.go +++ /dev/null @@ -1,125 +0,0 @@ -package vaults - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -var _ resourceids.ResourceId = &DeletedVaultId{} - -// DeletedVaultId is a struct representing the Resource ID for a Deleted Vault -type DeletedVaultId struct { - SubscriptionId string - LocationName string - DeletedVaultName string -} - -// NewDeletedVaultID returns a new DeletedVaultId struct -func NewDeletedVaultID(subscriptionId string, locationName string, deletedVaultName string) DeletedVaultId { - return DeletedVaultId{ - SubscriptionId: subscriptionId, - LocationName: locationName, - DeletedVaultName: deletedVaultName, - } -} - -// ParseDeletedVaultID parses 'input' into a DeletedVaultId -func ParseDeletedVaultID(input string) (*DeletedVaultId, error) { - parser := resourceids.NewParserFromResourceIdType(&DeletedVaultId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := DeletedVaultId{} - if err := id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -// ParseDeletedVaultIDInsensitively parses 'input' case-insensitively into a DeletedVaultId -// note: this method should only be used for API response data and not user input -func ParseDeletedVaultIDInsensitively(input string) (*DeletedVaultId, error) { - parser := resourceids.NewParserFromResourceIdType(&DeletedVaultId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := DeletedVaultId{} - if err := id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -func (id *DeletedVaultId) FromParseResult(input resourceids.ParseResult) error { - var ok bool - - if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) - } - - if id.LocationName, ok = input.Parsed["locationName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) - } - - if id.DeletedVaultName, ok = input.Parsed["deletedVaultName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "deletedVaultName", input) - } - - return nil -} - -// ValidateDeletedVaultID checks that 'input' can be parsed as a Deleted Vault ID -func ValidateDeletedVaultID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParseDeletedVaultID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Deleted Vault ID -func (id DeletedVaultId) ID() string { - fmtString := "/subscriptions/%s/providers/Microsoft.KeyVault/locations/%s/deletedVaults/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName, id.DeletedVaultName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Deleted Vault ID -func (id DeletedVaultId) 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("staticMicrosoftKeyVault", "Microsoft.KeyVault", "Microsoft.KeyVault"), - resourceids.StaticSegment("staticLocations", "locations", "locations"), - resourceids.UserSpecifiedSegment("locationName", "locationValue"), - resourceids.StaticSegment("staticDeletedVaults", "deletedVaults", "deletedVaults"), - resourceids.UserSpecifiedSegment("deletedVaultName", "deletedVaultValue"), - } -} - -// String returns a human-readable description of this Deleted Vault ID -func (id DeletedVaultId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Location Name: %q", id.LocationName), - fmt.Sprintf("Deleted Vault Name: %q", id.DeletedVaultName), - } - return fmt.Sprintf("Deleted Vault (%s)", strings.Join(components, "\n")) -} diff --git a/resource-manager/keyvault/2022-11-01/vaults/id_deletedvault_test.go b/resource-manager/keyvault/2022-11-01/vaults/id_deletedvault_test.go deleted file mode 100644 index b76e29d4fc7..00000000000 --- a/resource-manager/keyvault/2022-11-01/vaults/id_deletedvault_test.go +++ /dev/null @@ -1,282 +0,0 @@ -package vaults - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -var _ resourceids.ResourceId = &DeletedVaultId{} - -func TestNewDeletedVaultID(t *testing.T) { - id := NewDeletedVaultID("12345678-1234-9876-4563-123456789012", "locationValue", "deletedVaultValue") - - if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { - t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") - } - - if id.LocationName != "locationValue" { - t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationValue") - } - - if id.DeletedVaultName != "deletedVaultValue" { - t.Fatalf("Expected %q but got %q for Segment 'DeletedVaultName'", id.DeletedVaultName, "deletedVaultValue") - } -} - -func TestFormatDeletedVaultID(t *testing.T) { - actual := NewDeletedVaultID("12345678-1234-9876-4563-123456789012", "locationValue", "deletedVaultValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.KeyVault/locations/locationValue/deletedVaults/deletedVaultValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseDeletedVaultID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *DeletedVaultId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - 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.KeyVault", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.KeyVault/locations", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.KeyVault/locations/locationValue", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.KeyVault/locations/locationValue/deletedVaults", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.KeyVault/locations/locationValue/deletedVaults/deletedVaultValue", - Expected: &DeletedVaultId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - LocationName: "locationValue", - DeletedVaultName: "deletedVaultValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.KeyVault/locations/locationValue/deletedVaults/deletedVaultValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseDeletedVaultID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.LocationName != v.Expected.LocationName { - t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) - } - - if actual.DeletedVaultName != v.Expected.DeletedVaultName { - t.Fatalf("Expected %q but got %q for DeletedVaultName", v.Expected.DeletedVaultName, actual.DeletedVaultName) - } - - } -} - -func TestParseDeletedVaultIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *DeletedVaultId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI (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.KeyVault", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.kEyVaUlT", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.KeyVault/locations", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.kEyVaUlT/lOcAtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.KeyVault/locations/locationValue", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.kEyVaUlT/lOcAtIoNs/lOcAtIoNvAlUe", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.KeyVault/locations/locationValue/deletedVaults", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.kEyVaUlT/lOcAtIoNs/lOcAtIoNvAlUe/dElEtEdVaUlTs", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.KeyVault/locations/locationValue/deletedVaults/deletedVaultValue", - Expected: &DeletedVaultId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - LocationName: "locationValue", - DeletedVaultName: "deletedVaultValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.KeyVault/locations/locationValue/deletedVaults/deletedVaultValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.kEyVaUlT/lOcAtIoNs/lOcAtIoNvAlUe/dElEtEdVaUlTs/dElEtEdVaUlTvAlUe", - Expected: &DeletedVaultId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - LocationName: "lOcAtIoNvAlUe", - DeletedVaultName: "dElEtEdVaUlTvAlUe", - }, - }, - { - // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.kEyVaUlT/lOcAtIoNs/lOcAtIoNvAlUe/dElEtEdVaUlTs/dElEtEdVaUlTvAlUe/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseDeletedVaultIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.LocationName != v.Expected.LocationName { - t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) - } - - if actual.DeletedVaultName != v.Expected.DeletedVaultName { - t.Fatalf("Expected %q but got %q for DeletedVaultName", v.Expected.DeletedVaultName, actual.DeletedVaultName) - } - - } -} - -func TestSegmentsForDeletedVaultId(t *testing.T) { - segments := DeletedVaultId{}.Segments() - if len(segments) == 0 { - t.Fatalf("DeletedVaultId has no segments") - } - - uniqueNames := make(map[string]struct{}, 0) - for _, segment := range segments { - uniqueNames[segment.Name] = struct{}{} - } - if len(uniqueNames) != len(segments) { - t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) - } -} diff --git a/resource-manager/keyvault/2022-11-01/vaults/id_operationkind.go b/resource-manager/keyvault/2022-11-01/vaults/id_operationkind.go deleted file mode 100644 index 25708d5d526..00000000000 --- a/resource-manager/keyvault/2022-11-01/vaults/id_operationkind.go +++ /dev/null @@ -1,142 +0,0 @@ -package vaults - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -var _ resourceids.ResourceId = &OperationKindId{} - -// OperationKindId is a struct representing the Resource ID for a Operation Kind -type OperationKindId struct { - SubscriptionId string - ResourceGroupName string - VaultName string - OperationKind AccessPolicyUpdateKind -} - -// NewOperationKindID returns a new OperationKindId struct -func NewOperationKindID(subscriptionId string, resourceGroupName string, vaultName string, operationKind AccessPolicyUpdateKind) OperationKindId { - return OperationKindId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - VaultName: vaultName, - OperationKind: operationKind, - } -} - -// ParseOperationKindID parses 'input' into a OperationKindId -func ParseOperationKindID(input string) (*OperationKindId, error) { - parser := resourceids.NewParserFromResourceIdType(&OperationKindId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := OperationKindId{} - if err := id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -// ParseOperationKindIDInsensitively parses 'input' case-insensitively into a OperationKindId -// note: this method should only be used for API response data and not user input -func ParseOperationKindIDInsensitively(input string) (*OperationKindId, error) { - parser := resourceids.NewParserFromResourceIdType(&OperationKindId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := OperationKindId{} - if err := id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -func (id *OperationKindId) FromParseResult(input resourceids.ParseResult) error { - var ok bool - - if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) - } - - if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) - } - - if id.VaultName, ok = input.Parsed["vaultName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) - } - - if v, ok := input.Parsed["operationKind"]; true { - if !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "operationKind", input) - } - - operationKind, err := parseAccessPolicyUpdateKind(v) - if err != nil { - return fmt.Errorf("parsing %q: %+v", v, err) - } - id.OperationKind = *operationKind - } - - return nil -} - -// ValidateOperationKindID checks that 'input' can be parsed as a Operation Kind ID -func ValidateOperationKindID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParseOperationKindID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Operation Kind ID -func (id OperationKindId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.KeyVault/vaults/%s/accessPolicies/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, string(id.OperationKind)) -} - -// Segments returns a slice of Resource ID Segments which comprise this Operation Kind ID -func (id OperationKindId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftKeyVault", "Microsoft.KeyVault", "Microsoft.KeyVault"), - resourceids.StaticSegment("staticVaults", "vaults", "vaults"), - resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), - resourceids.StaticSegment("staticAccessPolicies", "accessPolicies", "accessPolicies"), - resourceids.ConstantSegment("operationKind", PossibleValuesForAccessPolicyUpdateKind(), "add"), - } -} - -// String returns a human-readable description of this Operation Kind ID -func (id OperationKindId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Vault Name: %q", id.VaultName), - fmt.Sprintf("Operation Kind: %q", string(id.OperationKind)), - } - return fmt.Sprintf("Operation Kind (%s)", strings.Join(components, "\n")) -} diff --git a/resource-manager/keyvault/2022-11-01/vaults/id_operationkind_test.go b/resource-manager/keyvault/2022-11-01/vaults/id_operationkind_test.go deleted file mode 100644 index 97ed59eb4d4..00000000000 --- a/resource-manager/keyvault/2022-11-01/vaults/id_operationkind_test.go +++ /dev/null @@ -1,327 +0,0 @@ -package vaults - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -var _ resourceids.ResourceId = &OperationKindId{} - -func TestNewOperationKindID(t *testing.T) { - id := NewOperationKindID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "add") - - if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { - t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") - } - - if id.ResourceGroupName != "example-resource-group" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") - } - - if id.VaultName != "vaultValue" { - t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") - } - - if id.OperationKind != "add" { - t.Fatalf("Expected %q but got %q for Segment 'OperationKind'", id.OperationKind, "add") - } -} - -func TestFormatOperationKindID(t *testing.T) { - actual := NewOperationKindID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "add").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/vaults/vaultValue/accessPolicies/add" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseOperationKindID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *OperationKindId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/vaults", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/vaults/vaultValue", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/vaults/vaultValue/accessPolicies", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/vaults/vaultValue/accessPolicies/add", - Expected: &OperationKindId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - VaultName: "vaultValue", - OperationKind: "add", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/vaults/vaultValue/accessPolicies/add/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseOperationKindID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.VaultName != v.Expected.VaultName { - t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) - } - - if actual.OperationKind != v.Expected.OperationKind { - t.Fatalf("Expected %q but got %q for OperationKind", v.Expected.OperationKind, actual.OperationKind) - } - - } -} - -func TestParseOperationKindIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *OperationKindId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/vaults", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/vAuLtS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/vaults/vaultValue", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/vAuLtS/vAuLtVaLuE", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/vaults/vaultValue/accessPolicies", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/vAuLtS/vAuLtVaLuE/aCcEsSpOlIcIeS", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/vaults/vaultValue/accessPolicies/add", - Expected: &OperationKindId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - VaultName: "vaultValue", - OperationKind: "add", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/vaults/vaultValue/accessPolicies/add/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/vAuLtS/vAuLtVaLuE/aCcEsSpOlIcIeS/aDd", - Expected: &OperationKindId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - VaultName: "vAuLtVaLuE", - OperationKind: "add", - }, - }, - { - // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kEyVaUlT/vAuLtS/vAuLtVaLuE/aCcEsSpOlIcIeS/aDd/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseOperationKindIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.VaultName != v.Expected.VaultName { - t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) - } - - if actual.OperationKind != v.Expected.OperationKind { - t.Fatalf("Expected %q but got %q for OperationKind", v.Expected.OperationKind, actual.OperationKind) - } - - } -} - -func TestSegmentsForOperationKindId(t *testing.T) { - segments := OperationKindId{}.Segments() - if len(segments) == 0 { - t.Fatalf("OperationKindId has no segments") - } - - uniqueNames := make(map[string]struct{}, 0) - for _, segment := range segments { - uniqueNames[segment.Name] = struct{}{} - } - if len(uniqueNames) != len(segments) { - t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) - } -} diff --git a/resource-manager/keyvault/2022-11-01/vaults/method_checknameavailability_autorest.go b/resource-manager/keyvault/2022-11-01/vaults/method_checknameavailability_autorest.go deleted file mode 100644 index b6a428f979b..00000000000 --- a/resource-manager/keyvault/2022-11-01/vaults/method_checknameavailability_autorest.go +++ /dev/null @@ -1,71 +0,0 @@ -package vaults - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CheckNameAvailabilityOperationResponse struct { - HttpResponse *http.Response - Model *CheckNameAvailabilityResult -} - -// CheckNameAvailability ... -func (c VaultsClient) CheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input VaultCheckNameAvailabilityParameters) (result CheckNameAvailabilityOperationResponse, err error) { - req, err := c.preparerForCheckNameAvailability(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "CheckNameAvailability", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "CheckNameAvailability", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCheckNameAvailability(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "CheckNameAvailability", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCheckNameAvailability prepares the CheckNameAvailability request. -func (c VaultsClient) preparerForCheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input VaultCheckNameAvailabilityParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.KeyVault/checkNameAvailability", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCheckNameAvailability handles the response to the CheckNameAvailability request. The method always -// closes the http.Response Body. -func (c VaultsClient) responderForCheckNameAvailability(resp *http.Response) (result CheckNameAvailabilityOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2022-11-01/vaults/method_createorupdate_autorest.go b/resource-manager/keyvault/2022-11-01/vaults/method_createorupdate_autorest.go deleted file mode 100644 index b80f3097c1d..00000000000 --- a/resource-manager/keyvault/2022-11-01/vaults/method_createorupdate_autorest.go +++ /dev/null @@ -1,81 +0,0 @@ -package vaults - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response - Model *Vault -} - -// CreateOrUpdate ... -func (c VaultsClient) CreateOrUpdate(ctx context.Context, id commonids.KeyVaultId, input VaultCreateOrUpdateParameters) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c VaultsClient) CreateOrUpdateThenPoll(ctx context.Context, id commonids.KeyVaultId, input VaultCreateOrUpdateParameters) error { - result, err := c.CreateOrUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c VaultsClient) preparerForCreateOrUpdate(ctx context.Context, id commonids.KeyVaultId, input VaultCreateOrUpdateParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c VaultsClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/keyvault/2022-11-01/vaults/method_delete_autorest.go b/resource-manager/keyvault/2022-11-01/vaults/method_delete_autorest.go deleted file mode 100644 index 5eabac1a3f0..00000000000 --- a/resource-manager/keyvault/2022-11-01/vaults/method_delete_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package vaults - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteOperationResponse struct { - HttpResponse *http.Response -} - -// Delete ... -func (c VaultsClient) Delete(ctx context.Context, id commonids.KeyVaultId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c VaultsClient) preparerForDelete(ctx context.Context, id commonids.KeyVaultId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c VaultsClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2022-11-01/vaults/method_get_autorest.go b/resource-manager/keyvault/2022-11-01/vaults/method_get_autorest.go deleted file mode 100644 index 986510ec6d7..00000000000 --- a/resource-manager/keyvault/2022-11-01/vaults/method_get_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package vaults - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *Vault -} - -// Get ... -func (c VaultsClient) Get(ctx context.Context, id commonids.KeyVaultId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c VaultsClient) preparerForGet(ctx context.Context, id commonids.KeyVaultId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c VaultsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2022-11-01/vaults/method_getdeleted_autorest.go b/resource-manager/keyvault/2022-11-01/vaults/method_getdeleted_autorest.go deleted file mode 100644 index b60a7041ea1..00000000000 --- a/resource-manager/keyvault/2022-11-01/vaults/method_getdeleted_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package vaults - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetDeletedOperationResponse struct { - HttpResponse *http.Response - Model *DeletedVault -} - -// GetDeleted ... -func (c VaultsClient) GetDeleted(ctx context.Context, id DeletedVaultId) (result GetDeletedOperationResponse, err error) { - req, err := c.preparerForGetDeleted(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "GetDeleted", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "GetDeleted", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetDeleted(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "GetDeleted", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetDeleted prepares the GetDeleted request. -func (c VaultsClient) preparerForGetDeleted(ctx context.Context, id DeletedVaultId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetDeleted handles the response to the GetDeleted request. The method always -// closes the http.Response Body. -func (c VaultsClient) responderForGetDeleted(resp *http.Response) (result GetDeletedOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2022-11-01/vaults/method_list_autorest.go b/resource-manager/keyvault/2022-11-01/vaults/method_list_autorest.go deleted file mode 100644 index 58b77e07a16..00000000000 --- a/resource-manager/keyvault/2022-11-01/vaults/method_list_autorest.go +++ /dev/null @@ -1,221 +0,0 @@ -package vaults - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *[]Resource - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []Resource -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListOperationOptions struct { - Filter *VaultListFilterTypes - Top *int64 -} - -func DefaultListOperationOptions() ListOperationOptions { - return ListOperationOptions{} -} - -func (o ListOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// List ... -func (c VaultsClient) List(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c VaultsClient) preparerForList(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/resources", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c VaultsClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c VaultsClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []Resource `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { - req, err := c.preparerForListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c VaultsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, options, ResourceOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c VaultsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions, predicate ResourceOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]Resource, 0) - - page, err := c.List(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/keyvault/2022-11-01/vaults/method_listbyresourcegroup_autorest.go b/resource-manager/keyvault/2022-11-01/vaults/method_listbyresourcegroup_autorest.go deleted file mode 100644 index c7f2a4088e7..00000000000 --- a/resource-manager/keyvault/2022-11-01/vaults/method_listbyresourcegroup_autorest.go +++ /dev/null @@ -1,216 +0,0 @@ -package vaults - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// 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 - Model *[]Vault - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByResourceGroupOperationResponse, error) -} - -type ListByResourceGroupCompleteResult struct { - Items []Vault -} - -func (r ListByResourceGroupOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByResourceGroupOperationResponse) LoadMore(ctx context.Context) (resp ListByResourceGroupOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByResourceGroupOperationOptions struct { - Top *int64 -} - -func DefaultListByResourceGroupOperationOptions() ListByResourceGroupOperationOptions { - return ListByResourceGroupOperationOptions{} -} - -func (o ListByResourceGroupOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByResourceGroupOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByResourceGroup ... -func (c VaultsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (resp ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroup(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListByResourceGroup", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByResourceGroup(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListByResourceGroup", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByResourceGroup prepares the ListByResourceGroup request. -func (c VaultsClient) preparerForListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.KeyVault/vaults", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByResourceGroupWithNextLink prepares the ListByResourceGroup request with the given nextLink token. -func (c VaultsClient) preparerForListByResourceGroupWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByResourceGroup handles the response to the ListByResourceGroup request. The method always -// closes the http.Response Body. -func (c VaultsClient) responderForListByResourceGroup(resp *http.Response) (result ListByResourceGroupOperationResponse, err error) { - type page struct { - Values []Vault `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroupWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListByResourceGroup", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByResourceGroup(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListByResourceGroup", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByResourceGroupComplete retrieves all of the results into a single object -func (c VaultsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (ListByResourceGroupCompleteResult, error) { - return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, options, VaultOperationPredicate{}) -} - -// ListByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c VaultsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions, predicate VaultOperationPredicate) (resp ListByResourceGroupCompleteResult, err error) { - items := make([]Vault, 0) - - page, err := c.ListByResourceGroup(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByResourceGroupCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/keyvault/2022-11-01/vaults/method_listbysubscription_autorest.go b/resource-manager/keyvault/2022-11-01/vaults/method_listbysubscription_autorest.go deleted file mode 100644 index 11e2932b29c..00000000000 --- a/resource-manager/keyvault/2022-11-01/vaults/method_listbysubscription_autorest.go +++ /dev/null @@ -1,216 +0,0 @@ -package vaults - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// 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 - Model *[]Vault - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListBySubscriptionOperationResponse, error) -} - -type ListBySubscriptionCompleteResult struct { - Items []Vault -} - -func (r ListBySubscriptionOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListBySubscriptionOperationResponse) LoadMore(ctx context.Context) (resp ListBySubscriptionOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListBySubscriptionOperationOptions struct { - Top *int64 -} - -func DefaultListBySubscriptionOperationOptions() ListBySubscriptionOperationOptions { - return ListBySubscriptionOperationOptions{} -} - -func (o ListBySubscriptionOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListBySubscriptionOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListBySubscription ... -func (c VaultsClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions) (resp ListBySubscriptionOperationResponse, err error) { - req, err := c.preparerForListBySubscription(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListBySubscription", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListBySubscription", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListBySubscription(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListBySubscription", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListBySubscription prepares the ListBySubscription request. -func (c VaultsClient) preparerForListBySubscription(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.KeyVault/vaults", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListBySubscriptionWithNextLink prepares the ListBySubscription request with the given nextLink token. -func (c VaultsClient) preparerForListBySubscriptionWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListBySubscription handles the response to the ListBySubscription request. The method always -// closes the http.Response Body. -func (c VaultsClient) responderForListBySubscription(resp *http.Response) (result ListBySubscriptionOperationResponse, err error) { - type page struct { - Values []Vault `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListBySubscriptionOperationResponse, err error) { - req, err := c.preparerForListBySubscriptionWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListBySubscription", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListBySubscription", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListBySubscription(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListBySubscription", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListBySubscriptionComplete retrieves all of the results into a single object -func (c VaultsClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions) (ListBySubscriptionCompleteResult, error) { - return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, options, VaultOperationPredicate{}) -} - -// ListBySubscriptionCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c VaultsClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions, predicate VaultOperationPredicate) (resp ListBySubscriptionCompleteResult, err error) { - items := make([]Vault, 0) - - page, err := c.ListBySubscription(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListBySubscriptionCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/keyvault/2022-11-01/vaults/method_listdeleted_autorest.go b/resource-manager/keyvault/2022-11-01/vaults/method_listdeleted_autorest.go deleted file mode 100644 index 7f1b889661b..00000000000 --- a/resource-manager/keyvault/2022-11-01/vaults/method_listdeleted_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package vaults - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListDeletedOperationResponse struct { - HttpResponse *http.Response - Model *[]DeletedVault - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListDeletedOperationResponse, error) -} - -type ListDeletedCompleteResult struct { - Items []DeletedVault -} - -func (r ListDeletedOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListDeletedOperationResponse) LoadMore(ctx context.Context) (resp ListDeletedOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListDeleted ... -func (c VaultsClient) ListDeleted(ctx context.Context, id commonids.SubscriptionId) (resp ListDeletedOperationResponse, err error) { - req, err := c.preparerForListDeleted(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListDeleted", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListDeleted", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListDeleted(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListDeleted", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListDeleted prepares the ListDeleted request. -func (c VaultsClient) preparerForListDeleted(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.KeyVault/deletedVaults", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListDeletedWithNextLink prepares the ListDeleted request with the given nextLink token. -func (c VaultsClient) preparerForListDeletedWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListDeleted handles the response to the ListDeleted request. The method always -// closes the http.Response Body. -func (c VaultsClient) responderForListDeleted(resp *http.Response) (result ListDeletedOperationResponse, err error) { - type page struct { - Values []DeletedVault `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListDeletedOperationResponse, err error) { - req, err := c.preparerForListDeletedWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListDeleted", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListDeleted", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListDeleted(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListDeleted", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListDeletedComplete retrieves all of the results into a single object -func (c VaultsClient) ListDeletedComplete(ctx context.Context, id commonids.SubscriptionId) (ListDeletedCompleteResult, error) { - return c.ListDeletedCompleteMatchingPredicate(ctx, id, DeletedVaultOperationPredicate{}) -} - -// ListDeletedCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c VaultsClient) ListDeletedCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate DeletedVaultOperationPredicate) (resp ListDeletedCompleteResult, err error) { - items := make([]DeletedVault, 0) - - page, err := c.ListDeleted(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListDeletedCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/keyvault/2022-11-01/vaults/method_purgedeleted_autorest.go b/resource-manager/keyvault/2022-11-01/vaults/method_purgedeleted_autorest.go deleted file mode 100644 index 17606022668..00000000000 --- a/resource-manager/keyvault/2022-11-01/vaults/method_purgedeleted_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package vaults - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PurgeDeletedOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// PurgeDeleted ... -func (c VaultsClient) PurgeDeleted(ctx context.Context, id DeletedVaultId) (result PurgeDeletedOperationResponse, err error) { - req, err := c.preparerForPurgeDeleted(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "PurgeDeleted", nil, "Failure preparing request") - return - } - - result, err = c.senderForPurgeDeleted(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "PurgeDeleted", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// PurgeDeletedThenPoll performs PurgeDeleted then polls until it's completed -func (c VaultsClient) PurgeDeletedThenPoll(ctx context.Context, id DeletedVaultId) error { - result, err := c.PurgeDeleted(ctx, id) - if err != nil { - return fmt.Errorf("performing PurgeDeleted: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after PurgeDeleted: %+v", err) - } - - return nil -} - -// preparerForPurgeDeleted prepares the PurgeDeleted request. -func (c VaultsClient) preparerForPurgeDeleted(ctx context.Context, id DeletedVaultId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/purge", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForPurgeDeleted sends the PurgeDeleted request. The method will close the -// http.Response Body if it receives an error. -func (c VaultsClient) senderForPurgeDeleted(ctx context.Context, req *http.Request) (future PurgeDeletedOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/keyvault/2022-11-01/vaults/method_update_autorest.go b/resource-manager/keyvault/2022-11-01/vaults/method_update_autorest.go deleted file mode 100644 index b1145cfe089..00000000000 --- a/resource-manager/keyvault/2022-11-01/vaults/method_update_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package vaults - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateOperationResponse struct { - HttpResponse *http.Response - Model *Vault -} - -// Update ... -func (c VaultsClient) Update(ctx context.Context, id commonids.KeyVaultId, input VaultPatchParameters) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c VaultsClient) preparerForUpdate(ctx context.Context, id commonids.KeyVaultId, input VaultPatchParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdate handles the response to the Update request. The method always -// closes the http.Response Body. -func (c VaultsClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2022-11-01/vaults/method_updateaccesspolicy_autorest.go b/resource-manager/keyvault/2022-11-01/vaults/method_updateaccesspolicy_autorest.go deleted file mode 100644 index f76830d71d8..00000000000 --- a/resource-manager/keyvault/2022-11-01/vaults/method_updateaccesspolicy_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package vaults - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateAccessPolicyOperationResponse struct { - HttpResponse *http.Response - Model *VaultAccessPolicyParameters -} - -// UpdateAccessPolicy ... -func (c VaultsClient) UpdateAccessPolicy(ctx context.Context, id OperationKindId, input VaultAccessPolicyParameters) (result UpdateAccessPolicyOperationResponse, err error) { - req, err := c.preparerForUpdateAccessPolicy(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "UpdateAccessPolicy", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "UpdateAccessPolicy", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateAccessPolicy(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "UpdateAccessPolicy", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateAccessPolicy prepares the UpdateAccessPolicy request. -func (c VaultsClient) preparerForUpdateAccessPolicy(ctx context.Context, id OperationKindId, input VaultAccessPolicyParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateAccessPolicy handles the response to the UpdateAccessPolicy request. The method always -// closes the http.Response Body. -func (c VaultsClient) responderForUpdateAccessPolicy(resp *http.Response) (result UpdateAccessPolicyOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2022-11-01/vaults/model_accesspolicyentry.go b/resource-manager/keyvault/2022-11-01/vaults/model_accesspolicyentry.go deleted file mode 100644 index a183e1481b6..00000000000 --- a/resource-manager/keyvault/2022-11-01/vaults/model_accesspolicyentry.go +++ /dev/null @@ -1,11 +0,0 @@ -package vaults - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type AccessPolicyEntry struct { - ApplicationId *string `json:"applicationId,omitempty"` - ObjectId string `json:"objectId"` - Permissions Permissions `json:"permissions"` - TenantId string `json:"tenantId"` -} diff --git a/resource-manager/keyvault/2022-11-01/vaults/model_checknameavailabilityresult.go b/resource-manager/keyvault/2022-11-01/vaults/model_checknameavailabilityresult.go deleted file mode 100644 index 392070c655a..00000000000 --- a/resource-manager/keyvault/2022-11-01/vaults/model_checknameavailabilityresult.go +++ /dev/null @@ -1,10 +0,0 @@ -package vaults - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CheckNameAvailabilityResult struct { - Message *string `json:"message,omitempty"` - NameAvailable *bool `json:"nameAvailable,omitempty"` - Reason *Reason `json:"reason,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/vaults/model_deletedvault.go b/resource-manager/keyvault/2022-11-01/vaults/model_deletedvault.go deleted file mode 100644 index 0516f7fabdc..00000000000 --- a/resource-manager/keyvault/2022-11-01/vaults/model_deletedvault.go +++ /dev/null @@ -1,11 +0,0 @@ -package vaults - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeletedVault struct { - Id *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Properties *DeletedVaultProperties `json:"properties,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/vaults/model_deletedvaultproperties.go b/resource-manager/keyvault/2022-11-01/vaults/model_deletedvaultproperties.go deleted file mode 100644 index e8857532e44..00000000000 --- a/resource-manager/keyvault/2022-11-01/vaults/model_deletedvaultproperties.go +++ /dev/null @@ -1,43 +0,0 @@ -package vaults - -import ( - "time" - - "github.com/hashicorp/go-azure-helpers/lang/dates" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeletedVaultProperties struct { - DeletionDate *string `json:"deletionDate,omitempty"` - Location *string `json:"location,omitempty"` - PurgeProtectionEnabled *bool `json:"purgeProtectionEnabled,omitempty"` - ScheduledPurgeDate *string `json:"scheduledPurgeDate,omitempty"` - Tags *map[string]string `json:"tags,omitempty"` - VaultId *string `json:"vaultId,omitempty"` -} - -func (o *DeletedVaultProperties) GetDeletionDateAsTime() (*time.Time, error) { - if o.DeletionDate == nil { - return nil, nil - } - return dates.ParseAsFormat(o.DeletionDate, "2006-01-02T15:04:05Z07:00") -} - -func (o *DeletedVaultProperties) SetDeletionDateAsTime(input time.Time) { - formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.DeletionDate = &formatted -} - -func (o *DeletedVaultProperties) GetScheduledPurgeDateAsTime() (*time.Time, error) { - if o.ScheduledPurgeDate == nil { - return nil, nil - } - return dates.ParseAsFormat(o.ScheduledPurgeDate, "2006-01-02T15:04:05Z07:00") -} - -func (o *DeletedVaultProperties) SetScheduledPurgeDateAsTime(input time.Time) { - formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.ScheduledPurgeDate = &formatted -} diff --git a/resource-manager/keyvault/2022-11-01/vaults/model_iprule.go b/resource-manager/keyvault/2022-11-01/vaults/model_iprule.go deleted file mode 100644 index 1ef577d7d01..00000000000 --- a/resource-manager/keyvault/2022-11-01/vaults/model_iprule.go +++ /dev/null @@ -1,8 +0,0 @@ -package vaults - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type IPRule struct { - Value string `json:"value"` -} diff --git a/resource-manager/keyvault/2022-11-01/vaults/model_networkruleset.go b/resource-manager/keyvault/2022-11-01/vaults/model_networkruleset.go deleted file mode 100644 index 044635c0f77..00000000000 --- a/resource-manager/keyvault/2022-11-01/vaults/model_networkruleset.go +++ /dev/null @@ -1,11 +0,0 @@ -package vaults - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type NetworkRuleSet struct { - Bypass *NetworkRuleBypassOptions `json:"bypass,omitempty"` - DefaultAction *NetworkRuleAction `json:"defaultAction,omitempty"` - IPRules *[]IPRule `json:"ipRules,omitempty"` - VirtualNetworkRules *[]VirtualNetworkRule `json:"virtualNetworkRules,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/vaults/model_permissions.go b/resource-manager/keyvault/2022-11-01/vaults/model_permissions.go deleted file mode 100644 index b5f9cca4bd6..00000000000 --- a/resource-manager/keyvault/2022-11-01/vaults/model_permissions.go +++ /dev/null @@ -1,11 +0,0 @@ -package vaults - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type Permissions struct { - Certificates *[]CertificatePermissions `json:"certificates,omitempty"` - Keys *[]KeyPermissions `json:"keys,omitempty"` - Secrets *[]SecretPermissions `json:"secrets,omitempty"` - Storage *[]StoragePermissions `json:"storage,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/vaults/model_privateendpoint.go b/resource-manager/keyvault/2022-11-01/vaults/model_privateendpoint.go deleted file mode 100644 index 64ce35a3d98..00000000000 --- a/resource-manager/keyvault/2022-11-01/vaults/model_privateendpoint.go +++ /dev/null @@ -1,8 +0,0 @@ -package vaults - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PrivateEndpoint struct { - Id *string `json:"id,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/vaults/model_privateendpointconnectionitem.go b/resource-manager/keyvault/2022-11-01/vaults/model_privateendpointconnectionitem.go deleted file mode 100644 index a0f6df8359d..00000000000 --- a/resource-manager/keyvault/2022-11-01/vaults/model_privateendpointconnectionitem.go +++ /dev/null @@ -1,10 +0,0 @@ -package vaults - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PrivateEndpointConnectionItem struct { - Etag *string `json:"etag,omitempty"` - Id *string `json:"id,omitempty"` - Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/vaults/model_privateendpointconnectionproperties.go b/resource-manager/keyvault/2022-11-01/vaults/model_privateendpointconnectionproperties.go deleted file mode 100644 index 7dd15bb6220..00000000000 --- a/resource-manager/keyvault/2022-11-01/vaults/model_privateendpointconnectionproperties.go +++ /dev/null @@ -1,10 +0,0 @@ -package vaults - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PrivateEndpointConnectionProperties struct { - PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` - PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` - ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/vaults/model_privatelinkserviceconnectionstate.go b/resource-manager/keyvault/2022-11-01/vaults/model_privatelinkserviceconnectionstate.go deleted file mode 100644 index ced73fba28c..00000000000 --- a/resource-manager/keyvault/2022-11-01/vaults/model_privatelinkserviceconnectionstate.go +++ /dev/null @@ -1,10 +0,0 @@ -package vaults - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PrivateLinkServiceConnectionState struct { - ActionsRequired *ActionsRequired `json:"actionsRequired,omitempty"` - Description *string `json:"description,omitempty"` - Status *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/vaults/model_resource.go b/resource-manager/keyvault/2022-11-01/vaults/model_resource.go deleted file mode 100644 index 2c29e958d53..00000000000 --- a/resource-manager/keyvault/2022-11-01/vaults/model_resource.go +++ /dev/null @@ -1,12 +0,0 @@ -package vaults - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type Resource struct { - Id *string `json:"id,omitempty"` - Location *string `json:"location,omitempty"` - Name *string `json:"name,omitempty"` - Tags *map[string]string `json:"tags,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/vaults/model_sku.go b/resource-manager/keyvault/2022-11-01/vaults/model_sku.go deleted file mode 100644 index 259dd1fce3a..00000000000 --- a/resource-manager/keyvault/2022-11-01/vaults/model_sku.go +++ /dev/null @@ -1,9 +0,0 @@ -package vaults - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type Sku struct { - Family SkuFamily `json:"family"` - Name SkuName `json:"name"` -} diff --git a/resource-manager/keyvault/2022-11-01/vaults/model_vault.go b/resource-manager/keyvault/2022-11-01/vaults/model_vault.go deleted file mode 100644 index cfb5acec999..00000000000 --- a/resource-manager/keyvault/2022-11-01/vaults/model_vault.go +++ /dev/null @@ -1,18 +0,0 @@ -package vaults - -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 Vault struct { - Id *string `json:"id,omitempty"` - Location *string `json:"location,omitempty"` - Name *string `json:"name,omitempty"` - Properties VaultProperties `json:"properties"` - SystemData *systemdata.SystemData `json:"systemData,omitempty"` - Tags *map[string]string `json:"tags,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/vaults/model_vaultaccesspolicyparameters.go b/resource-manager/keyvault/2022-11-01/vaults/model_vaultaccesspolicyparameters.go deleted file mode 100644 index 7353ce39d54..00000000000 --- a/resource-manager/keyvault/2022-11-01/vaults/model_vaultaccesspolicyparameters.go +++ /dev/null @@ -1,12 +0,0 @@ -package vaults - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type VaultAccessPolicyParameters struct { - Id *string `json:"id,omitempty"` - Location *string `json:"location,omitempty"` - Name *string `json:"name,omitempty"` - Properties VaultAccessPolicyProperties `json:"properties"` - Type *string `json:"type,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/vaults/model_vaultaccesspolicyproperties.go b/resource-manager/keyvault/2022-11-01/vaults/model_vaultaccesspolicyproperties.go deleted file mode 100644 index 78525492fd7..00000000000 --- a/resource-manager/keyvault/2022-11-01/vaults/model_vaultaccesspolicyproperties.go +++ /dev/null @@ -1,8 +0,0 @@ -package vaults - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type VaultAccessPolicyProperties struct { - AccessPolicies []AccessPolicyEntry `json:"accessPolicies"` -} diff --git a/resource-manager/keyvault/2022-11-01/vaults/model_vaultchecknameavailabilityparameters.go b/resource-manager/keyvault/2022-11-01/vaults/model_vaultchecknameavailabilityparameters.go deleted file mode 100644 index b9f9c94d368..00000000000 --- a/resource-manager/keyvault/2022-11-01/vaults/model_vaultchecknameavailabilityparameters.go +++ /dev/null @@ -1,9 +0,0 @@ -package vaults - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type VaultCheckNameAvailabilityParameters struct { - Name string `json:"name"` - Type Type `json:"type"` -} diff --git a/resource-manager/keyvault/2022-11-01/vaults/model_vaultcreateorupdateparameters.go b/resource-manager/keyvault/2022-11-01/vaults/model_vaultcreateorupdateparameters.go deleted file mode 100644 index 6e8ca68bd73..00000000000 --- a/resource-manager/keyvault/2022-11-01/vaults/model_vaultcreateorupdateparameters.go +++ /dev/null @@ -1,10 +0,0 @@ -package vaults - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type VaultCreateOrUpdateParameters struct { - Location string `json:"location"` - Properties VaultProperties `json:"properties"` - Tags *map[string]string `json:"tags,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/vaults/model_vaultpatchparameters.go b/resource-manager/keyvault/2022-11-01/vaults/model_vaultpatchparameters.go deleted file mode 100644 index 9352a604c87..00000000000 --- a/resource-manager/keyvault/2022-11-01/vaults/model_vaultpatchparameters.go +++ /dev/null @@ -1,9 +0,0 @@ -package vaults - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type VaultPatchParameters struct { - Properties *VaultPatchProperties `json:"properties,omitempty"` - Tags *map[string]string `json:"tags,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/vaults/model_vaultpatchproperties.go b/resource-manager/keyvault/2022-11-01/vaults/model_vaultpatchproperties.go deleted file mode 100644 index 9a4f85f22a4..00000000000 --- a/resource-manager/keyvault/2022-11-01/vaults/model_vaultpatchproperties.go +++ /dev/null @@ -1,20 +0,0 @@ -package vaults - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type VaultPatchProperties struct { - AccessPolicies *[]AccessPolicyEntry `json:"accessPolicies,omitempty"` - CreateMode *CreateMode `json:"createMode,omitempty"` - EnablePurgeProtection *bool `json:"enablePurgeProtection,omitempty"` - EnableRbacAuthorization *bool `json:"enableRbacAuthorization,omitempty"` - EnableSoftDelete *bool `json:"enableSoftDelete,omitempty"` - EnabledForDeployment *bool `json:"enabledForDeployment,omitempty"` - EnabledForDiskEncryption *bool `json:"enabledForDiskEncryption,omitempty"` - EnabledForTemplateDeployment *bool `json:"enabledForTemplateDeployment,omitempty"` - NetworkAcls *NetworkRuleSet `json:"networkAcls,omitempty"` - PublicNetworkAccess *string `json:"publicNetworkAccess,omitempty"` - Sku *Sku `json:"sku,omitempty"` - SoftDeleteRetentionInDays *int64 `json:"softDeleteRetentionInDays,omitempty"` - TenantId *string `json:"tenantId,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/vaults/model_vaultproperties.go b/resource-manager/keyvault/2022-11-01/vaults/model_vaultproperties.go deleted file mode 100644 index a5e381c4dd9..00000000000 --- a/resource-manager/keyvault/2022-11-01/vaults/model_vaultproperties.go +++ /dev/null @@ -1,24 +0,0 @@ -package vaults - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type VaultProperties struct { - AccessPolicies *[]AccessPolicyEntry `json:"accessPolicies,omitempty"` - CreateMode *CreateMode `json:"createMode,omitempty"` - EnablePurgeProtection *bool `json:"enablePurgeProtection,omitempty"` - EnableRbacAuthorization *bool `json:"enableRbacAuthorization,omitempty"` - EnableSoftDelete *bool `json:"enableSoftDelete,omitempty"` - EnabledForDeployment *bool `json:"enabledForDeployment,omitempty"` - EnabledForDiskEncryption *bool `json:"enabledForDiskEncryption,omitempty"` - EnabledForTemplateDeployment *bool `json:"enabledForTemplateDeployment,omitempty"` - HsmPoolResourceId *string `json:"hsmPoolResourceId,omitempty"` - NetworkAcls *NetworkRuleSet `json:"networkAcls,omitempty"` - PrivateEndpointConnections *[]PrivateEndpointConnectionItem `json:"privateEndpointConnections,omitempty"` - ProvisioningState *VaultProvisioningState `json:"provisioningState,omitempty"` - PublicNetworkAccess *string `json:"publicNetworkAccess,omitempty"` - Sku Sku `json:"sku"` - SoftDeleteRetentionInDays *int64 `json:"softDeleteRetentionInDays,omitempty"` - TenantId string `json:"tenantId"` - VaultUri *string `json:"vaultUri,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/vaults/model_virtualnetworkrule.go b/resource-manager/keyvault/2022-11-01/vaults/model_virtualnetworkrule.go deleted file mode 100644 index cd5b11b8aa7..00000000000 --- a/resource-manager/keyvault/2022-11-01/vaults/model_virtualnetworkrule.go +++ /dev/null @@ -1,9 +0,0 @@ -package vaults - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type VirtualNetworkRule struct { - Id string `json:"id"` - IgnoreMissingVnetServiceEndpoint *bool `json:"ignoreMissingVnetServiceEndpoint,omitempty"` -} diff --git a/resource-manager/keyvault/2022-11-01/vaults/predicates.go b/resource-manager/keyvault/2022-11-01/vaults/predicates.go deleted file mode 100644 index ded74b94926..00000000000 --- a/resource-manager/keyvault/2022-11-01/vaults/predicates.go +++ /dev/null @@ -1,83 +0,0 @@ -package vaults - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeletedVaultOperationPredicate struct { - Id *string - Name *string - Type *string -} - -func (p DeletedVaultOperationPredicate) Matches(input DeletedVault) bool { - - if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { - return false - } - - if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { - return false - } - - if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { - return false - } - - return true -} - -type ResourceOperationPredicate struct { - Id *string - Location *string - Name *string - Type *string -} - -func (p ResourceOperationPredicate) Matches(input Resource) bool { - - if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { - return false - } - - if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { - return false - } - - if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { - return false - } - - if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { - return false - } - - return true -} - -type VaultOperationPredicate struct { - Id *string - Location *string - Name *string - Type *string -} - -func (p VaultOperationPredicate) Matches(input Vault) 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/keyvault/2022-11-01/vaults/version.go b/resource-manager/keyvault/2022-11-01/vaults/version.go deleted file mode 100644 index 136e34e051d..00000000000 --- a/resource-manager/keyvault/2022-11-01/vaults/version.go +++ /dev/null @@ -1,12 +0,0 @@ -package vaults - -import "fmt" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -const defaultApiVersion = "2022-11-01" - -func userAgent() string { - return fmt.Sprintf("hashicorp/go-azure-sdk/vaults/%s", defaultApiVersion) -} diff --git a/resource-manager/keyvault/2023-07-01/client.go b/resource-manager/keyvault/2023-07-01/client.go index ebd1ba67b58..6b78e596b4f 100644 --- a/resource-manager/keyvault/2023-07-01/client.go +++ b/resource-manager/keyvault/2023-07-01/client.go @@ -4,7 +4,8 @@ package v2023_07_01 // Licensed under the MIT License. See NOTICE.txt in the project root for license information. import ( - "github.com/Azure/go-autorest/autorest" + "fmt" + "github.com/hashicorp/go-azure-sdk/resource-manager/keyvault/2023-07-01/keys" "github.com/hashicorp/go-azure-sdk/resource-manager/keyvault/2023-07-01/managedhsmkeys" "github.com/hashicorp/go-azure-sdk/resource-manager/keyvault/2023-07-01/managedhsms" @@ -16,6 +17,8 @@ import ( "github.com/hashicorp/go-azure-sdk/resource-manager/keyvault/2023-07-01/privatelinkresources" "github.com/hashicorp/go-azure-sdk/resource-manager/keyvault/2023-07-01/secrets" "github.com/hashicorp/go-azure-sdk/resource-manager/keyvault/2023-07-01/vaults" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" ) type Client struct { @@ -32,52 +35,84 @@ type Client struct { Vaults *vaults.VaultsClient } -func NewClientWithBaseURI(endpoint string, configureAuthFunc func(c *autorest.Client)) Client { - - keysClient := keys.NewKeysClientWithBaseURI(endpoint) - configureAuthFunc(&keysClient.Client) - - mHSMListPrivateEndpointConnectionsClient := mhsmlistprivateendpointconnections.NewMHSMListPrivateEndpointConnectionsClientWithBaseURI(endpoint) - configureAuthFunc(&mHSMListPrivateEndpointConnectionsClient.Client) +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + keysClient, err := keys.NewKeysClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Keys client: %+v", err) + } + configureFunc(keysClient.Client) - mHSMListRegionsClient := mhsmlistregions.NewMHSMListRegionsClientWithBaseURI(endpoint) - configureAuthFunc(&mHSMListRegionsClient.Client) + mHSMListPrivateEndpointConnectionsClient, err := mhsmlistprivateendpointconnections.NewMHSMListPrivateEndpointConnectionsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building MHSMListPrivateEndpointConnections client: %+v", err) + } + configureFunc(mHSMListPrivateEndpointConnectionsClient.Client) - mHSMPrivateEndpointConnectionsClient := mhsmprivateendpointconnections.NewMHSMPrivateEndpointConnectionsClientWithBaseURI(endpoint) - configureAuthFunc(&mHSMPrivateEndpointConnectionsClient.Client) + mHSMListRegionsClient, err := mhsmlistregions.NewMHSMListRegionsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building MHSMListRegions client: %+v", err) + } + configureFunc(mHSMListRegionsClient.Client) - mHSMPrivateLinkResourcesClient := mhsmprivatelinkresources.NewMHSMPrivateLinkResourcesClientWithBaseURI(endpoint) - configureAuthFunc(&mHSMPrivateLinkResourcesClient.Client) + mHSMPrivateEndpointConnectionsClient, err := mhsmprivateendpointconnections.NewMHSMPrivateEndpointConnectionsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building MHSMPrivateEndpointConnections client: %+v", err) + } + configureFunc(mHSMPrivateEndpointConnectionsClient.Client) - managedHsmKeysClient := managedhsmkeys.NewManagedHsmKeysClientWithBaseURI(endpoint) - configureAuthFunc(&managedHsmKeysClient.Client) + mHSMPrivateLinkResourcesClient, err := mhsmprivatelinkresources.NewMHSMPrivateLinkResourcesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building MHSMPrivateLinkResources client: %+v", err) + } + configureFunc(mHSMPrivateLinkResourcesClient.Client) - managedHsmsClient := managedhsms.NewManagedHsmsClientWithBaseURI(endpoint) - configureAuthFunc(&managedHsmsClient.Client) + managedHsmKeysClient, err := managedhsmkeys.NewManagedHsmKeysClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ManagedHsmKeys client: %+v", err) + } + configureFunc(managedHsmKeysClient.Client) - privateEndpointConnectionsClient := privateendpointconnections.NewPrivateEndpointConnectionsClientWithBaseURI(endpoint) - configureAuthFunc(&privateEndpointConnectionsClient.Client) + managedHsmsClient, err := managedhsms.NewManagedHsmsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ManagedHsms client: %+v", err) + } + configureFunc(managedHsmsClient.Client) - privateLinkResourcesClient := privatelinkresources.NewPrivateLinkResourcesClientWithBaseURI(endpoint) - configureAuthFunc(&privateLinkResourcesClient.Client) + privateEndpointConnectionsClient, err := privateendpointconnections.NewPrivateEndpointConnectionsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building PrivateEndpointConnections client: %+v", err) + } + configureFunc(privateEndpointConnectionsClient.Client) - secretsClient := secrets.NewSecretsClientWithBaseURI(endpoint) - configureAuthFunc(&secretsClient.Client) + privateLinkResourcesClient, err := privatelinkresources.NewPrivateLinkResourcesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building PrivateLinkResources client: %+v", err) + } + configureFunc(privateLinkResourcesClient.Client) - vaultsClient := vaults.NewVaultsClientWithBaseURI(endpoint) - configureAuthFunc(&vaultsClient.Client) + secretsClient, err := secrets.NewSecretsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Secrets client: %+v", err) + } + configureFunc(secretsClient.Client) - return Client{ - Keys: &keysClient, - MHSMListPrivateEndpointConnections: &mHSMListPrivateEndpointConnectionsClient, - MHSMListRegions: &mHSMListRegionsClient, - MHSMPrivateEndpointConnections: &mHSMPrivateEndpointConnectionsClient, - MHSMPrivateLinkResources: &mHSMPrivateLinkResourcesClient, - ManagedHsmKeys: &managedHsmKeysClient, - ManagedHsms: &managedHsmsClient, - PrivateEndpointConnections: &privateEndpointConnectionsClient, - PrivateLinkResources: &privateLinkResourcesClient, - Secrets: &secretsClient, - Vaults: &vaultsClient, + vaultsClient, err := vaults.NewVaultsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Vaults client: %+v", err) } + configureFunc(vaultsClient.Client) + + return &Client{ + Keys: keysClient, + MHSMListPrivateEndpointConnections: mHSMListPrivateEndpointConnectionsClient, + MHSMListRegions: mHSMListRegionsClient, + MHSMPrivateEndpointConnections: mHSMPrivateEndpointConnectionsClient, + MHSMPrivateLinkResources: mHSMPrivateLinkResourcesClient, + ManagedHsmKeys: managedHsmKeysClient, + ManagedHsms: managedHsmsClient, + PrivateEndpointConnections: privateEndpointConnectionsClient, + PrivateLinkResources: privateLinkResourcesClient, + Secrets: secretsClient, + Vaults: vaultsClient, + }, nil } diff --git a/resource-manager/keyvault/2023-07-01/keys/client.go b/resource-manager/keyvault/2023-07-01/keys/client.go index bc451013a0b..91e56411c78 100644 --- a/resource-manager/keyvault/2023-07-01/keys/client.go +++ b/resource-manager/keyvault/2023-07-01/keys/client.go @@ -1,18 +1,26 @@ package keys -import "github.com/Azure/go-autorest/autorest" +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 KeysClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewKeysClientWithBaseURI(endpoint string) KeysClient { - return KeysClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewKeysClientWithBaseURI(sdkApi sdkEnv.Api) (*KeysClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "keys", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating KeysClient: %+v", err) } + + return &KeysClient{ + Client: client, + }, nil } diff --git a/resource-manager/keyvault/2023-07-01/keys/constants.go b/resource-manager/keyvault/2023-07-01/keys/constants.go index 5709bbb5cef..ff9cd332a69 100644 --- a/resource-manager/keyvault/2023-07-01/keys/constants.go +++ b/resource-manager/keyvault/2023-07-01/keys/constants.go @@ -1,6 +1,10 @@ package keys -import "strings" +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. @@ -23,6 +27,19 @@ func PossibleValuesForDeletionRecoveryLevel() []string { } } +func (s *DeletionRecoveryLevel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeletionRecoveryLevel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseDeletionRecoveryLevel(input string) (*DeletionRecoveryLevel, error) { vals := map[string]DeletionRecoveryLevel{ "purgeable": DeletionRecoveryLevelPurgeable, @@ -57,6 +74,19 @@ func PossibleValuesForJsonWebKeyCurveName() []string { } } +func (s *JsonWebKeyCurveName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseJsonWebKeyCurveName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseJsonWebKeyCurveName(input string) (*JsonWebKeyCurveName, error) { vals := map[string]JsonWebKeyCurveName{ "p-521": JsonWebKeyCurveNamePNegativeFiveTwoOne, @@ -99,6 +129,19 @@ func PossibleValuesForJsonWebKeyOperation() []string { } } +func (s *JsonWebKeyOperation) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseJsonWebKeyOperation(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseJsonWebKeyOperation(input string) (*JsonWebKeyOperation, error) { vals := map[string]JsonWebKeyOperation{ "decrypt": JsonWebKeyOperationDecrypt, @@ -137,6 +180,19 @@ func PossibleValuesForJsonWebKeyType() []string { } } +func (s *JsonWebKeyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseJsonWebKeyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseJsonWebKeyType(input string) (*JsonWebKeyType, error) { vals := map[string]JsonWebKeyType{ "ec": JsonWebKeyTypeEC, @@ -167,6 +223,19 @@ func PossibleValuesForKeyRotationPolicyActionType() []string { } } +func (s *KeyRotationPolicyActionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKeyRotationPolicyActionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseKeyRotationPolicyActionType(input string) (*KeyRotationPolicyActionType, error) { vals := map[string]KeyRotationPolicyActionType{ "notify": KeyRotationPolicyActionTypeNotify, diff --git a/resource-manager/keyvault/2023-07-01/keys/method_createifnotexist.go b/resource-manager/keyvault/2023-07-01/keys/method_createifnotexist.go new file mode 100644 index 00000000000..1dd55e7588f --- /dev/null +++ b/resource-manager/keyvault/2023-07-01/keys/method_createifnotexist.go @@ -0,0 +1,56 @@ +package keys + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateIfNotExistOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Key +} + +// CreateIfNotExist ... +func (c KeysClient) CreateIfNotExist(ctx context.Context, id commonids.KeyVaultKeyId, input KeyCreateParameters) (result CreateIfNotExistOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/keyvault/2023-07-01/keys/method_createifnotexist_autorest.go b/resource-manager/keyvault/2023-07-01/keys/method_createifnotexist_autorest.go deleted file mode 100644 index 638f6c1d6b1..00000000000 --- a/resource-manager/keyvault/2023-07-01/keys/method_createifnotexist_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package keys - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateIfNotExistOperationResponse struct { - HttpResponse *http.Response - Model *Key -} - -// CreateIfNotExist ... -func (c KeysClient) CreateIfNotExist(ctx context.Context, id commonids.KeyVaultKeyId, input KeyCreateParameters) (result CreateIfNotExistOperationResponse, err error) { - req, err := c.preparerForCreateIfNotExist(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "CreateIfNotExist", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "CreateIfNotExist", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateIfNotExist(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "CreateIfNotExist", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateIfNotExist prepares the CreateIfNotExist request. -func (c KeysClient) preparerForCreateIfNotExist(ctx context.Context, id commonids.KeyVaultKeyId, input KeyCreateParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateIfNotExist handles the response to the CreateIfNotExist request. The method always -// closes the http.Response Body. -func (c KeysClient) responderForCreateIfNotExist(resp *http.Response) (result CreateIfNotExistOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2023-07-01/keys/method_get.go b/resource-manager/keyvault/2023-07-01/keys/method_get.go new file mode 100644 index 00000000000..0bfd51b62e9 --- /dev/null +++ b/resource-manager/keyvault/2023-07-01/keys/method_get.go @@ -0,0 +1,52 @@ +package keys + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Key +} + +// Get ... +func (c KeysClient) Get(ctx context.Context, id commonids.KeyVaultKeyId) (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 + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/keyvault/2023-07-01/keys/method_get_autorest.go b/resource-manager/keyvault/2023-07-01/keys/method_get_autorest.go deleted file mode 100644 index 5d081998ae6..00000000000 --- a/resource-manager/keyvault/2023-07-01/keys/method_get_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package keys - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *Key -} - -// Get ... -func (c KeysClient) Get(ctx context.Context, id commonids.KeyVaultKeyId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c KeysClient) preparerForGet(ctx context.Context, id commonids.KeyVaultKeyId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c KeysClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2023-07-01/keys/method_getversion.go b/resource-manager/keyvault/2023-07-01/keys/method_getversion.go new file mode 100644 index 00000000000..7f9907e55f7 --- /dev/null +++ b/resource-manager/keyvault/2023-07-01/keys/method_getversion.go @@ -0,0 +1,52 @@ +package keys + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetVersionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Key +} + +// GetVersion ... +func (c KeysClient) GetVersion(ctx context.Context, id commonids.KeyVaultKeyVersionId) (result GetVersionOperationResponse, 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 + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/keyvault/2023-07-01/keys/method_getversion_autorest.go b/resource-manager/keyvault/2023-07-01/keys/method_getversion_autorest.go deleted file mode 100644 index 97ea758183b..00000000000 --- a/resource-manager/keyvault/2023-07-01/keys/method_getversion_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package keys - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetVersionOperationResponse struct { - HttpResponse *http.Response - Model *Key -} - -// GetVersion ... -func (c KeysClient) GetVersion(ctx context.Context, id commonids.KeyVaultKeyVersionId) (result GetVersionOperationResponse, err error) { - req, err := c.preparerForGetVersion(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "GetVersion", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "GetVersion", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetVersion(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "GetVersion", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetVersion prepares the GetVersion request. -func (c KeysClient) preparerForGetVersion(ctx context.Context, id commonids.KeyVaultKeyVersionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetVersion handles the response to the GetVersion request. The method always -// closes the http.Response Body. -func (c KeysClient) responderForGetVersion(resp *http.Response) (result GetVersionOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2023-07-01/keys/method_list.go b/resource-manager/keyvault/2023-07-01/keys/method_list.go new file mode 100644 index 00000000000..44e0006d569 --- /dev/null +++ b/resource-manager/keyvault/2023-07-01/keys/method_list.go @@ -0,0 +1,92 @@ +package keys + +import ( + "context" + "fmt" + "net/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 *[]Key +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Key +} + +// List ... +func (c KeysClient) List(ctx context.Context, id commonids.KeyVaultId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/keys", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Key `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 KeysClient) ListComplete(ctx context.Context, id commonids.KeyVaultId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, KeyOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c KeysClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.KeyVaultId, predicate KeyOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Key, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/keyvault/2023-07-01/keys/method_list_autorest.go b/resource-manager/keyvault/2023-07-01/keys/method_list_autorest.go deleted file mode 100644 index c0ac89d60ff..00000000000 --- a/resource-manager/keyvault/2023-07-01/keys/method_list_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package keys - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *[]Key - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []Key -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// List ... -func (c KeysClient) List(ctx context.Context, id commonids.KeyVaultId) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c KeysClient) preparerForList(ctx context.Context, id commonids.KeyVaultId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/keys", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c KeysClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c KeysClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []Key `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { - req, err := c.preparerForListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c KeysClient) ListComplete(ctx context.Context, id commonids.KeyVaultId) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, KeyOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c KeysClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.KeyVaultId, predicate KeyOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]Key, 0) - - page, err := c.List(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/keyvault/2023-07-01/keys/method_listversions.go b/resource-manager/keyvault/2023-07-01/keys/method_listversions.go new file mode 100644 index 00000000000..23ba2149ebe --- /dev/null +++ b/resource-manager/keyvault/2023-07-01/keys/method_listversions.go @@ -0,0 +1,92 @@ +package keys + +import ( + "context" + "fmt" + "net/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 ListVersionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Key +} + +type ListVersionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []Key +} + +// ListVersions ... +func (c KeysClient) ListVersions(ctx context.Context, id commonids.KeyVaultKeyId) (result ListVersionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/versions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Key `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListVersionsComplete retrieves all the results into a single object +func (c KeysClient) ListVersionsComplete(ctx context.Context, id commonids.KeyVaultKeyId) (ListVersionsCompleteResult, error) { + return c.ListVersionsCompleteMatchingPredicate(ctx, id, KeyOperationPredicate{}) +} + +// ListVersionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c KeysClient) ListVersionsCompleteMatchingPredicate(ctx context.Context, id commonids.KeyVaultKeyId, predicate KeyOperationPredicate) (result ListVersionsCompleteResult, err error) { + items := make([]Key, 0) + + resp, err := c.ListVersions(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListVersionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/keyvault/2023-07-01/keys/method_listversions_autorest.go b/resource-manager/keyvault/2023-07-01/keys/method_listversions_autorest.go deleted file mode 100644 index f88803ad5ef..00000000000 --- a/resource-manager/keyvault/2023-07-01/keys/method_listversions_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package keys - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListVersionsOperationResponse struct { - HttpResponse *http.Response - Model *[]Key - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListVersionsOperationResponse, error) -} - -type ListVersionsCompleteResult struct { - Items []Key -} - -func (r ListVersionsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListVersionsOperationResponse) LoadMore(ctx context.Context) (resp ListVersionsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListVersions ... -func (c KeysClient) ListVersions(ctx context.Context, id commonids.KeyVaultKeyId) (resp ListVersionsOperationResponse, err error) { - req, err := c.preparerForListVersions(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "ListVersions", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "ListVersions", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListVersions(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "ListVersions", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListVersions prepares the ListVersions request. -func (c KeysClient) preparerForListVersions(ctx context.Context, id commonids.KeyVaultKeyId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/versions", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListVersionsWithNextLink prepares the ListVersions request with the given nextLink token. -func (c KeysClient) preparerForListVersionsWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListVersions handles the response to the ListVersions request. The method always -// closes the http.Response Body. -func (c KeysClient) responderForListVersions(resp *http.Response) (result ListVersionsOperationResponse, err error) { - type page struct { - Values []Key `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListVersionsOperationResponse, err error) { - req, err := c.preparerForListVersionsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "ListVersions", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "ListVersions", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListVersions(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "keys.KeysClient", "ListVersions", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListVersionsComplete retrieves all of the results into a single object -func (c KeysClient) ListVersionsComplete(ctx context.Context, id commonids.KeyVaultKeyId) (ListVersionsCompleteResult, error) { - return c.ListVersionsCompleteMatchingPredicate(ctx, id, KeyOperationPredicate{}) -} - -// ListVersionsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c KeysClient) ListVersionsCompleteMatchingPredicate(ctx context.Context, id commonids.KeyVaultKeyId, predicate KeyOperationPredicate) (resp ListVersionsCompleteResult, err error) { - items := make([]Key, 0) - - page, err := c.ListVersions(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListVersionsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/keyvault/2023-07-01/managedhsmkeys/client.go b/resource-manager/keyvault/2023-07-01/managedhsmkeys/client.go index 00b1e46fa11..e7245d7a210 100644 --- a/resource-manager/keyvault/2023-07-01/managedhsmkeys/client.go +++ b/resource-manager/keyvault/2023-07-01/managedhsmkeys/client.go @@ -1,18 +1,26 @@ package managedhsmkeys -import "github.com/Azure/go-autorest/autorest" +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 ManagedHsmKeysClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewManagedHsmKeysClientWithBaseURI(endpoint string) ManagedHsmKeysClient { - return ManagedHsmKeysClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewManagedHsmKeysClientWithBaseURI(sdkApi sdkEnv.Api) (*ManagedHsmKeysClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "managedhsmkeys", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ManagedHsmKeysClient: %+v", err) } + + return &ManagedHsmKeysClient{ + Client: client, + }, nil } diff --git a/resource-manager/keyvault/2023-07-01/managedhsmkeys/constants.go b/resource-manager/keyvault/2023-07-01/managedhsmkeys/constants.go index 62ac26a4df4..cb82cf7396c 100644 --- a/resource-manager/keyvault/2023-07-01/managedhsmkeys/constants.go +++ b/resource-manager/keyvault/2023-07-01/managedhsmkeys/constants.go @@ -1,6 +1,10 @@ package managedhsmkeys -import "strings" +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. @@ -23,6 +27,19 @@ func PossibleValuesForDeletionRecoveryLevel() []string { } } +func (s *DeletionRecoveryLevel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeletionRecoveryLevel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseDeletionRecoveryLevel(input string) (*DeletionRecoveryLevel, error) { vals := map[string]DeletionRecoveryLevel{ "purgeable": DeletionRecoveryLevelPurgeable, @@ -57,6 +74,19 @@ func PossibleValuesForJsonWebKeyCurveName() []string { } } +func (s *JsonWebKeyCurveName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseJsonWebKeyCurveName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseJsonWebKeyCurveName(input string) (*JsonWebKeyCurveName, error) { vals := map[string]JsonWebKeyCurveName{ "p-521": JsonWebKeyCurveNamePNegativeFiveTwoOne, @@ -99,6 +129,19 @@ func PossibleValuesForJsonWebKeyOperation() []string { } } +func (s *JsonWebKeyOperation) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseJsonWebKeyOperation(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseJsonWebKeyOperation(input string) (*JsonWebKeyOperation, error) { vals := map[string]JsonWebKeyOperation{ "decrypt": JsonWebKeyOperationDecrypt, @@ -137,6 +180,19 @@ func PossibleValuesForJsonWebKeyType() []string { } } +func (s *JsonWebKeyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseJsonWebKeyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseJsonWebKeyType(input string) (*JsonWebKeyType, error) { vals := map[string]JsonWebKeyType{ "ec": JsonWebKeyTypeEC, @@ -167,6 +223,19 @@ func PossibleValuesForKeyRotationPolicyActionType() []string { } } +func (s *KeyRotationPolicyActionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKeyRotationPolicyActionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseKeyRotationPolicyActionType(input string) (*KeyRotationPolicyActionType, error) { vals := map[string]KeyRotationPolicyActionType{ "notify": KeyRotationPolicyActionTypeNotify, diff --git a/resource-manager/keyvault/2023-07-01/managedhsmkeys/method_createifnotexist.go b/resource-manager/keyvault/2023-07-01/managedhsmkeys/method_createifnotexist.go new file mode 100644 index 00000000000..be7b1e4a9d3 --- /dev/null +++ b/resource-manager/keyvault/2023-07-01/managedhsmkeys/method_createifnotexist.go @@ -0,0 +1,55 @@ +package managedhsmkeys + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateIfNotExistOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ManagedHsmKey +} + +// CreateIfNotExist ... +func (c ManagedHsmKeysClient) CreateIfNotExist(ctx context.Context, id KeyId, input ManagedHsmKeyCreateParameters) (result CreateIfNotExistOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/keyvault/2023-07-01/managedhsmkeys/method_createifnotexist_autorest.go b/resource-manager/keyvault/2023-07-01/managedhsmkeys/method_createifnotexist_autorest.go deleted file mode 100644 index aa82950bb50..00000000000 --- a/resource-manager/keyvault/2023-07-01/managedhsmkeys/method_createifnotexist_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package managedhsmkeys - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateIfNotExistOperationResponse struct { - HttpResponse *http.Response - Model *ManagedHsmKey -} - -// CreateIfNotExist ... -func (c ManagedHsmKeysClient) CreateIfNotExist(ctx context.Context, id KeyId, input ManagedHsmKeyCreateParameters) (result CreateIfNotExistOperationResponse, err error) { - req, err := c.preparerForCreateIfNotExist(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsmkeys.ManagedHsmKeysClient", "CreateIfNotExist", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsmkeys.ManagedHsmKeysClient", "CreateIfNotExist", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateIfNotExist(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsmkeys.ManagedHsmKeysClient", "CreateIfNotExist", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateIfNotExist prepares the CreateIfNotExist request. -func (c ManagedHsmKeysClient) preparerForCreateIfNotExist(ctx context.Context, id KeyId, input ManagedHsmKeyCreateParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateIfNotExist handles the response to the CreateIfNotExist request. The method always -// closes the http.Response Body. -func (c ManagedHsmKeysClient) responderForCreateIfNotExist(resp *http.Response) (result CreateIfNotExistOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2023-07-01/managedhsmkeys/method_get.go b/resource-manager/keyvault/2023-07-01/managedhsmkeys/method_get.go new file mode 100644 index 00000000000..15239aa3975 --- /dev/null +++ b/resource-manager/keyvault/2023-07-01/managedhsmkeys/method_get.go @@ -0,0 +1,51 @@ +package managedhsmkeys + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *ManagedHsmKey +} + +// Get ... +func (c ManagedHsmKeysClient) Get(ctx context.Context, id KeyId) (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 + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/keyvault/2023-07-01/managedhsmkeys/method_get_autorest.go b/resource-manager/keyvault/2023-07-01/managedhsmkeys/method_get_autorest.go deleted file mode 100644 index db30eaf79c9..00000000000 --- a/resource-manager/keyvault/2023-07-01/managedhsmkeys/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package managedhsmkeys - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *ManagedHsmKey -} - -// Get ... -func (c ManagedHsmKeysClient) Get(ctx context.Context, id KeyId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsmkeys.ManagedHsmKeysClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsmkeys.ManagedHsmKeysClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsmkeys.ManagedHsmKeysClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ManagedHsmKeysClient) preparerForGet(ctx context.Context, id KeyId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c ManagedHsmKeysClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2023-07-01/managedhsmkeys/method_getversion.go b/resource-manager/keyvault/2023-07-01/managedhsmkeys/method_getversion.go new file mode 100644 index 00000000000..3124543940b --- /dev/null +++ b/resource-manager/keyvault/2023-07-01/managedhsmkeys/method_getversion.go @@ -0,0 +1,51 @@ +package managedhsmkeys + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetVersionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ManagedHsmKey +} + +// GetVersion ... +func (c ManagedHsmKeysClient) GetVersion(ctx context.Context, id VersionId) (result GetVersionOperationResponse, 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 + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/keyvault/2023-07-01/managedhsmkeys/method_getversion_autorest.go b/resource-manager/keyvault/2023-07-01/managedhsmkeys/method_getversion_autorest.go deleted file mode 100644 index 0ae2f0a6a44..00000000000 --- a/resource-manager/keyvault/2023-07-01/managedhsmkeys/method_getversion_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package managedhsmkeys - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetVersionOperationResponse struct { - HttpResponse *http.Response - Model *ManagedHsmKey -} - -// GetVersion ... -func (c ManagedHsmKeysClient) GetVersion(ctx context.Context, id VersionId) (result GetVersionOperationResponse, err error) { - req, err := c.preparerForGetVersion(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsmkeys.ManagedHsmKeysClient", "GetVersion", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsmkeys.ManagedHsmKeysClient", "GetVersion", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetVersion(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsmkeys.ManagedHsmKeysClient", "GetVersion", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetVersion prepares the GetVersion request. -func (c ManagedHsmKeysClient) preparerForGetVersion(ctx context.Context, id VersionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetVersion handles the response to the GetVersion request. The method always -// closes the http.Response Body. -func (c ManagedHsmKeysClient) responderForGetVersion(resp *http.Response) (result GetVersionOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2023-07-01/managedhsmkeys/method_list.go b/resource-manager/keyvault/2023-07-01/managedhsmkeys/method_list.go new file mode 100644 index 00000000000..7a9a0dd0c49 --- /dev/null +++ b/resource-manager/keyvault/2023-07-01/managedhsmkeys/method_list.go @@ -0,0 +1,91 @@ +package managedhsmkeys + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]ManagedHsmKey +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ManagedHsmKey +} + +// List ... +func (c ManagedHsmKeysClient) List(ctx context.Context, id ManagedHSMId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/keys", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ManagedHsmKey `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 ManagedHsmKeysClient) ListComplete(ctx context.Context, id ManagedHSMId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ManagedHsmKeyOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagedHsmKeysClient) ListCompleteMatchingPredicate(ctx context.Context, id ManagedHSMId, predicate ManagedHsmKeyOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ManagedHsmKey, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/keyvault/2023-07-01/managedhsmkeys/method_list_autorest.go b/resource-manager/keyvault/2023-07-01/managedhsmkeys/method_list_autorest.go deleted file mode 100644 index ed089028581..00000000000 --- a/resource-manager/keyvault/2023-07-01/managedhsmkeys/method_list_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package managedhsmkeys - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *[]ManagedHsmKey - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []ManagedHsmKey -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// List ... -func (c ManagedHsmKeysClient) List(ctx context.Context, id ManagedHSMId) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsmkeys.ManagedHsmKeysClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsmkeys.ManagedHsmKeysClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsmkeys.ManagedHsmKeysClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c ManagedHsmKeysClient) preparerForList(ctx context.Context, id ManagedHSMId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/keys", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c ManagedHsmKeysClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c ManagedHsmKeysClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []ManagedHsmKey `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { - req, err := c.preparerForListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsmkeys.ManagedHsmKeysClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsmkeys.ManagedHsmKeysClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsmkeys.ManagedHsmKeysClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c ManagedHsmKeysClient) ListComplete(ctx context.Context, id ManagedHSMId) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, ManagedHsmKeyOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ManagedHsmKeysClient) ListCompleteMatchingPredicate(ctx context.Context, id ManagedHSMId, predicate ManagedHsmKeyOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]ManagedHsmKey, 0) - - page, err := c.List(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/keyvault/2023-07-01/managedhsmkeys/method_listversions.go b/resource-manager/keyvault/2023-07-01/managedhsmkeys/method_listversions.go new file mode 100644 index 00000000000..ffbcaf291e7 --- /dev/null +++ b/resource-manager/keyvault/2023-07-01/managedhsmkeys/method_listversions.go @@ -0,0 +1,91 @@ +package managedhsmkeys + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListVersionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ManagedHsmKey +} + +type ListVersionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []ManagedHsmKey +} + +// ListVersions ... +func (c ManagedHsmKeysClient) ListVersions(ctx context.Context, id KeyId) (result ListVersionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/versions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ManagedHsmKey `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListVersionsComplete retrieves all the results into a single object +func (c ManagedHsmKeysClient) ListVersionsComplete(ctx context.Context, id KeyId) (ListVersionsCompleteResult, error) { + return c.ListVersionsCompleteMatchingPredicate(ctx, id, ManagedHsmKeyOperationPredicate{}) +} + +// ListVersionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagedHsmKeysClient) ListVersionsCompleteMatchingPredicate(ctx context.Context, id KeyId, predicate ManagedHsmKeyOperationPredicate) (result ListVersionsCompleteResult, err error) { + items := make([]ManagedHsmKey, 0) + + resp, err := c.ListVersions(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListVersionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/keyvault/2023-07-01/managedhsmkeys/method_listversions_autorest.go b/resource-manager/keyvault/2023-07-01/managedhsmkeys/method_listversions_autorest.go deleted file mode 100644 index 58118cbe7ad..00000000000 --- a/resource-manager/keyvault/2023-07-01/managedhsmkeys/method_listversions_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package managedhsmkeys - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListVersionsOperationResponse struct { - HttpResponse *http.Response - Model *[]ManagedHsmKey - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListVersionsOperationResponse, error) -} - -type ListVersionsCompleteResult struct { - Items []ManagedHsmKey -} - -func (r ListVersionsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListVersionsOperationResponse) LoadMore(ctx context.Context) (resp ListVersionsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListVersions ... -func (c ManagedHsmKeysClient) ListVersions(ctx context.Context, id KeyId) (resp ListVersionsOperationResponse, err error) { - req, err := c.preparerForListVersions(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsmkeys.ManagedHsmKeysClient", "ListVersions", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsmkeys.ManagedHsmKeysClient", "ListVersions", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListVersions(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsmkeys.ManagedHsmKeysClient", "ListVersions", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListVersions prepares the ListVersions request. -func (c ManagedHsmKeysClient) preparerForListVersions(ctx context.Context, id KeyId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/versions", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListVersionsWithNextLink prepares the ListVersions request with the given nextLink token. -func (c ManagedHsmKeysClient) preparerForListVersionsWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListVersions handles the response to the ListVersions request. The method always -// closes the http.Response Body. -func (c ManagedHsmKeysClient) responderForListVersions(resp *http.Response) (result ListVersionsOperationResponse, err error) { - type page struct { - Values []ManagedHsmKey `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListVersionsOperationResponse, err error) { - req, err := c.preparerForListVersionsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsmkeys.ManagedHsmKeysClient", "ListVersions", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsmkeys.ManagedHsmKeysClient", "ListVersions", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListVersions(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsmkeys.ManagedHsmKeysClient", "ListVersions", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListVersionsComplete retrieves all of the results into a single object -func (c ManagedHsmKeysClient) ListVersionsComplete(ctx context.Context, id KeyId) (ListVersionsCompleteResult, error) { - return c.ListVersionsCompleteMatchingPredicate(ctx, id, ManagedHsmKeyOperationPredicate{}) -} - -// ListVersionsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ManagedHsmKeysClient) ListVersionsCompleteMatchingPredicate(ctx context.Context, id KeyId, predicate ManagedHsmKeyOperationPredicate) (resp ListVersionsCompleteResult, err error) { - items := make([]ManagedHsmKey, 0) - - page, err := c.ListVersions(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListVersionsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/keyvault/2023-07-01/managedhsms/client.go b/resource-manager/keyvault/2023-07-01/managedhsms/client.go index 3063f136888..7d80c6b65a0 100644 --- a/resource-manager/keyvault/2023-07-01/managedhsms/client.go +++ b/resource-manager/keyvault/2023-07-01/managedhsms/client.go @@ -1,18 +1,26 @@ package managedhsms -import "github.com/Azure/go-autorest/autorest" +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 ManagedHsmsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewManagedHsmsClientWithBaseURI(endpoint string) ManagedHsmsClient { - return ManagedHsmsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewManagedHsmsClientWithBaseURI(sdkApi sdkEnv.Api) (*ManagedHsmsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "managedhsms", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ManagedHsmsClient: %+v", err) } + + return &ManagedHsmsClient{ + Client: client, + }, nil } diff --git a/resource-manager/keyvault/2023-07-01/managedhsms/constants.go b/resource-manager/keyvault/2023-07-01/managedhsms/constants.go index d6d903bd50d..b12fff596a8 100644 --- a/resource-manager/keyvault/2023-07-01/managedhsms/constants.go +++ b/resource-manager/keyvault/2023-07-01/managedhsms/constants.go @@ -1,6 +1,10 @@ package managedhsms -import "strings" +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. @@ -17,6 +21,19 @@ func PossibleValuesForActionsRequired() []string { } } +func (s *ActionsRequired) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseActionsRequired(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseActionsRequired(input string) (*ActionsRequired, error) { vals := map[string]ActionsRequired{ "none": ActionsRequiredNone, @@ -48,6 +65,19 @@ func PossibleValuesForActivationStatus() []string { } } +func (s *ActivationStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseActivationStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseActivationStatus(input string) (*ActivationStatus, error) { vals := map[string]ActivationStatus{ "active": ActivationStatusActive, @@ -78,6 +108,19 @@ func PossibleValuesForCreateMode() []string { } } +func (s *CreateMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCreateMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseCreateMode(input string) (*CreateMode, error) { vals := map[string]CreateMode{ "default": CreateModeDefault, @@ -114,6 +157,19 @@ func PossibleValuesForGeoReplicationRegionProvisioningState() []string { } } +func (s *GeoReplicationRegionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGeoReplicationRegionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseGeoReplicationRegionProvisioningState(input string) (*GeoReplicationRegionProvisioningState, error) { vals := map[string]GeoReplicationRegionProvisioningState{ "cleanup": GeoReplicationRegionProvisioningStateCleanup, @@ -144,6 +200,19 @@ func PossibleValuesForManagedHsmSkuFamily() []string { } } +func (s *ManagedHsmSkuFamily) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedHsmSkuFamily(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseManagedHsmSkuFamily(input string) (*ManagedHsmSkuFamily, error) { vals := map[string]ManagedHsmSkuFamily{ "b": ManagedHsmSkuFamilyB, @@ -173,6 +242,19 @@ func PossibleValuesForManagedHsmSkuName() []string { } } +func (s *ManagedHsmSkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedHsmSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseManagedHsmSkuName(input string) (*ManagedHsmSkuName, error) { vals := map[string]ManagedHsmSkuName{ "custom_b6": ManagedHsmSkuNameCustomBSix, @@ -202,6 +284,19 @@ func PossibleValuesForNetworkRuleAction() []string { } } +func (s *NetworkRuleAction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkRuleAction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseNetworkRuleAction(input string) (*NetworkRuleAction, error) { vals := map[string]NetworkRuleAction{ "allow": NetworkRuleActionAllow, @@ -230,6 +325,19 @@ func PossibleValuesForNetworkRuleBypassOptions() []string { } } +func (s *NetworkRuleBypassOptions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkRuleBypassOptions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseNetworkRuleBypassOptions(input string) (*NetworkRuleBypassOptions, error) { vals := map[string]NetworkRuleBypassOptions{ "azureservices": NetworkRuleBypassOptionsAzureServices, @@ -266,6 +374,19 @@ func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { } } +func (s *PrivateEndpointConnectionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointConnectionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { vals := map[string]PrivateEndpointConnectionProvisioningState{ "creating": PrivateEndpointConnectionProvisioningStateCreating, @@ -302,6 +423,19 @@ func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { } } +func (s *PrivateEndpointServiceConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointServiceConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { vals := map[string]PrivateEndpointServiceConnectionStatus{ "approved": PrivateEndpointServiceConnectionStatusApproved, @@ -344,6 +478,19 @@ func PossibleValuesForProvisioningState() []string { } } +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{ "activated": ProvisioningStateActivated, @@ -378,6 +525,19 @@ func PossibleValuesForPublicNetworkAccess() []string { } } +func (s *PublicNetworkAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicNetworkAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePublicNetworkAccess(input string) (*PublicNetworkAccess, error) { vals := map[string]PublicNetworkAccess{ "disabled": PublicNetworkAccessDisabled, @@ -406,6 +566,19 @@ func PossibleValuesForReason() []string { } } +func (s *Reason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseReason(input string) (*Reason, error) { vals := map[string]Reason{ "accountnameinvalid": ReasonAccountNameInvalid, diff --git a/resource-manager/keyvault/2023-07-01/managedhsms/method_checkmhsmnameavailability.go b/resource-manager/keyvault/2023-07-01/managedhsms/method_checkmhsmnameavailability.go new file mode 100644 index 00000000000..c5a17524779 --- /dev/null +++ b/resource-manager/keyvault/2023-07-01/managedhsms/method_checkmhsmnameavailability.go @@ -0,0 +1,57 @@ +package managedhsms + +import ( + "context" + "fmt" + "net/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 CheckMhsmNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CheckMhsmNameAvailabilityResult +} + +// CheckMhsmNameAvailability ... +func (c ManagedHsmsClient) CheckMhsmNameAvailability(ctx context.Context, id commonids.SubscriptionId, input CheckMhsmNameAvailabilityParameters) (result CheckMhsmNameAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.KeyVault/checkMhsmNameAvailability", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/keyvault/2023-07-01/managedhsms/method_checkmhsmnameavailability_autorest.go b/resource-manager/keyvault/2023-07-01/managedhsms/method_checkmhsmnameavailability_autorest.go deleted file mode 100644 index 1d6648210eb..00000000000 --- a/resource-manager/keyvault/2023-07-01/managedhsms/method_checkmhsmnameavailability_autorest.go +++ /dev/null @@ -1,71 +0,0 @@ -package managedhsms - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CheckMhsmNameAvailabilityOperationResponse struct { - HttpResponse *http.Response - Model *CheckMhsmNameAvailabilityResult -} - -// CheckMhsmNameAvailability ... -func (c ManagedHsmsClient) CheckMhsmNameAvailability(ctx context.Context, id commonids.SubscriptionId, input CheckMhsmNameAvailabilityParameters) (result CheckMhsmNameAvailabilityOperationResponse, err error) { - req, err := c.preparerForCheckMhsmNameAvailability(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "CheckMhsmNameAvailability", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "CheckMhsmNameAvailability", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCheckMhsmNameAvailability(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "CheckMhsmNameAvailability", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCheckMhsmNameAvailability prepares the CheckMhsmNameAvailability request. -func (c ManagedHsmsClient) preparerForCheckMhsmNameAvailability(ctx context.Context, id commonids.SubscriptionId, input CheckMhsmNameAvailabilityParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.KeyVault/checkMhsmNameAvailability", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCheckMhsmNameAvailability handles the response to the CheckMhsmNameAvailability request. The method always -// closes the http.Response Body. -func (c ManagedHsmsClient) responderForCheckMhsmNameAvailability(resp *http.Response) (result CheckMhsmNameAvailabilityOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2023-07-01/managedhsms/method_createorupdate.go b/resource-manager/keyvault/2023-07-01/managedhsms/method_createorupdate.go new file mode 100644 index 00000000000..91b4b268c93 --- /dev/null +++ b/resource-manager/keyvault/2023-07-01/managedhsms/method_createorupdate.go @@ -0,0 +1,79 @@ +package managedhsms + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ManagedHsm +} + +// CreateOrUpdate ... +func (c ManagedHsmsClient) CreateOrUpdate(ctx context.Context, id ManagedHSMId, input ManagedHsm) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c ManagedHsmsClient) CreateOrUpdateThenPoll(ctx context.Context, id ManagedHSMId, input ManagedHsm) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/keyvault/2023-07-01/managedhsms/method_createorupdate_autorest.go b/resource-manager/keyvault/2023-07-01/managedhsms/method_createorupdate_autorest.go deleted file mode 100644 index 13ea1b5b54e..00000000000 --- a/resource-manager/keyvault/2023-07-01/managedhsms/method_createorupdate_autorest.go +++ /dev/null @@ -1,80 +0,0 @@ -package managedhsms - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response - Model *ManagedHsm -} - -// CreateOrUpdate ... -func (c ManagedHsmsClient) CreateOrUpdate(ctx context.Context, id ManagedHSMId, input ManagedHsm) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c ManagedHsmsClient) CreateOrUpdateThenPoll(ctx context.Context, id ManagedHSMId, input ManagedHsm) error { - result, err := c.CreateOrUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c ManagedHsmsClient) preparerForCreateOrUpdate(ctx context.Context, id ManagedHSMId, input ManagedHsm) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c ManagedHsmsClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/keyvault/2023-07-01/managedhsms/method_delete.go b/resource-manager/keyvault/2023-07-01/managedhsms/method_delete.go new file mode 100644 index 00000000000..6f16d635189 --- /dev/null +++ b/resource-manager/keyvault/2023-07-01/managedhsms/method_delete.go @@ -0,0 +1,71 @@ +package managedhsms + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ManagedHsmsClient) Delete(ctx context.Context, id ManagedHSMId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c ManagedHsmsClient) DeleteThenPoll(ctx context.Context, id ManagedHSMId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/keyvault/2023-07-01/managedhsms/method_delete_autorest.go b/resource-manager/keyvault/2023-07-01/managedhsms/method_delete_autorest.go deleted file mode 100644 index 56fa4634de5..00000000000 --- a/resource-manager/keyvault/2023-07-01/managedhsms/method_delete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package managedhsms - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Delete ... -func (c ManagedHsmsClient) Delete(ctx context.Context, id ManagedHSMId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c ManagedHsmsClient) DeleteThenPoll(ctx context.Context, id ManagedHSMId) error { - result, err := c.Delete(ctx, id) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} - -// preparerForDelete prepares the Delete request. -func (c ManagedHsmsClient) preparerForDelete(ctx context.Context, id ManagedHSMId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDelete sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (c ManagedHsmsClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/keyvault/2023-07-01/managedhsms/method_get.go b/resource-manager/keyvault/2023-07-01/managedhsms/method_get.go new file mode 100644 index 00000000000..1025e8d36c5 --- /dev/null +++ b/resource-manager/keyvault/2023-07-01/managedhsms/method_get.go @@ -0,0 +1,52 @@ +package managedhsms + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *ManagedHsm +} + +// Get ... +func (c ManagedHsmsClient) Get(ctx context.Context, id ManagedHSMId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + 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 + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/keyvault/2023-07-01/managedhsms/method_get_autorest.go b/resource-manager/keyvault/2023-07-01/managedhsms/method_get_autorest.go deleted file mode 100644 index 827011f2ea0..00000000000 --- a/resource-manager/keyvault/2023-07-01/managedhsms/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package managedhsms - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *ManagedHsm -} - -// Get ... -func (c ManagedHsmsClient) Get(ctx context.Context, id ManagedHSMId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ManagedHsmsClient) preparerForGet(ctx context.Context, id ManagedHSMId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c ManagedHsmsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2023-07-01/managedhsms/method_getdeleted.go b/resource-manager/keyvault/2023-07-01/managedhsms/method_getdeleted.go new file mode 100644 index 00000000000..e2dbc231c3d --- /dev/null +++ b/resource-manager/keyvault/2023-07-01/managedhsms/method_getdeleted.go @@ -0,0 +1,51 @@ +package managedhsms + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetDeletedOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DeletedManagedHsm +} + +// GetDeleted ... +func (c ManagedHsmsClient) GetDeleted(ctx context.Context, id DeletedManagedHSMId) (result GetDeletedOperationResponse, 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 + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/keyvault/2023-07-01/managedhsms/method_getdeleted_autorest.go b/resource-manager/keyvault/2023-07-01/managedhsms/method_getdeleted_autorest.go deleted file mode 100644 index ad43ab79e1b..00000000000 --- a/resource-manager/keyvault/2023-07-01/managedhsms/method_getdeleted_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package managedhsms - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetDeletedOperationResponse struct { - HttpResponse *http.Response - Model *DeletedManagedHsm -} - -// GetDeleted ... -func (c ManagedHsmsClient) GetDeleted(ctx context.Context, id DeletedManagedHSMId) (result GetDeletedOperationResponse, err error) { - req, err := c.preparerForGetDeleted(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "GetDeleted", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "GetDeleted", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetDeleted(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "GetDeleted", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetDeleted prepares the GetDeleted request. -func (c ManagedHsmsClient) preparerForGetDeleted(ctx context.Context, id DeletedManagedHSMId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetDeleted handles the response to the GetDeleted request. The method always -// closes the http.Response Body. -func (c ManagedHsmsClient) responderForGetDeleted(resp *http.Response) (result GetDeletedOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2023-07-01/managedhsms/method_listbyresourcegroup.go b/resource-manager/keyvault/2023-07-01/managedhsms/method_listbyresourcegroup.go new file mode 100644 index 00000000000..3d678d2c8f5 --- /dev/null +++ b/resource-manager/keyvault/2023-07-01/managedhsms/method_listbyresourcegroup.go @@ -0,0 +1,120 @@ +package managedhsms + +import ( + "context" + "fmt" + "net/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 *[]ManagedHsm +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []ManagedHsm +} + +type ListByResourceGroupOperationOptions struct { + Top *int64 +} + +func DefaultListByResourceGroupOperationOptions() ListByResourceGroupOperationOptions { + return ListByResourceGroupOperationOptions{} +} + +func (o ListByResourceGroupOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByResourceGroupOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByResourceGroupOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByResourceGroup ... +func (c ManagedHsmsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.KeyVault/managedHSMs", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ManagedHsm `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 ManagedHsmsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, options, ManagedHsmOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagedHsmsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions, predicate ManagedHsmOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]ManagedHsm, 0) + + resp, err := c.ListByResourceGroup(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/keyvault/2023-07-01/managedhsms/method_listbyresourcegroup_autorest.go b/resource-manager/keyvault/2023-07-01/managedhsms/method_listbyresourcegroup_autorest.go deleted file mode 100644 index 941be9aa8ee..00000000000 --- a/resource-manager/keyvault/2023-07-01/managedhsms/method_listbyresourcegroup_autorest.go +++ /dev/null @@ -1,216 +0,0 @@ -package managedhsms - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// 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 - Model *[]ManagedHsm - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByResourceGroupOperationResponse, error) -} - -type ListByResourceGroupCompleteResult struct { - Items []ManagedHsm -} - -func (r ListByResourceGroupOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByResourceGroupOperationResponse) LoadMore(ctx context.Context) (resp ListByResourceGroupOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByResourceGroupOperationOptions struct { - Top *int64 -} - -func DefaultListByResourceGroupOperationOptions() ListByResourceGroupOperationOptions { - return ListByResourceGroupOperationOptions{} -} - -func (o ListByResourceGroupOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByResourceGroupOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByResourceGroup ... -func (c ManagedHsmsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (resp ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroup(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListByResourceGroup", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByResourceGroup(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListByResourceGroup", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByResourceGroup prepares the ListByResourceGroup request. -func (c ManagedHsmsClient) preparerForListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.KeyVault/managedHSMs", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByResourceGroupWithNextLink prepares the ListByResourceGroup request with the given nextLink token. -func (c ManagedHsmsClient) preparerForListByResourceGroupWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByResourceGroup handles the response to the ListByResourceGroup request. The method always -// closes the http.Response Body. -func (c ManagedHsmsClient) responderForListByResourceGroup(resp *http.Response) (result ListByResourceGroupOperationResponse, err error) { - type page struct { - Values []ManagedHsm `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroupWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListByResourceGroup", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByResourceGroup(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListByResourceGroup", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByResourceGroupComplete retrieves all of the results into a single object -func (c ManagedHsmsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (ListByResourceGroupCompleteResult, error) { - return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, options, ManagedHsmOperationPredicate{}) -} - -// ListByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ManagedHsmsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions, predicate ManagedHsmOperationPredicate) (resp ListByResourceGroupCompleteResult, err error) { - items := make([]ManagedHsm, 0) - - page, err := c.ListByResourceGroup(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByResourceGroupCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/keyvault/2023-07-01/managedhsms/method_listbysubscription.go b/resource-manager/keyvault/2023-07-01/managedhsms/method_listbysubscription.go new file mode 100644 index 00000000000..c5cb4236b40 --- /dev/null +++ b/resource-manager/keyvault/2023-07-01/managedhsms/method_listbysubscription.go @@ -0,0 +1,120 @@ +package managedhsms + +import ( + "context" + "fmt" + "net/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 *[]ManagedHsm +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []ManagedHsm +} + +type ListBySubscriptionOperationOptions struct { + Top *int64 +} + +func DefaultListBySubscriptionOperationOptions() ListBySubscriptionOperationOptions { + return ListBySubscriptionOperationOptions{} +} + +func (o ListBySubscriptionOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListBySubscriptionOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListBySubscriptionOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListBySubscription ... +func (c ManagedHsmsClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.KeyVault/managedHSMs", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ManagedHsm `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 ManagedHsmsClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, options, ManagedHsmOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagedHsmsClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions, predicate ManagedHsmOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]ManagedHsm, 0) + + resp, err := c.ListBySubscription(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/keyvault/2023-07-01/managedhsms/method_listbysubscription_autorest.go b/resource-manager/keyvault/2023-07-01/managedhsms/method_listbysubscription_autorest.go deleted file mode 100644 index fcf426e915e..00000000000 --- a/resource-manager/keyvault/2023-07-01/managedhsms/method_listbysubscription_autorest.go +++ /dev/null @@ -1,216 +0,0 @@ -package managedhsms - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// 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 - Model *[]ManagedHsm - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListBySubscriptionOperationResponse, error) -} - -type ListBySubscriptionCompleteResult struct { - Items []ManagedHsm -} - -func (r ListBySubscriptionOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListBySubscriptionOperationResponse) LoadMore(ctx context.Context) (resp ListBySubscriptionOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListBySubscriptionOperationOptions struct { - Top *int64 -} - -func DefaultListBySubscriptionOperationOptions() ListBySubscriptionOperationOptions { - return ListBySubscriptionOperationOptions{} -} - -func (o ListBySubscriptionOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListBySubscriptionOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListBySubscription ... -func (c ManagedHsmsClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions) (resp ListBySubscriptionOperationResponse, err error) { - req, err := c.preparerForListBySubscription(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListBySubscription", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListBySubscription", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListBySubscription(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListBySubscription", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListBySubscription prepares the ListBySubscription request. -func (c ManagedHsmsClient) preparerForListBySubscription(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.KeyVault/managedHSMs", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListBySubscriptionWithNextLink prepares the ListBySubscription request with the given nextLink token. -func (c ManagedHsmsClient) preparerForListBySubscriptionWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListBySubscription handles the response to the ListBySubscription request. The method always -// closes the http.Response Body. -func (c ManagedHsmsClient) responderForListBySubscription(resp *http.Response) (result ListBySubscriptionOperationResponse, err error) { - type page struct { - Values []ManagedHsm `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListBySubscriptionOperationResponse, err error) { - req, err := c.preparerForListBySubscriptionWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListBySubscription", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListBySubscription", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListBySubscription(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListBySubscription", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListBySubscriptionComplete retrieves all of the results into a single object -func (c ManagedHsmsClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions) (ListBySubscriptionCompleteResult, error) { - return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, options, ManagedHsmOperationPredicate{}) -} - -// ListBySubscriptionCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ManagedHsmsClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions, predicate ManagedHsmOperationPredicate) (resp ListBySubscriptionCompleteResult, err error) { - items := make([]ManagedHsm, 0) - - page, err := c.ListBySubscription(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListBySubscriptionCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/keyvault/2023-07-01/managedhsms/method_listdeleted.go b/resource-manager/keyvault/2023-07-01/managedhsms/method_listdeleted.go new file mode 100644 index 00000000000..93639db56ab --- /dev/null +++ b/resource-manager/keyvault/2023-07-01/managedhsms/method_listdeleted.go @@ -0,0 +1,92 @@ +package managedhsms + +import ( + "context" + "fmt" + "net/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 ListDeletedOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DeletedManagedHsm +} + +type ListDeletedCompleteResult struct { + LatestHttpResponse *http.Response + Items []DeletedManagedHsm +} + +// ListDeleted ... +func (c ManagedHsmsClient) ListDeleted(ctx context.Context, id commonids.SubscriptionId) (result ListDeletedOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.KeyVault/deletedManagedHSMs", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DeletedManagedHsm `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListDeletedComplete retrieves all the results into a single object +func (c ManagedHsmsClient) ListDeletedComplete(ctx context.Context, id commonids.SubscriptionId) (ListDeletedCompleteResult, error) { + return c.ListDeletedCompleteMatchingPredicate(ctx, id, DeletedManagedHsmOperationPredicate{}) +} + +// ListDeletedCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagedHsmsClient) ListDeletedCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate DeletedManagedHsmOperationPredicate) (result ListDeletedCompleteResult, err error) { + items := make([]DeletedManagedHsm, 0) + + resp, err := c.ListDeleted(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListDeletedCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/keyvault/2023-07-01/managedhsms/method_listdeleted_autorest.go b/resource-manager/keyvault/2023-07-01/managedhsms/method_listdeleted_autorest.go deleted file mode 100644 index 72c2fcb6ecb..00000000000 --- a/resource-manager/keyvault/2023-07-01/managedhsms/method_listdeleted_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package managedhsms - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListDeletedOperationResponse struct { - HttpResponse *http.Response - Model *[]DeletedManagedHsm - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListDeletedOperationResponse, error) -} - -type ListDeletedCompleteResult struct { - Items []DeletedManagedHsm -} - -func (r ListDeletedOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListDeletedOperationResponse) LoadMore(ctx context.Context) (resp ListDeletedOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListDeleted ... -func (c ManagedHsmsClient) ListDeleted(ctx context.Context, id commonids.SubscriptionId) (resp ListDeletedOperationResponse, err error) { - req, err := c.preparerForListDeleted(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListDeleted", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListDeleted", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListDeleted(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListDeleted", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListDeleted prepares the ListDeleted request. -func (c ManagedHsmsClient) preparerForListDeleted(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.KeyVault/deletedManagedHSMs", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListDeletedWithNextLink prepares the ListDeleted request with the given nextLink token. -func (c ManagedHsmsClient) preparerForListDeletedWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListDeleted handles the response to the ListDeleted request. The method always -// closes the http.Response Body. -func (c ManagedHsmsClient) responderForListDeleted(resp *http.Response) (result ListDeletedOperationResponse, err error) { - type page struct { - Values []DeletedManagedHsm `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListDeletedOperationResponse, err error) { - req, err := c.preparerForListDeletedWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListDeleted", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListDeleted", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListDeleted(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "ListDeleted", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListDeletedComplete retrieves all of the results into a single object -func (c ManagedHsmsClient) ListDeletedComplete(ctx context.Context, id commonids.SubscriptionId) (ListDeletedCompleteResult, error) { - return c.ListDeletedCompleteMatchingPredicate(ctx, id, DeletedManagedHsmOperationPredicate{}) -} - -// ListDeletedCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ManagedHsmsClient) ListDeletedCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate DeletedManagedHsmOperationPredicate) (resp ListDeletedCompleteResult, err error) { - items := make([]DeletedManagedHsm, 0) - - page, err := c.ListDeleted(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListDeletedCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/keyvault/2023-07-01/managedhsms/method_purgedeleted.go b/resource-manager/keyvault/2023-07-01/managedhsms/method_purgedeleted.go new file mode 100644 index 00000000000..efe27946375 --- /dev/null +++ b/resource-manager/keyvault/2023-07-01/managedhsms/method_purgedeleted.go @@ -0,0 +1,69 @@ +package managedhsms + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PurgeDeletedOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// PurgeDeleted ... +func (c ManagedHsmsClient) PurgeDeleted(ctx context.Context, id DeletedManagedHSMId) (result PurgeDeletedOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/purge", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// PurgeDeletedThenPoll performs PurgeDeleted then polls until it's completed +func (c ManagedHsmsClient) PurgeDeletedThenPoll(ctx context.Context, id DeletedManagedHSMId) error { + result, err := c.PurgeDeleted(ctx, id) + if err != nil { + return fmt.Errorf("performing PurgeDeleted: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after PurgeDeleted: %+v", err) + } + + return nil +} diff --git a/resource-manager/keyvault/2023-07-01/managedhsms/method_purgedeleted_autorest.go b/resource-manager/keyvault/2023-07-01/managedhsms/method_purgedeleted_autorest.go deleted file mode 100644 index 25a1e6e2654..00000000000 --- a/resource-manager/keyvault/2023-07-01/managedhsms/method_purgedeleted_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package managedhsms - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PurgeDeletedOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// PurgeDeleted ... -func (c ManagedHsmsClient) PurgeDeleted(ctx context.Context, id DeletedManagedHSMId) (result PurgeDeletedOperationResponse, err error) { - req, err := c.preparerForPurgeDeleted(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "PurgeDeleted", nil, "Failure preparing request") - return - } - - result, err = c.senderForPurgeDeleted(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "PurgeDeleted", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// PurgeDeletedThenPoll performs PurgeDeleted then polls until it's completed -func (c ManagedHsmsClient) PurgeDeletedThenPoll(ctx context.Context, id DeletedManagedHSMId) error { - result, err := c.PurgeDeleted(ctx, id) - if err != nil { - return fmt.Errorf("performing PurgeDeleted: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after PurgeDeleted: %+v", err) - } - - return nil -} - -// preparerForPurgeDeleted prepares the PurgeDeleted request. -func (c ManagedHsmsClient) preparerForPurgeDeleted(ctx context.Context, id DeletedManagedHSMId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/purge", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForPurgeDeleted sends the PurgeDeleted request. The method will close the -// http.Response Body if it receives an error. -func (c ManagedHsmsClient) senderForPurgeDeleted(ctx context.Context, req *http.Request) (future PurgeDeletedOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/keyvault/2023-07-01/managedhsms/method_update.go b/resource-manager/keyvault/2023-07-01/managedhsms/method_update.go new file mode 100644 index 00000000000..5a416125ad2 --- /dev/null +++ b/resource-manager/keyvault/2023-07-01/managedhsms/method_update.go @@ -0,0 +1,79 @@ +package managedhsms + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ManagedHsm +} + +// Update ... +func (c ManagedHsmsClient) Update(ctx context.Context, id ManagedHSMId, input ManagedHsm) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c ManagedHsmsClient) UpdateThenPoll(ctx context.Context, id ManagedHSMId, input ManagedHsm) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/resource-manager/keyvault/2023-07-01/managedhsms/method_update_autorest.go b/resource-manager/keyvault/2023-07-01/managedhsms/method_update_autorest.go deleted file mode 100644 index f0ad60994ca..00000000000 --- a/resource-manager/keyvault/2023-07-01/managedhsms/method_update_autorest.go +++ /dev/null @@ -1,80 +0,0 @@ -package managedhsms - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response - Model *ManagedHsm -} - -// Update ... -func (c ManagedHsmsClient) Update(ctx context.Context, id ManagedHSMId, input ManagedHsm) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "Update", nil, "Failure preparing request") - return - } - - result, err = c.senderForUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "managedhsms.ManagedHsmsClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// UpdateThenPoll performs Update then polls until it's completed -func (c ManagedHsmsClient) UpdateThenPoll(ctx context.Context, id ManagedHSMId, input ManagedHsm) error { - result, err := c.Update(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Update: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Update: %+v", err) - } - - return nil -} - -// preparerForUpdate prepares the Update request. -func (c ManagedHsmsClient) preparerForUpdate(ctx context.Context, id ManagedHSMId, input ManagedHsm) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForUpdate sends the Update request. The method will close the -// http.Response Body if it receives an error. -func (c ManagedHsmsClient) senderForUpdate(ctx context.Context, req *http.Request) (future UpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/keyvault/2023-07-01/mhsmlistprivateendpointconnections/client.go b/resource-manager/keyvault/2023-07-01/mhsmlistprivateendpointconnections/client.go index e8f5caf9f7b..5ae424fe241 100644 --- a/resource-manager/keyvault/2023-07-01/mhsmlistprivateendpointconnections/client.go +++ b/resource-manager/keyvault/2023-07-01/mhsmlistprivateendpointconnections/client.go @@ -1,18 +1,26 @@ package mhsmlistprivateendpointconnections -import "github.com/Azure/go-autorest/autorest" +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 MHSMListPrivateEndpointConnectionsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewMHSMListPrivateEndpointConnectionsClientWithBaseURI(endpoint string) MHSMListPrivateEndpointConnectionsClient { - return MHSMListPrivateEndpointConnectionsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewMHSMListPrivateEndpointConnectionsClientWithBaseURI(sdkApi sdkEnv.Api) (*MHSMListPrivateEndpointConnectionsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "mhsmlistprivateendpointconnections", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating MHSMListPrivateEndpointConnectionsClient: %+v", err) } + + return &MHSMListPrivateEndpointConnectionsClient{ + Client: client, + }, nil } diff --git a/resource-manager/keyvault/2023-07-01/mhsmlistprivateendpointconnections/constants.go b/resource-manager/keyvault/2023-07-01/mhsmlistprivateendpointconnections/constants.go index 6217f9d1eca..b090eefc340 100644 --- a/resource-manager/keyvault/2023-07-01/mhsmlistprivateendpointconnections/constants.go +++ b/resource-manager/keyvault/2023-07-01/mhsmlistprivateendpointconnections/constants.go @@ -1,6 +1,10 @@ package mhsmlistprivateendpointconnections -import "strings" +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. @@ -17,6 +21,19 @@ func PossibleValuesForActionsRequired() []string { } } +func (s *ActionsRequired) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseActionsRequired(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseActionsRequired(input string) (*ActionsRequired, error) { vals := map[string]ActionsRequired{ "none": ActionsRequiredNone, @@ -42,6 +59,19 @@ func PossibleValuesForManagedHsmSkuFamily() []string { } } +func (s *ManagedHsmSkuFamily) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedHsmSkuFamily(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseManagedHsmSkuFamily(input string) (*ManagedHsmSkuFamily, error) { vals := map[string]ManagedHsmSkuFamily{ "b": ManagedHsmSkuFamilyB, @@ -71,6 +101,19 @@ func PossibleValuesForManagedHsmSkuName() []string { } } +func (s *ManagedHsmSkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedHsmSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseManagedHsmSkuName(input string) (*ManagedHsmSkuName, error) { vals := map[string]ManagedHsmSkuName{ "custom_b6": ManagedHsmSkuNameCustomBSix, @@ -108,6 +151,19 @@ func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { } } +func (s *PrivateEndpointConnectionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointConnectionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { vals := map[string]PrivateEndpointConnectionProvisioningState{ "creating": PrivateEndpointConnectionProvisioningStateCreating, @@ -144,6 +200,19 @@ func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { } } +func (s *PrivateEndpointServiceConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointServiceConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { vals := map[string]PrivateEndpointServiceConnectionStatus{ "approved": PrivateEndpointServiceConnectionStatusApproved, diff --git a/resource-manager/keyvault/2023-07-01/mhsmlistprivateendpointconnections/method_mhsmprivateendpointconnectionslistbyresource.go b/resource-manager/keyvault/2023-07-01/mhsmlistprivateendpointconnections/method_mhsmprivateendpointconnectionslistbyresource.go new file mode 100644 index 00000000000..b910eeef477 --- /dev/null +++ b/resource-manager/keyvault/2023-07-01/mhsmlistprivateendpointconnections/method_mhsmprivateendpointconnectionslistbyresource.go @@ -0,0 +1,91 @@ +package mhsmlistprivateendpointconnections + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MHSMPrivateEndpointConnectionsListByResourceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]MHSMPrivateEndpointConnection +} + +type MHSMPrivateEndpointConnectionsListByResourceCompleteResult struct { + LatestHttpResponse *http.Response + Items []MHSMPrivateEndpointConnection +} + +// MHSMPrivateEndpointConnectionsListByResource ... +func (c MHSMListPrivateEndpointConnectionsClient) MHSMPrivateEndpointConnectionsListByResource(ctx context.Context, id ManagedHSMId) (result MHSMPrivateEndpointConnectionsListByResourceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateEndpointConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]MHSMPrivateEndpointConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// MHSMPrivateEndpointConnectionsListByResourceComplete retrieves all the results into a single object +func (c MHSMListPrivateEndpointConnectionsClient) MHSMPrivateEndpointConnectionsListByResourceComplete(ctx context.Context, id ManagedHSMId) (MHSMPrivateEndpointConnectionsListByResourceCompleteResult, error) { + return c.MHSMPrivateEndpointConnectionsListByResourceCompleteMatchingPredicate(ctx, id, MHSMPrivateEndpointConnectionOperationPredicate{}) +} + +// MHSMPrivateEndpointConnectionsListByResourceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c MHSMListPrivateEndpointConnectionsClient) MHSMPrivateEndpointConnectionsListByResourceCompleteMatchingPredicate(ctx context.Context, id ManagedHSMId, predicate MHSMPrivateEndpointConnectionOperationPredicate) (result MHSMPrivateEndpointConnectionsListByResourceCompleteResult, err error) { + items := make([]MHSMPrivateEndpointConnection, 0) + + resp, err := c.MHSMPrivateEndpointConnectionsListByResource(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = MHSMPrivateEndpointConnectionsListByResourceCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/keyvault/2023-07-01/mhsmlistprivateendpointconnections/method_mhsmprivateendpointconnectionslistbyresource_autorest.go b/resource-manager/keyvault/2023-07-01/mhsmlistprivateendpointconnections/method_mhsmprivateendpointconnectionslistbyresource_autorest.go deleted file mode 100644 index ee28909928e..00000000000 --- a/resource-manager/keyvault/2023-07-01/mhsmlistprivateendpointconnections/method_mhsmprivateendpointconnectionslistbyresource_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package mhsmlistprivateendpointconnections - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type MHSMPrivateEndpointConnectionsListByResourceOperationResponse struct { - HttpResponse *http.Response - Model *[]MHSMPrivateEndpointConnection - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (MHSMPrivateEndpointConnectionsListByResourceOperationResponse, error) -} - -type MHSMPrivateEndpointConnectionsListByResourceCompleteResult struct { - Items []MHSMPrivateEndpointConnection -} - -func (r MHSMPrivateEndpointConnectionsListByResourceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r MHSMPrivateEndpointConnectionsListByResourceOperationResponse) LoadMore(ctx context.Context) (resp MHSMPrivateEndpointConnectionsListByResourceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// MHSMPrivateEndpointConnectionsListByResource ... -func (c MHSMListPrivateEndpointConnectionsClient) MHSMPrivateEndpointConnectionsListByResource(ctx context.Context, id ManagedHSMId) (resp MHSMPrivateEndpointConnectionsListByResourceOperationResponse, err error) { - req, err := c.preparerForMHSMPrivateEndpointConnectionsListByResource(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmlistprivateendpointconnections.MHSMListPrivateEndpointConnectionsClient", "MHSMPrivateEndpointConnectionsListByResource", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmlistprivateendpointconnections.MHSMListPrivateEndpointConnectionsClient", "MHSMPrivateEndpointConnectionsListByResource", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForMHSMPrivateEndpointConnectionsListByResource(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmlistprivateendpointconnections.MHSMListPrivateEndpointConnectionsClient", "MHSMPrivateEndpointConnectionsListByResource", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForMHSMPrivateEndpointConnectionsListByResource prepares the MHSMPrivateEndpointConnectionsListByResource request. -func (c MHSMListPrivateEndpointConnectionsClient) preparerForMHSMPrivateEndpointConnectionsListByResource(ctx context.Context, id ManagedHSMId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/privateEndpointConnections", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForMHSMPrivateEndpointConnectionsListByResourceWithNextLink prepares the MHSMPrivateEndpointConnectionsListByResource request with the given nextLink token. -func (c MHSMListPrivateEndpointConnectionsClient) preparerForMHSMPrivateEndpointConnectionsListByResourceWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForMHSMPrivateEndpointConnectionsListByResource handles the response to the MHSMPrivateEndpointConnectionsListByResource request. The method always -// closes the http.Response Body. -func (c MHSMListPrivateEndpointConnectionsClient) responderForMHSMPrivateEndpointConnectionsListByResource(resp *http.Response) (result MHSMPrivateEndpointConnectionsListByResourceOperationResponse, err error) { - type page struct { - Values []MHSMPrivateEndpointConnection `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result MHSMPrivateEndpointConnectionsListByResourceOperationResponse, err error) { - req, err := c.preparerForMHSMPrivateEndpointConnectionsListByResourceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmlistprivateendpointconnections.MHSMListPrivateEndpointConnectionsClient", "MHSMPrivateEndpointConnectionsListByResource", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmlistprivateendpointconnections.MHSMListPrivateEndpointConnectionsClient", "MHSMPrivateEndpointConnectionsListByResource", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForMHSMPrivateEndpointConnectionsListByResource(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmlistprivateendpointconnections.MHSMListPrivateEndpointConnectionsClient", "MHSMPrivateEndpointConnectionsListByResource", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// MHSMPrivateEndpointConnectionsListByResourceComplete retrieves all of the results into a single object -func (c MHSMListPrivateEndpointConnectionsClient) MHSMPrivateEndpointConnectionsListByResourceComplete(ctx context.Context, id ManagedHSMId) (MHSMPrivateEndpointConnectionsListByResourceCompleteResult, error) { - return c.MHSMPrivateEndpointConnectionsListByResourceCompleteMatchingPredicate(ctx, id, MHSMPrivateEndpointConnectionOperationPredicate{}) -} - -// MHSMPrivateEndpointConnectionsListByResourceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c MHSMListPrivateEndpointConnectionsClient) MHSMPrivateEndpointConnectionsListByResourceCompleteMatchingPredicate(ctx context.Context, id ManagedHSMId, predicate MHSMPrivateEndpointConnectionOperationPredicate) (resp MHSMPrivateEndpointConnectionsListByResourceCompleteResult, err error) { - items := make([]MHSMPrivateEndpointConnection, 0) - - page, err := c.MHSMPrivateEndpointConnectionsListByResource(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := MHSMPrivateEndpointConnectionsListByResourceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/keyvault/2023-07-01/mhsmlistregions/client.go b/resource-manager/keyvault/2023-07-01/mhsmlistregions/client.go index d9601517581..2afc4c3e8f1 100644 --- a/resource-manager/keyvault/2023-07-01/mhsmlistregions/client.go +++ b/resource-manager/keyvault/2023-07-01/mhsmlistregions/client.go @@ -1,18 +1,26 @@ package mhsmlistregions -import "github.com/Azure/go-autorest/autorest" +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 MHSMListRegionsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewMHSMListRegionsClientWithBaseURI(endpoint string) MHSMListRegionsClient { - return MHSMListRegionsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewMHSMListRegionsClientWithBaseURI(sdkApi sdkEnv.Api) (*MHSMListRegionsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "mhsmlistregions", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating MHSMListRegionsClient: %+v", err) } + + return &MHSMListRegionsClient{ + Client: client, + }, nil } diff --git a/resource-manager/keyvault/2023-07-01/mhsmlistregions/constants.go b/resource-manager/keyvault/2023-07-01/mhsmlistregions/constants.go index 74a0de32d31..1fb1987323b 100644 --- a/resource-manager/keyvault/2023-07-01/mhsmlistregions/constants.go +++ b/resource-manager/keyvault/2023-07-01/mhsmlistregions/constants.go @@ -1,6 +1,10 @@ package mhsmlistregions -import "strings" +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. @@ -27,6 +31,19 @@ func PossibleValuesForGeoReplicationRegionProvisioningState() []string { } } +func (s *GeoReplicationRegionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGeoReplicationRegionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseGeoReplicationRegionProvisioningState(input string) (*GeoReplicationRegionProvisioningState, error) { vals := map[string]GeoReplicationRegionProvisioningState{ "cleanup": GeoReplicationRegionProvisioningStateCleanup, diff --git a/resource-manager/keyvault/2023-07-01/mhsmlistregions/method_mhsmregionslistbyresource.go b/resource-manager/keyvault/2023-07-01/mhsmlistregions/method_mhsmregionslistbyresource.go new file mode 100644 index 00000000000..3818aa259d7 --- /dev/null +++ b/resource-manager/keyvault/2023-07-01/mhsmlistregions/method_mhsmregionslistbyresource.go @@ -0,0 +1,91 @@ +package mhsmlistregions + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MHSMRegionsListByResourceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]MHSMGeoReplicatedRegion +} + +type MHSMRegionsListByResourceCompleteResult struct { + LatestHttpResponse *http.Response + Items []MHSMGeoReplicatedRegion +} + +// MHSMRegionsListByResource ... +func (c MHSMListRegionsClient) MHSMRegionsListByResource(ctx context.Context, id ManagedHSMId) (result MHSMRegionsListByResourceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/regions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]MHSMGeoReplicatedRegion `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// MHSMRegionsListByResourceComplete retrieves all the results into a single object +func (c MHSMListRegionsClient) MHSMRegionsListByResourceComplete(ctx context.Context, id ManagedHSMId) (MHSMRegionsListByResourceCompleteResult, error) { + return c.MHSMRegionsListByResourceCompleteMatchingPredicate(ctx, id, MHSMGeoReplicatedRegionOperationPredicate{}) +} + +// MHSMRegionsListByResourceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c MHSMListRegionsClient) MHSMRegionsListByResourceCompleteMatchingPredicate(ctx context.Context, id ManagedHSMId, predicate MHSMGeoReplicatedRegionOperationPredicate) (result MHSMRegionsListByResourceCompleteResult, err error) { + items := make([]MHSMGeoReplicatedRegion, 0) + + resp, err := c.MHSMRegionsListByResource(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = MHSMRegionsListByResourceCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/keyvault/2023-07-01/mhsmlistregions/method_mhsmregionslistbyresource_autorest.go b/resource-manager/keyvault/2023-07-01/mhsmlistregions/method_mhsmregionslistbyresource_autorest.go deleted file mode 100644 index e5ef2b4033f..00000000000 --- a/resource-manager/keyvault/2023-07-01/mhsmlistregions/method_mhsmregionslistbyresource_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package mhsmlistregions - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type MHSMRegionsListByResourceOperationResponse struct { - HttpResponse *http.Response - Model *[]MHSMGeoReplicatedRegion - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (MHSMRegionsListByResourceOperationResponse, error) -} - -type MHSMRegionsListByResourceCompleteResult struct { - Items []MHSMGeoReplicatedRegion -} - -func (r MHSMRegionsListByResourceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r MHSMRegionsListByResourceOperationResponse) LoadMore(ctx context.Context) (resp MHSMRegionsListByResourceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// MHSMRegionsListByResource ... -func (c MHSMListRegionsClient) MHSMRegionsListByResource(ctx context.Context, id ManagedHSMId) (resp MHSMRegionsListByResourceOperationResponse, err error) { - req, err := c.preparerForMHSMRegionsListByResource(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmlistregions.MHSMListRegionsClient", "MHSMRegionsListByResource", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmlistregions.MHSMListRegionsClient", "MHSMRegionsListByResource", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForMHSMRegionsListByResource(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmlistregions.MHSMListRegionsClient", "MHSMRegionsListByResource", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForMHSMRegionsListByResource prepares the MHSMRegionsListByResource request. -func (c MHSMListRegionsClient) preparerForMHSMRegionsListByResource(ctx context.Context, id ManagedHSMId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/regions", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForMHSMRegionsListByResourceWithNextLink prepares the MHSMRegionsListByResource request with the given nextLink token. -func (c MHSMListRegionsClient) preparerForMHSMRegionsListByResourceWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForMHSMRegionsListByResource handles the response to the MHSMRegionsListByResource request. The method always -// closes the http.Response Body. -func (c MHSMListRegionsClient) responderForMHSMRegionsListByResource(resp *http.Response) (result MHSMRegionsListByResourceOperationResponse, err error) { - type page struct { - Values []MHSMGeoReplicatedRegion `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result MHSMRegionsListByResourceOperationResponse, err error) { - req, err := c.preparerForMHSMRegionsListByResourceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmlistregions.MHSMListRegionsClient", "MHSMRegionsListByResource", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmlistregions.MHSMListRegionsClient", "MHSMRegionsListByResource", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForMHSMRegionsListByResource(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmlistregions.MHSMListRegionsClient", "MHSMRegionsListByResource", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// MHSMRegionsListByResourceComplete retrieves all of the results into a single object -func (c MHSMListRegionsClient) MHSMRegionsListByResourceComplete(ctx context.Context, id ManagedHSMId) (MHSMRegionsListByResourceCompleteResult, error) { - return c.MHSMRegionsListByResourceCompleteMatchingPredicate(ctx, id, MHSMGeoReplicatedRegionOperationPredicate{}) -} - -// MHSMRegionsListByResourceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c MHSMListRegionsClient) MHSMRegionsListByResourceCompleteMatchingPredicate(ctx context.Context, id ManagedHSMId, predicate MHSMGeoReplicatedRegionOperationPredicate) (resp MHSMRegionsListByResourceCompleteResult, err error) { - items := make([]MHSMGeoReplicatedRegion, 0) - - page, err := c.MHSMRegionsListByResource(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := MHSMRegionsListByResourceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/keyvault/2023-07-01/mhsmprivateendpointconnections/client.go b/resource-manager/keyvault/2023-07-01/mhsmprivateendpointconnections/client.go index 933a39f9036..710a4a6195a 100644 --- a/resource-manager/keyvault/2023-07-01/mhsmprivateendpointconnections/client.go +++ b/resource-manager/keyvault/2023-07-01/mhsmprivateendpointconnections/client.go @@ -1,18 +1,26 @@ package mhsmprivateendpointconnections -import "github.com/Azure/go-autorest/autorest" +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 MHSMPrivateEndpointConnectionsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewMHSMPrivateEndpointConnectionsClientWithBaseURI(endpoint string) MHSMPrivateEndpointConnectionsClient { - return MHSMPrivateEndpointConnectionsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewMHSMPrivateEndpointConnectionsClientWithBaseURI(sdkApi sdkEnv.Api) (*MHSMPrivateEndpointConnectionsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "mhsmprivateendpointconnections", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating MHSMPrivateEndpointConnectionsClient: %+v", err) } + + return &MHSMPrivateEndpointConnectionsClient{ + Client: client, + }, nil } diff --git a/resource-manager/keyvault/2023-07-01/mhsmprivateendpointconnections/constants.go b/resource-manager/keyvault/2023-07-01/mhsmprivateendpointconnections/constants.go index c8d3a4886e3..1681432cb1a 100644 --- a/resource-manager/keyvault/2023-07-01/mhsmprivateendpointconnections/constants.go +++ b/resource-manager/keyvault/2023-07-01/mhsmprivateendpointconnections/constants.go @@ -1,6 +1,10 @@ package mhsmprivateendpointconnections -import "strings" +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. @@ -17,6 +21,19 @@ func PossibleValuesForActionsRequired() []string { } } +func (s *ActionsRequired) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseActionsRequired(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseActionsRequired(input string) (*ActionsRequired, error) { vals := map[string]ActionsRequired{ "none": ActionsRequiredNone, @@ -42,6 +59,19 @@ func PossibleValuesForManagedHsmSkuFamily() []string { } } +func (s *ManagedHsmSkuFamily) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedHsmSkuFamily(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseManagedHsmSkuFamily(input string) (*ManagedHsmSkuFamily, error) { vals := map[string]ManagedHsmSkuFamily{ "b": ManagedHsmSkuFamilyB, @@ -71,6 +101,19 @@ func PossibleValuesForManagedHsmSkuName() []string { } } +func (s *ManagedHsmSkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedHsmSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseManagedHsmSkuName(input string) (*ManagedHsmSkuName, error) { vals := map[string]ManagedHsmSkuName{ "custom_b6": ManagedHsmSkuNameCustomBSix, @@ -108,6 +151,19 @@ func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { } } +func (s *PrivateEndpointConnectionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointConnectionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { vals := map[string]PrivateEndpointConnectionProvisioningState{ "creating": PrivateEndpointConnectionProvisioningStateCreating, @@ -144,6 +200,19 @@ func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { } } +func (s *PrivateEndpointServiceConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointServiceConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { vals := map[string]PrivateEndpointServiceConnectionStatus{ "approved": PrivateEndpointServiceConnectionStatusApproved, diff --git a/resource-manager/keyvault/2023-07-01/mhsmprivateendpointconnections/method_delete.go b/resource-manager/keyvault/2023-07-01/mhsmprivateendpointconnections/method_delete.go new file mode 100644 index 00000000000..f51f98a2fd5 --- /dev/null +++ b/resource-manager/keyvault/2023-07-01/mhsmprivateendpointconnections/method_delete.go @@ -0,0 +1,76 @@ +package mhsmprivateendpointconnections + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *MHSMPrivateEndpointConnection +} + +// Delete ... +func (c MHSMPrivateEndpointConnectionsClient) Delete(ctx context.Context, id PrivateEndpointConnectionId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + 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 + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c MHSMPrivateEndpointConnectionsClient) DeleteThenPoll(ctx context.Context, id PrivateEndpointConnectionId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/keyvault/2023-07-01/mhsmprivateendpointconnections/method_delete_autorest.go b/resource-manager/keyvault/2023-07-01/mhsmprivateendpointconnections/method_delete_autorest.go deleted file mode 100644 index d3eef6a25df..00000000000 --- a/resource-manager/keyvault/2023-07-01/mhsmprivateendpointconnections/method_delete_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package mhsmprivateendpointconnections - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response - Model *MHSMPrivateEndpointConnection -} - -// Delete ... -func (c MHSMPrivateEndpointConnectionsClient) Delete(ctx context.Context, id PrivateEndpointConnectionId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmprivateendpointconnections.MHSMPrivateEndpointConnectionsClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmprivateendpointconnections.MHSMPrivateEndpointConnectionsClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c MHSMPrivateEndpointConnectionsClient) DeleteThenPoll(ctx context.Context, id PrivateEndpointConnectionId) error { - result, err := c.Delete(ctx, id) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} - -// preparerForDelete prepares the Delete request. -func (c MHSMPrivateEndpointConnectionsClient) preparerForDelete(ctx context.Context, id PrivateEndpointConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDelete sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (c MHSMPrivateEndpointConnectionsClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/keyvault/2023-07-01/mhsmprivateendpointconnections/method_get.go b/resource-manager/keyvault/2023-07-01/mhsmprivateendpointconnections/method_get.go new file mode 100644 index 00000000000..0d6f190b40f --- /dev/null +++ b/resource-manager/keyvault/2023-07-01/mhsmprivateendpointconnections/method_get.go @@ -0,0 +1,51 @@ +package mhsmprivateendpointconnections + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *MHSMPrivateEndpointConnection +} + +// Get ... +func (c MHSMPrivateEndpointConnectionsClient) Get(ctx context.Context, id PrivateEndpointConnectionId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/keyvault/2023-07-01/mhsmprivateendpointconnections/method_get_autorest.go b/resource-manager/keyvault/2023-07-01/mhsmprivateendpointconnections/method_get_autorest.go deleted file mode 100644 index e20835facef..00000000000 --- a/resource-manager/keyvault/2023-07-01/mhsmprivateendpointconnections/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package mhsmprivateendpointconnections - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *MHSMPrivateEndpointConnection -} - -// Get ... -func (c MHSMPrivateEndpointConnectionsClient) Get(ctx context.Context, id PrivateEndpointConnectionId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmprivateendpointconnections.MHSMPrivateEndpointConnectionsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmprivateendpointconnections.MHSMPrivateEndpointConnectionsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmprivateendpointconnections.MHSMPrivateEndpointConnectionsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c MHSMPrivateEndpointConnectionsClient) preparerForGet(ctx context.Context, id PrivateEndpointConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c MHSMPrivateEndpointConnectionsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2023-07-01/mhsmprivateendpointconnections/method_put.go b/resource-manager/keyvault/2023-07-01/mhsmprivateendpointconnections/method_put.go new file mode 100644 index 00000000000..b0f0e17635a --- /dev/null +++ b/resource-manager/keyvault/2023-07-01/mhsmprivateendpointconnections/method_put.go @@ -0,0 +1,55 @@ +package mhsmprivateendpointconnections + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PutOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MHSMPrivateEndpointConnection +} + +// Put ... +func (c MHSMPrivateEndpointConnectionsClient) Put(ctx context.Context, id PrivateEndpointConnectionId, input MHSMPrivateEndpointConnection) (result PutOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/keyvault/2023-07-01/mhsmprivateendpointconnections/method_put_autorest.go b/resource-manager/keyvault/2023-07-01/mhsmprivateendpointconnections/method_put_autorest.go deleted file mode 100644 index 61f1cad7759..00000000000 --- a/resource-manager/keyvault/2023-07-01/mhsmprivateendpointconnections/method_put_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package mhsmprivateendpointconnections - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PutOperationResponse struct { - HttpResponse *http.Response - Model *MHSMPrivateEndpointConnection -} - -// Put ... -func (c MHSMPrivateEndpointConnectionsClient) Put(ctx context.Context, id PrivateEndpointConnectionId, input MHSMPrivateEndpointConnection) (result PutOperationResponse, err error) { - req, err := c.preparerForPut(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmprivateendpointconnections.MHSMPrivateEndpointConnectionsClient", "Put", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmprivateendpointconnections.MHSMPrivateEndpointConnectionsClient", "Put", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForPut(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmprivateendpointconnections.MHSMPrivateEndpointConnectionsClient", "Put", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForPut prepares the Put request. -func (c MHSMPrivateEndpointConnectionsClient) preparerForPut(ctx context.Context, id PrivateEndpointConnectionId, input MHSMPrivateEndpointConnection) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForPut handles the response to the Put request. The method always -// closes the http.Response Body. -func (c MHSMPrivateEndpointConnectionsClient) responderForPut(resp *http.Response) (result PutOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2023-07-01/mhsmprivatelinkresources/client.go b/resource-manager/keyvault/2023-07-01/mhsmprivatelinkresources/client.go index 45db1c12858..5748b25631c 100644 --- a/resource-manager/keyvault/2023-07-01/mhsmprivatelinkresources/client.go +++ b/resource-manager/keyvault/2023-07-01/mhsmprivatelinkresources/client.go @@ -1,18 +1,26 @@ package mhsmprivatelinkresources -import "github.com/Azure/go-autorest/autorest" +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 MHSMPrivateLinkResourcesClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewMHSMPrivateLinkResourcesClientWithBaseURI(endpoint string) MHSMPrivateLinkResourcesClient { - return MHSMPrivateLinkResourcesClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewMHSMPrivateLinkResourcesClientWithBaseURI(sdkApi sdkEnv.Api) (*MHSMPrivateLinkResourcesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "mhsmprivatelinkresources", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating MHSMPrivateLinkResourcesClient: %+v", err) } + + return &MHSMPrivateLinkResourcesClient{ + Client: client, + }, nil } diff --git a/resource-manager/keyvault/2023-07-01/mhsmprivatelinkresources/constants.go b/resource-manager/keyvault/2023-07-01/mhsmprivatelinkresources/constants.go index aa5754b95cd..849f0230029 100644 --- a/resource-manager/keyvault/2023-07-01/mhsmprivatelinkresources/constants.go +++ b/resource-manager/keyvault/2023-07-01/mhsmprivatelinkresources/constants.go @@ -1,6 +1,10 @@ package mhsmprivatelinkresources -import "strings" +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. @@ -17,6 +21,19 @@ func PossibleValuesForManagedHsmSkuFamily() []string { } } +func (s *ManagedHsmSkuFamily) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedHsmSkuFamily(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseManagedHsmSkuFamily(input string) (*ManagedHsmSkuFamily, error) { vals := map[string]ManagedHsmSkuFamily{ "b": ManagedHsmSkuFamilyB, @@ -46,6 +63,19 @@ func PossibleValuesForManagedHsmSkuName() []string { } } +func (s *ManagedHsmSkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedHsmSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseManagedHsmSkuName(input string) (*ManagedHsmSkuName, error) { vals := map[string]ManagedHsmSkuName{ "custom_b6": ManagedHsmSkuNameCustomBSix, diff --git a/resource-manager/keyvault/2023-07-01/mhsmprivatelinkresources/method_listbymhsmresource.go b/resource-manager/keyvault/2023-07-01/mhsmprivatelinkresources/method_listbymhsmresource.go new file mode 100644 index 00000000000..ff310315267 --- /dev/null +++ b/resource-manager/keyvault/2023-07-01/mhsmprivatelinkresources/method_listbymhsmresource.go @@ -0,0 +1,52 @@ +package mhsmprivatelinkresources + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByMHSMResourceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MHSMPrivateLinkResourceListResult +} + +// ListByMHSMResource ... +func (c MHSMPrivateLinkResourcesClient) ListByMHSMResource(ctx context.Context, id ManagedHSMId) (result ListByMHSMResourceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateLinkResources", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/keyvault/2023-07-01/mhsmprivatelinkresources/method_listbymhsmresource_autorest.go b/resource-manager/keyvault/2023-07-01/mhsmprivatelinkresources/method_listbymhsmresource_autorest.go deleted file mode 100644 index 039d077edfe..00000000000 --- a/resource-manager/keyvault/2023-07-01/mhsmprivatelinkresources/method_listbymhsmresource_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package mhsmprivatelinkresources - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByMHSMResourceOperationResponse struct { - HttpResponse *http.Response - Model *MHSMPrivateLinkResourceListResult -} - -// ListByMHSMResource ... -func (c MHSMPrivateLinkResourcesClient) ListByMHSMResource(ctx context.Context, id ManagedHSMId) (result ListByMHSMResourceOperationResponse, err error) { - req, err := c.preparerForListByMHSMResource(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmprivatelinkresources.MHSMPrivateLinkResourcesClient", "ListByMHSMResource", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmprivatelinkresources.MHSMPrivateLinkResourcesClient", "ListByMHSMResource", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByMHSMResource(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "mhsmprivatelinkresources.MHSMPrivateLinkResourcesClient", "ListByMHSMResource", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByMHSMResource prepares the ListByMHSMResource request. -func (c MHSMPrivateLinkResourcesClient) preparerForListByMHSMResource(ctx context.Context, id ManagedHSMId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/privateLinkResources", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByMHSMResource handles the response to the ListByMHSMResource request. The method always -// closes the http.Response Body. -func (c MHSMPrivateLinkResourcesClient) responderForListByMHSMResource(resp *http.Response) (result ListByMHSMResourceOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2023-07-01/privateendpointconnections/client.go b/resource-manager/keyvault/2023-07-01/privateendpointconnections/client.go index 1de584406fe..3bf7a6afe1f 100644 --- a/resource-manager/keyvault/2023-07-01/privateendpointconnections/client.go +++ b/resource-manager/keyvault/2023-07-01/privateendpointconnections/client.go @@ -1,18 +1,26 @@ package privateendpointconnections -import "github.com/Azure/go-autorest/autorest" +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 PrivateEndpointConnectionsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewPrivateEndpointConnectionsClientWithBaseURI(endpoint string) PrivateEndpointConnectionsClient { - return PrivateEndpointConnectionsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewPrivateEndpointConnectionsClientWithBaseURI(sdkApi sdkEnv.Api) (*PrivateEndpointConnectionsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "privateendpointconnections", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PrivateEndpointConnectionsClient: %+v", err) } + + return &PrivateEndpointConnectionsClient{ + Client: client, + }, nil } diff --git a/resource-manager/keyvault/2023-07-01/privateendpointconnections/constants.go b/resource-manager/keyvault/2023-07-01/privateendpointconnections/constants.go index 127a9d9aafd..fdeb29178f4 100644 --- a/resource-manager/keyvault/2023-07-01/privateendpointconnections/constants.go +++ b/resource-manager/keyvault/2023-07-01/privateendpointconnections/constants.go @@ -1,6 +1,10 @@ package privateendpointconnections -import "strings" +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. @@ -17,6 +21,19 @@ func PossibleValuesForActionsRequired() []string { } } +func (s *ActionsRequired) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseActionsRequired(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseActionsRequired(input string) (*ActionsRequired, error) { vals := map[string]ActionsRequired{ "none": ActionsRequiredNone, @@ -52,6 +69,19 @@ func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { } } +func (s *PrivateEndpointConnectionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointConnectionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { vals := map[string]PrivateEndpointConnectionProvisioningState{ "creating": PrivateEndpointConnectionProvisioningStateCreating, @@ -88,6 +118,19 @@ func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { } } +func (s *PrivateEndpointServiceConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointServiceConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { vals := map[string]PrivateEndpointServiceConnectionStatus{ "approved": PrivateEndpointServiceConnectionStatusApproved, diff --git a/resource-manager/keyvault/2023-07-01/privateendpointconnections/method_delete.go b/resource-manager/keyvault/2023-07-01/privateendpointconnections/method_delete.go new file mode 100644 index 00000000000..6014fe7deaf --- /dev/null +++ b/resource-manager/keyvault/2023-07-01/privateendpointconnections/method_delete.go @@ -0,0 +1,77 @@ +package privateendpointconnections + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnection +} + +// Delete ... +func (c PrivateEndpointConnectionsClient) Delete(ctx context.Context, id commonids.KeyVaultPrivateEndpointConnectionId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c PrivateEndpointConnectionsClient) DeleteThenPoll(ctx context.Context, id commonids.KeyVaultPrivateEndpointConnectionId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/keyvault/2023-07-01/privateendpointconnections/method_delete_autorest.go b/resource-manager/keyvault/2023-07-01/privateendpointconnections/method_delete_autorest.go deleted file mode 100644 index 4703a8f08ad..00000000000 --- a/resource-manager/keyvault/2023-07-01/privateendpointconnections/method_delete_autorest.go +++ /dev/null @@ -1,80 +0,0 @@ -package privateendpointconnections - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response - Model *PrivateEndpointConnection -} - -// Delete ... -func (c PrivateEndpointConnectionsClient) Delete(ctx context.Context, id commonids.KeyVaultPrivateEndpointConnectionId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c PrivateEndpointConnectionsClient) DeleteThenPoll(ctx context.Context, id commonids.KeyVaultPrivateEndpointConnectionId) error { - result, err := c.Delete(ctx, id) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} - -// preparerForDelete prepares the Delete request. -func (c PrivateEndpointConnectionsClient) preparerForDelete(ctx context.Context, id commonids.KeyVaultPrivateEndpointConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDelete sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (c PrivateEndpointConnectionsClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/keyvault/2023-07-01/privateendpointconnections/method_get.go b/resource-manager/keyvault/2023-07-01/privateendpointconnections/method_get.go new file mode 100644 index 00000000000..3760955fc98 --- /dev/null +++ b/resource-manager/keyvault/2023-07-01/privateendpointconnections/method_get.go @@ -0,0 +1,53 @@ +package privateendpointconnections + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnection +} + +// Get ... +func (c PrivateEndpointConnectionsClient) Get(ctx context.Context, id commonids.KeyVaultPrivateEndpointConnectionId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + 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 + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/keyvault/2023-07-01/privateendpointconnections/method_get_autorest.go b/resource-manager/keyvault/2023-07-01/privateendpointconnections/method_get_autorest.go deleted file mode 100644 index 6c5953b7a4e..00000000000 --- a/resource-manager/keyvault/2023-07-01/privateendpointconnections/method_get_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package privateendpointconnections - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *PrivateEndpointConnection -} - -// Get ... -func (c PrivateEndpointConnectionsClient) Get(ctx context.Context, id commonids.KeyVaultPrivateEndpointConnectionId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c PrivateEndpointConnectionsClient) preparerForGet(ctx context.Context, id commonids.KeyVaultPrivateEndpointConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c PrivateEndpointConnectionsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2023-07-01/privateendpointconnections/method_listbyresource.go b/resource-manager/keyvault/2023-07-01/privateendpointconnections/method_listbyresource.go new file mode 100644 index 00000000000..1509fe3c5d8 --- /dev/null +++ b/resource-manager/keyvault/2023-07-01/privateendpointconnections/method_listbyresource.go @@ -0,0 +1,92 @@ +package privateendpointconnections + +import ( + "context" + "fmt" + "net/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 ListByResourceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PrivateEndpointConnection +} + +type ListByResourceCompleteResult struct { + LatestHttpResponse *http.Response + Items []PrivateEndpointConnection +} + +// ListByResource ... +func (c PrivateEndpointConnectionsClient) ListByResource(ctx context.Context, id commonids.KeyVaultId) (result ListByResourceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateEndpointConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PrivateEndpointConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceComplete retrieves all the results into a single object +func (c PrivateEndpointConnectionsClient) ListByResourceComplete(ctx context.Context, id commonids.KeyVaultId) (ListByResourceCompleteResult, error) { + return c.ListByResourceCompleteMatchingPredicate(ctx, id, PrivateEndpointConnectionOperationPredicate{}) +} + +// ListByResourceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PrivateEndpointConnectionsClient) ListByResourceCompleteMatchingPredicate(ctx context.Context, id commonids.KeyVaultId, predicate PrivateEndpointConnectionOperationPredicate) (result ListByResourceCompleteResult, err error) { + items := make([]PrivateEndpointConnection, 0) + + resp, err := c.ListByResource(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/keyvault/2023-07-01/privateendpointconnections/method_listbyresource_autorest.go b/resource-manager/keyvault/2023-07-01/privateendpointconnections/method_listbyresource_autorest.go deleted file mode 100644 index 04d7c90769d..00000000000 --- a/resource-manager/keyvault/2023-07-01/privateendpointconnections/method_listbyresource_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package privateendpointconnections - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByResourceOperationResponse struct { - HttpResponse *http.Response - Model *[]PrivateEndpointConnection - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByResourceOperationResponse, error) -} - -type ListByResourceCompleteResult struct { - Items []PrivateEndpointConnection -} - -func (r ListByResourceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByResourceOperationResponse) LoadMore(ctx context.Context) (resp ListByResourceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByResource ... -func (c PrivateEndpointConnectionsClient) ListByResource(ctx context.Context, id commonids.KeyVaultId) (resp ListByResourceOperationResponse, err error) { - req, err := c.preparerForListByResource(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "ListByResource", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "ListByResource", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByResource(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "ListByResource", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByResource prepares the ListByResource request. -func (c PrivateEndpointConnectionsClient) preparerForListByResource(ctx context.Context, id commonids.KeyVaultId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/privateEndpointConnections", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByResourceWithNextLink prepares the ListByResource request with the given nextLink token. -func (c PrivateEndpointConnectionsClient) preparerForListByResourceWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByResource handles the response to the ListByResource request. The method always -// closes the http.Response Body. -func (c PrivateEndpointConnectionsClient) responderForListByResource(resp *http.Response) (result ListByResourceOperationResponse, err error) { - type page struct { - Values []PrivateEndpointConnection `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByResourceOperationResponse, err error) { - req, err := c.preparerForListByResourceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "ListByResource", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "ListByResource", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByResource(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "ListByResource", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByResourceComplete retrieves all of the results into a single object -func (c PrivateEndpointConnectionsClient) ListByResourceComplete(ctx context.Context, id commonids.KeyVaultId) (ListByResourceCompleteResult, error) { - return c.ListByResourceCompleteMatchingPredicate(ctx, id, PrivateEndpointConnectionOperationPredicate{}) -} - -// ListByResourceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c PrivateEndpointConnectionsClient) ListByResourceCompleteMatchingPredicate(ctx context.Context, id commonids.KeyVaultId, predicate PrivateEndpointConnectionOperationPredicate) (resp ListByResourceCompleteResult, err error) { - items := make([]PrivateEndpointConnection, 0) - - page, err := c.ListByResource(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByResourceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/keyvault/2023-07-01/privateendpointconnections/method_put.go b/resource-manager/keyvault/2023-07-01/privateendpointconnections/method_put.go new file mode 100644 index 00000000000..b8cc8217b77 --- /dev/null +++ b/resource-manager/keyvault/2023-07-01/privateendpointconnections/method_put.go @@ -0,0 +1,56 @@ +package privateendpointconnections + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PutOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnection +} + +// Put ... +func (c PrivateEndpointConnectionsClient) Put(ctx context.Context, id commonids.KeyVaultPrivateEndpointConnectionId, input PrivateEndpointConnection) (result PutOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/keyvault/2023-07-01/privateendpointconnections/method_put_autorest.go b/resource-manager/keyvault/2023-07-01/privateendpointconnections/method_put_autorest.go deleted file mode 100644 index 20a86574f4c..00000000000 --- a/resource-manager/keyvault/2023-07-01/privateendpointconnections/method_put_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package privateendpointconnections - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PutOperationResponse struct { - HttpResponse *http.Response - Model *PrivateEndpointConnection -} - -// Put ... -func (c PrivateEndpointConnectionsClient) Put(ctx context.Context, id commonids.KeyVaultPrivateEndpointConnectionId, input PrivateEndpointConnection) (result PutOperationResponse, err error) { - req, err := c.preparerForPut(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Put", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Put", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForPut(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Put", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForPut prepares the Put request. -func (c PrivateEndpointConnectionsClient) preparerForPut(ctx context.Context, id commonids.KeyVaultPrivateEndpointConnectionId, input PrivateEndpointConnection) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForPut handles the response to the Put request. The method always -// closes the http.Response Body. -func (c PrivateEndpointConnectionsClient) responderForPut(resp *http.Response) (result PutOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2023-07-01/privatelinkresources/client.go b/resource-manager/keyvault/2023-07-01/privatelinkresources/client.go index 5f532940700..e6e22caa746 100644 --- a/resource-manager/keyvault/2023-07-01/privatelinkresources/client.go +++ b/resource-manager/keyvault/2023-07-01/privatelinkresources/client.go @@ -1,18 +1,26 @@ package privatelinkresources -import "github.com/Azure/go-autorest/autorest" +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 PrivateLinkResourcesClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewPrivateLinkResourcesClientWithBaseURI(endpoint string) PrivateLinkResourcesClient { - return PrivateLinkResourcesClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewPrivateLinkResourcesClientWithBaseURI(sdkApi sdkEnv.Api) (*PrivateLinkResourcesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "privatelinkresources", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PrivateLinkResourcesClient: %+v", err) } + + return &PrivateLinkResourcesClient{ + Client: client, + }, nil } diff --git a/resource-manager/keyvault/2023-07-01/privatelinkresources/method_listbyvault.go b/resource-manager/keyvault/2023-07-01/privatelinkresources/method_listbyvault.go new file mode 100644 index 00000000000..ea47bc1bd77 --- /dev/null +++ b/resource-manager/keyvault/2023-07-01/privatelinkresources/method_listbyvault.go @@ -0,0 +1,53 @@ +package privatelinkresources + +import ( + "context" + "fmt" + "net/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 ListByVaultOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateLinkResourceListResult +} + +// ListByVault ... +func (c PrivateLinkResourcesClient) ListByVault(ctx context.Context, id commonids.KeyVaultId) (result ListByVaultOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateLinkResources", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/keyvault/2023-07-01/privatelinkresources/method_listbyvault_autorest.go b/resource-manager/keyvault/2023-07-01/privatelinkresources/method_listbyvault_autorest.go deleted file mode 100644 index ec68e666d4b..00000000000 --- a/resource-manager/keyvault/2023-07-01/privatelinkresources/method_listbyvault_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package privatelinkresources - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByVaultOperationResponse struct { - HttpResponse *http.Response - Model *PrivateLinkResourceListResult -} - -// ListByVault ... -func (c PrivateLinkResourcesClient) ListByVault(ctx context.Context, id commonids.KeyVaultId) (result ListByVaultOperationResponse, err error) { - req, err := c.preparerForListByVault(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "ListByVault", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "ListByVault", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByVault(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "ListByVault", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByVault prepares the ListByVault request. -func (c PrivateLinkResourcesClient) preparerForListByVault(ctx context.Context, id commonids.KeyVaultId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/privateLinkResources", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByVault handles the response to the ListByVault request. The method always -// closes the http.Response Body. -func (c PrivateLinkResourcesClient) responderForListByVault(resp *http.Response) (result ListByVaultOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2023-07-01/secrets/client.go b/resource-manager/keyvault/2023-07-01/secrets/client.go index ab0463026ab..c8a49ae1e6b 100644 --- a/resource-manager/keyvault/2023-07-01/secrets/client.go +++ b/resource-manager/keyvault/2023-07-01/secrets/client.go @@ -1,18 +1,26 @@ package secrets -import "github.com/Azure/go-autorest/autorest" +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 SecretsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewSecretsClientWithBaseURI(endpoint string) SecretsClient { - return SecretsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewSecretsClientWithBaseURI(sdkApi sdkEnv.Api) (*SecretsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "secrets", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SecretsClient: %+v", err) } + + return &SecretsClient{ + Client: client, + }, nil } diff --git a/resource-manager/keyvault/2023-07-01/secrets/method_createorupdate.go b/resource-manager/keyvault/2023-07-01/secrets/method_createorupdate.go new file mode 100644 index 00000000000..5d6bf2f3a01 --- /dev/null +++ b/resource-manager/keyvault/2023-07-01/secrets/method_createorupdate.go @@ -0,0 +1,56 @@ +package secrets + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *Secret +} + +// CreateOrUpdate ... +func (c SecretsClient) CreateOrUpdate(ctx context.Context, id SecretId, input SecretCreateOrUpdateParameters) (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 + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/keyvault/2023-07-01/secrets/method_createorupdate_autorest.go b/resource-manager/keyvault/2023-07-01/secrets/method_createorupdate_autorest.go deleted file mode 100644 index dd60760906f..00000000000 --- a/resource-manager/keyvault/2023-07-01/secrets/method_createorupdate_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package secrets - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateOperationResponse struct { - HttpResponse *http.Response - Model *Secret -} - -// CreateOrUpdate ... -func (c SecretsClient) CreateOrUpdate(ctx context.Context, id SecretId, input SecretCreateOrUpdateParameters) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "secrets.SecretsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "secrets.SecretsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "secrets.SecretsClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c SecretsClient) preparerForCreateOrUpdate(ctx context.Context, id SecretId, input SecretCreateOrUpdateParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdate handles the response to the CreateOrUpdate request. The method always -// closes the http.Response Body. -func (c SecretsClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2023-07-01/secrets/method_get.go b/resource-manager/keyvault/2023-07-01/secrets/method_get.go new file mode 100644 index 00000000000..1f77d7d5228 --- /dev/null +++ b/resource-manager/keyvault/2023-07-01/secrets/method_get.go @@ -0,0 +1,51 @@ +package secrets + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *Secret +} + +// Get ... +func (c SecretsClient) Get(ctx context.Context, id SecretId) (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 + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/keyvault/2023-07-01/secrets/method_get_autorest.go b/resource-manager/keyvault/2023-07-01/secrets/method_get_autorest.go deleted file mode 100644 index 3f83dfd6db7..00000000000 --- a/resource-manager/keyvault/2023-07-01/secrets/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package secrets - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *Secret -} - -// Get ... -func (c SecretsClient) Get(ctx context.Context, id SecretId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "secrets.SecretsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "secrets.SecretsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "secrets.SecretsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c SecretsClient) preparerForGet(ctx context.Context, id SecretId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c SecretsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2023-07-01/secrets/method_list.go b/resource-manager/keyvault/2023-07-01/secrets/method_list.go new file mode 100644 index 00000000000..2d18aa68bd7 --- /dev/null +++ b/resource-manager/keyvault/2023-07-01/secrets/method_list.go @@ -0,0 +1,120 @@ +package secrets + +import ( + "context" + "fmt" + "net/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 *[]Secret +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Secret +} + +type ListOperationOptions struct { + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// List ... +func (c SecretsClient) List(ctx context.Context, id commonids.KeyVaultId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/secrets", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Secret `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 SecretsClient) ListComplete(ctx context.Context, id commonids.KeyVaultId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, SecretOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SecretsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.KeyVaultId, options ListOperationOptions, predicate SecretOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Secret, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/keyvault/2023-07-01/secrets/method_list_autorest.go b/resource-manager/keyvault/2023-07-01/secrets/method_list_autorest.go deleted file mode 100644 index e00c01e9111..00000000000 --- a/resource-manager/keyvault/2023-07-01/secrets/method_list_autorest.go +++ /dev/null @@ -1,216 +0,0 @@ -package secrets - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *[]Secret - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []Secret -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListOperationOptions struct { - Top *int64 -} - -func DefaultListOperationOptions() ListOperationOptions { - return ListOperationOptions{} -} - -func (o ListOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// List ... -func (c SecretsClient) List(ctx context.Context, id commonids.KeyVaultId, options ListOperationOptions) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "secrets.SecretsClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "secrets.SecretsClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "secrets.SecretsClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c SecretsClient) preparerForList(ctx context.Context, id commonids.KeyVaultId, options ListOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/secrets", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c SecretsClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c SecretsClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []Secret `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { - req, err := c.preparerForListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "secrets.SecretsClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "secrets.SecretsClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "secrets.SecretsClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c SecretsClient) ListComplete(ctx context.Context, id commonids.KeyVaultId, options ListOperationOptions) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, options, SecretOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c SecretsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.KeyVaultId, options ListOperationOptions, predicate SecretOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]Secret, 0) - - page, err := c.List(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/keyvault/2023-07-01/secrets/method_update.go b/resource-manager/keyvault/2023-07-01/secrets/method_update.go new file mode 100644 index 00000000000..8bd931a32b9 --- /dev/null +++ b/resource-manager/keyvault/2023-07-01/secrets/method_update.go @@ -0,0 +1,56 @@ +package secrets + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *Secret +} + +// Update ... +func (c SecretsClient) Update(ctx context.Context, id SecretId, input SecretPatchParameters) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/keyvault/2023-07-01/secrets/method_update_autorest.go b/resource-manager/keyvault/2023-07-01/secrets/method_update_autorest.go deleted file mode 100644 index 8d1da9199de..00000000000 --- a/resource-manager/keyvault/2023-07-01/secrets/method_update_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package secrets - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateOperationResponse struct { - HttpResponse *http.Response - Model *Secret -} - -// Update ... -func (c SecretsClient) Update(ctx context.Context, id SecretId, input SecretPatchParameters) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "secrets.SecretsClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "secrets.SecretsClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "secrets.SecretsClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c SecretsClient) preparerForUpdate(ctx context.Context, id SecretId, input SecretPatchParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdate handles the response to the Update request. The method always -// closes the http.Response Body. -func (c SecretsClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2023-07-01/vaults/client.go b/resource-manager/keyvault/2023-07-01/vaults/client.go index 6cad2ef703e..1ddc5db936e 100644 --- a/resource-manager/keyvault/2023-07-01/vaults/client.go +++ b/resource-manager/keyvault/2023-07-01/vaults/client.go @@ -1,18 +1,26 @@ package vaults -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type VaultsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewVaultsClientWithBaseURI(endpoint string) VaultsClient { - return VaultsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewVaultsClientWithBaseURI(sdkApi sdkEnv.Api) (*VaultsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "vaults", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating VaultsClient: %+v", err) } + + return &VaultsClient{ + Client: client, + }, nil } diff --git a/resource-manager/keyvault/2023-07-01/vaults/constants.go b/resource-manager/keyvault/2023-07-01/vaults/constants.go index a9f3fd33ac5..a6d848aef64 100644 --- a/resource-manager/keyvault/2023-07-01/vaults/constants.go +++ b/resource-manager/keyvault/2023-07-01/vaults/constants.go @@ -1,6 +1,10 @@ package vaults -import "strings" +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. @@ -21,6 +25,19 @@ func PossibleValuesForAccessPolicyUpdateKind() []string { } } +func (s *AccessPolicyUpdateKind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAccessPolicyUpdateKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAccessPolicyUpdateKind(input string) (*AccessPolicyUpdateKind, error) { vals := map[string]AccessPolicyUpdateKind{ "add": AccessPolicyUpdateKindAdd, @@ -48,6 +65,19 @@ func PossibleValuesForActionsRequired() []string { } } +func (s *ActionsRequired) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseActionsRequired(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseActionsRequired(input string) (*ActionsRequired, error) { vals := map[string]ActionsRequired{ "none": ActionsRequiredNone, @@ -105,6 +135,19 @@ func PossibleValuesForCertificatePermissions() []string { } } +func (s *CertificatePermissions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCertificatePermissions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseCertificatePermissions(input string) (*CertificatePermissions, error) { vals := map[string]CertificatePermissions{ "all": CertificatePermissionsAll, @@ -148,6 +191,19 @@ func PossibleValuesForCreateMode() []string { } } +func (s *CreateMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCreateMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseCreateMode(input string) (*CreateMode, error) { vals := map[string]CreateMode{ "default": CreateModeDefault, @@ -214,6 +270,19 @@ func PossibleValuesForKeyPermissions() []string { } } +func (s *KeyPermissions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKeyPermissions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseKeyPermissions(input string) (*KeyPermissions, error) { vals := map[string]KeyPermissions{ "all": KeyPermissionsAll, @@ -261,6 +330,19 @@ func PossibleValuesForNetworkRuleAction() []string { } } +func (s *NetworkRuleAction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkRuleAction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseNetworkRuleAction(input string) (*NetworkRuleAction, error) { vals := map[string]NetworkRuleAction{ "allow": NetworkRuleActionAllow, @@ -289,6 +371,19 @@ func PossibleValuesForNetworkRuleBypassOptions() []string { } } +func (s *NetworkRuleBypassOptions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkRuleBypassOptions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseNetworkRuleBypassOptions(input string) (*NetworkRuleBypassOptions, error) { vals := map[string]NetworkRuleBypassOptions{ "azureservices": NetworkRuleBypassOptionsAzureServices, @@ -325,6 +420,19 @@ func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { } } +func (s *PrivateEndpointConnectionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointConnectionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { vals := map[string]PrivateEndpointConnectionProvisioningState{ "creating": PrivateEndpointConnectionProvisioningStateCreating, @@ -361,6 +469,19 @@ func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { } } +func (s *PrivateEndpointServiceConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointServiceConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { vals := map[string]PrivateEndpointServiceConnectionStatus{ "approved": PrivateEndpointServiceConnectionStatusApproved, @@ -391,6 +512,19 @@ func PossibleValuesForReason() []string { } } +func (s *Reason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseReason(input string) (*Reason, error) { vals := map[string]Reason{ "accountnameinvalid": ReasonAccountNameInvalid, @@ -433,6 +567,19 @@ func PossibleValuesForSecretPermissions() []string { } } +func (s *SecretPermissions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecretPermissions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSecretPermissions(input string) (*SecretPermissions, error) { vals := map[string]SecretPermissions{ "all": SecretPermissionsAll, @@ -466,6 +613,19 @@ func PossibleValuesForSkuFamily() []string { } } +func (s *SkuFamily) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuFamily(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSkuFamily(input string) (*SkuFamily, error) { vals := map[string]SkuFamily{ "a": SkuFamilyA, @@ -493,6 +653,19 @@ func PossibleValuesForSkuName() []string { } } +func (s *SkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSkuName(input string) (*SkuName, error) { vals := map[string]SkuName{ "premium": SkuNamePremium, @@ -547,6 +720,19 @@ func PossibleValuesForStoragePermissions() []string { } } +func (s *StoragePermissions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStoragePermissions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseStoragePermissions(input string) (*StoragePermissions, error) { vals := map[string]StoragePermissions{ "all": StoragePermissionsAll, @@ -586,6 +772,19 @@ func PossibleValuesForType() []string { } } +func (s *Type) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseType(input string) (*Type, error) { vals := map[string]Type{ "microsoft.keyvault/vaults": TypeMicrosoftPointKeyVaultVaults, @@ -611,6 +810,19 @@ func PossibleValuesForVaultListFilterTypes() []string { } } +func (s *VaultListFilterTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVaultListFilterTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseVaultListFilterTypes(input string) (*VaultListFilterTypes, error) { vals := map[string]VaultListFilterTypes{ "resourcetype eq 'microsoft.keyvault/vaults'": VaultListFilterTypesResourceTypeEqMicrosoftPointKeyVaultVaults, @@ -638,6 +850,19 @@ func PossibleValuesForVaultProvisioningState() []string { } } +func (s *VaultProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVaultProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseVaultProvisioningState(input string) (*VaultProvisioningState, error) { vals := map[string]VaultProvisioningState{ "registeringdns": VaultProvisioningStateRegisteringDns, diff --git a/resource-manager/keyvault/2023-07-01/vaults/method_checknameavailability.go b/resource-manager/keyvault/2023-07-01/vaults/method_checknameavailability.go new file mode 100644 index 00000000000..3722ee1be0e --- /dev/null +++ b/resource-manager/keyvault/2023-07-01/vaults/method_checknameavailability.go @@ -0,0 +1,57 @@ +package vaults + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CheckNameAvailabilityResult +} + +// CheckNameAvailability ... +func (c VaultsClient) CheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input VaultCheckNameAvailabilityParameters) (result CheckNameAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.KeyVault/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 + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/keyvault/2023-07-01/vaults/method_checknameavailability_autorest.go b/resource-manager/keyvault/2023-07-01/vaults/method_checknameavailability_autorest.go deleted file mode 100644 index b6a428f979b..00000000000 --- a/resource-manager/keyvault/2023-07-01/vaults/method_checknameavailability_autorest.go +++ /dev/null @@ -1,71 +0,0 @@ -package vaults - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CheckNameAvailabilityOperationResponse struct { - HttpResponse *http.Response - Model *CheckNameAvailabilityResult -} - -// CheckNameAvailability ... -func (c VaultsClient) CheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input VaultCheckNameAvailabilityParameters) (result CheckNameAvailabilityOperationResponse, err error) { - req, err := c.preparerForCheckNameAvailability(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "CheckNameAvailability", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "CheckNameAvailability", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCheckNameAvailability(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "CheckNameAvailability", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCheckNameAvailability prepares the CheckNameAvailability request. -func (c VaultsClient) preparerForCheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input VaultCheckNameAvailabilityParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.KeyVault/checkNameAvailability", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCheckNameAvailability handles the response to the CheckNameAvailability request. The method always -// closes the http.Response Body. -func (c VaultsClient) responderForCheckNameAvailability(resp *http.Response) (result CheckNameAvailabilityOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2023-07-01/vaults/method_createorupdate.go b/resource-manager/keyvault/2023-07-01/vaults/method_createorupdate.go new file mode 100644 index 00000000000..0a632c2b0aa --- /dev/null +++ b/resource-manager/keyvault/2023-07-01/vaults/method_createorupdate.go @@ -0,0 +1,80 @@ +package vaults + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Vault +} + +// CreateOrUpdate ... +func (c VaultsClient) CreateOrUpdate(ctx context.Context, id commonids.KeyVaultId, input VaultCreateOrUpdateParameters) (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 + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c VaultsClient) CreateOrUpdateThenPoll(ctx context.Context, id commonids.KeyVaultId, input VaultCreateOrUpdateParameters) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/keyvault/2023-07-01/vaults/method_createorupdate_autorest.go b/resource-manager/keyvault/2023-07-01/vaults/method_createorupdate_autorest.go deleted file mode 100644 index b80f3097c1d..00000000000 --- a/resource-manager/keyvault/2023-07-01/vaults/method_createorupdate_autorest.go +++ /dev/null @@ -1,81 +0,0 @@ -package vaults - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response - Model *Vault -} - -// CreateOrUpdate ... -func (c VaultsClient) CreateOrUpdate(ctx context.Context, id commonids.KeyVaultId, input VaultCreateOrUpdateParameters) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c VaultsClient) CreateOrUpdateThenPoll(ctx context.Context, id commonids.KeyVaultId, input VaultCreateOrUpdateParameters) error { - result, err := c.CreateOrUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c VaultsClient) preparerForCreateOrUpdate(ctx context.Context, id commonids.KeyVaultId, input VaultCreateOrUpdateParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c VaultsClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/keyvault/2023-07-01/vaults/method_delete.go b/resource-manager/keyvault/2023-07-01/vaults/method_delete.go new file mode 100644 index 00000000000..8875d26814e --- /dev/null +++ b/resource-manager/keyvault/2023-07-01/vaults/method_delete.go @@ -0,0 +1,48 @@ +package vaults + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c VaultsClient) Delete(ctx context.Context, id commonids.KeyVaultId) (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/keyvault/2023-07-01/vaults/method_delete_autorest.go b/resource-manager/keyvault/2023-07-01/vaults/method_delete_autorest.go deleted file mode 100644 index 5eabac1a3f0..00000000000 --- a/resource-manager/keyvault/2023-07-01/vaults/method_delete_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package vaults - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteOperationResponse struct { - HttpResponse *http.Response -} - -// Delete ... -func (c VaultsClient) Delete(ctx context.Context, id commonids.KeyVaultId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c VaultsClient) preparerForDelete(ctx context.Context, id commonids.KeyVaultId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c VaultsClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2023-07-01/vaults/method_get.go b/resource-manager/keyvault/2023-07-01/vaults/method_get.go new file mode 100644 index 00000000000..2dce9c46f1d --- /dev/null +++ b/resource-manager/keyvault/2023-07-01/vaults/method_get.go @@ -0,0 +1,52 @@ +package vaults + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Vault +} + +// Get ... +func (c VaultsClient) Get(ctx context.Context, id commonids.KeyVaultId) (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 + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/keyvault/2023-07-01/vaults/method_get_autorest.go b/resource-manager/keyvault/2023-07-01/vaults/method_get_autorest.go deleted file mode 100644 index 986510ec6d7..00000000000 --- a/resource-manager/keyvault/2023-07-01/vaults/method_get_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package vaults - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *Vault -} - -// Get ... -func (c VaultsClient) Get(ctx context.Context, id commonids.KeyVaultId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c VaultsClient) preparerForGet(ctx context.Context, id commonids.KeyVaultId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c VaultsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2023-07-01/vaults/method_getdeleted.go b/resource-manager/keyvault/2023-07-01/vaults/method_getdeleted.go new file mode 100644 index 00000000000..52346209891 --- /dev/null +++ b/resource-manager/keyvault/2023-07-01/vaults/method_getdeleted.go @@ -0,0 +1,51 @@ +package vaults + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetDeletedOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DeletedVault +} + +// GetDeleted ... +func (c VaultsClient) GetDeleted(ctx context.Context, id DeletedVaultId) (result GetDeletedOperationResponse, 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 + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/keyvault/2023-07-01/vaults/method_getdeleted_autorest.go b/resource-manager/keyvault/2023-07-01/vaults/method_getdeleted_autorest.go deleted file mode 100644 index b60a7041ea1..00000000000 --- a/resource-manager/keyvault/2023-07-01/vaults/method_getdeleted_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package vaults - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetDeletedOperationResponse struct { - HttpResponse *http.Response - Model *DeletedVault -} - -// GetDeleted ... -func (c VaultsClient) GetDeleted(ctx context.Context, id DeletedVaultId) (result GetDeletedOperationResponse, err error) { - req, err := c.preparerForGetDeleted(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "GetDeleted", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "GetDeleted", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetDeleted(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "GetDeleted", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetDeleted prepares the GetDeleted request. -func (c VaultsClient) preparerForGetDeleted(ctx context.Context, id DeletedVaultId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetDeleted handles the response to the GetDeleted request. The method always -// closes the http.Response Body. -func (c VaultsClient) responderForGetDeleted(resp *http.Response) (result GetDeletedOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2023-07-01/vaults/method_list.go b/resource-manager/keyvault/2023-07-01/vaults/method_list.go new file mode 100644 index 00000000000..a2db91dc5c9 --- /dev/null +++ b/resource-manager/keyvault/2023-07-01/vaults/method_list.go @@ -0,0 +1,124 @@ +package vaults + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Resource +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Resource +} + +type ListOperationOptions struct { + Filter *VaultListFilterTypes + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// List ... +func (c VaultsClient) List(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/resources", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Resource `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 VaultsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, ResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VaultsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions, predicate ResourceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Resource, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/keyvault/2023-07-01/vaults/method_list_autorest.go b/resource-manager/keyvault/2023-07-01/vaults/method_list_autorest.go deleted file mode 100644 index 58b77e07a16..00000000000 --- a/resource-manager/keyvault/2023-07-01/vaults/method_list_autorest.go +++ /dev/null @@ -1,221 +0,0 @@ -package vaults - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *[]Resource - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []Resource -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListOperationOptions struct { - Filter *VaultListFilterTypes - Top *int64 -} - -func DefaultListOperationOptions() ListOperationOptions { - return ListOperationOptions{} -} - -func (o ListOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// List ... -func (c VaultsClient) List(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c VaultsClient) preparerForList(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/resources", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c VaultsClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c VaultsClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []Resource `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { - req, err := c.preparerForListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c VaultsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, options, ResourceOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c VaultsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions, predicate ResourceOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]Resource, 0) - - page, err := c.List(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/keyvault/2023-07-01/vaults/method_listbyresourcegroup.go b/resource-manager/keyvault/2023-07-01/vaults/method_listbyresourcegroup.go new file mode 100644 index 00000000000..342da5a0bac --- /dev/null +++ b/resource-manager/keyvault/2023-07-01/vaults/method_listbyresourcegroup.go @@ -0,0 +1,120 @@ +package vaults + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Vault +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []Vault +} + +type ListByResourceGroupOperationOptions struct { + Top *int64 +} + +func DefaultListByResourceGroupOperationOptions() ListByResourceGroupOperationOptions { + return ListByResourceGroupOperationOptions{} +} + +func (o ListByResourceGroupOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByResourceGroupOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByResourceGroupOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByResourceGroup ... +func (c VaultsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.KeyVault/vaults", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Vault `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c VaultsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, options, VaultOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VaultsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions, predicate VaultOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]Vault, 0) + + resp, err := c.ListByResourceGroup(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/keyvault/2023-07-01/vaults/method_listbyresourcegroup_autorest.go b/resource-manager/keyvault/2023-07-01/vaults/method_listbyresourcegroup_autorest.go deleted file mode 100644 index c7f2a4088e7..00000000000 --- a/resource-manager/keyvault/2023-07-01/vaults/method_listbyresourcegroup_autorest.go +++ /dev/null @@ -1,216 +0,0 @@ -package vaults - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// 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 - Model *[]Vault - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByResourceGroupOperationResponse, error) -} - -type ListByResourceGroupCompleteResult struct { - Items []Vault -} - -func (r ListByResourceGroupOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByResourceGroupOperationResponse) LoadMore(ctx context.Context) (resp ListByResourceGroupOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByResourceGroupOperationOptions struct { - Top *int64 -} - -func DefaultListByResourceGroupOperationOptions() ListByResourceGroupOperationOptions { - return ListByResourceGroupOperationOptions{} -} - -func (o ListByResourceGroupOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByResourceGroupOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByResourceGroup ... -func (c VaultsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (resp ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroup(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListByResourceGroup", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByResourceGroup(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListByResourceGroup", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByResourceGroup prepares the ListByResourceGroup request. -func (c VaultsClient) preparerForListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.KeyVault/vaults", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByResourceGroupWithNextLink prepares the ListByResourceGroup request with the given nextLink token. -func (c VaultsClient) preparerForListByResourceGroupWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByResourceGroup handles the response to the ListByResourceGroup request. The method always -// closes the http.Response Body. -func (c VaultsClient) responderForListByResourceGroup(resp *http.Response) (result ListByResourceGroupOperationResponse, err error) { - type page struct { - Values []Vault `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroupWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListByResourceGroup", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByResourceGroup(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListByResourceGroup", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByResourceGroupComplete retrieves all of the results into a single object -func (c VaultsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (ListByResourceGroupCompleteResult, error) { - return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, options, VaultOperationPredicate{}) -} - -// ListByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c VaultsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions, predicate VaultOperationPredicate) (resp ListByResourceGroupCompleteResult, err error) { - items := make([]Vault, 0) - - page, err := c.ListByResourceGroup(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByResourceGroupCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/keyvault/2023-07-01/vaults/method_listbysubscription.go b/resource-manager/keyvault/2023-07-01/vaults/method_listbysubscription.go new file mode 100644 index 00000000000..1a9d39bdf07 --- /dev/null +++ b/resource-manager/keyvault/2023-07-01/vaults/method_listbysubscription.go @@ -0,0 +1,120 @@ +package vaults + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Vault +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []Vault +} + +type ListBySubscriptionOperationOptions struct { + Top *int64 +} + +func DefaultListBySubscriptionOperationOptions() ListBySubscriptionOperationOptions { + return ListBySubscriptionOperationOptions{} +} + +func (o ListBySubscriptionOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListBySubscriptionOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListBySubscriptionOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListBySubscription ... +func (c VaultsClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.KeyVault/vaults", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Vault `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 VaultsClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, options, VaultOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VaultsClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions, predicate VaultOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]Vault, 0) + + resp, err := c.ListBySubscription(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/keyvault/2023-07-01/vaults/method_listbysubscription_autorest.go b/resource-manager/keyvault/2023-07-01/vaults/method_listbysubscription_autorest.go deleted file mode 100644 index 11e2932b29c..00000000000 --- a/resource-manager/keyvault/2023-07-01/vaults/method_listbysubscription_autorest.go +++ /dev/null @@ -1,216 +0,0 @@ -package vaults - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// 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 - Model *[]Vault - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListBySubscriptionOperationResponse, error) -} - -type ListBySubscriptionCompleteResult struct { - Items []Vault -} - -func (r ListBySubscriptionOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListBySubscriptionOperationResponse) LoadMore(ctx context.Context) (resp ListBySubscriptionOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListBySubscriptionOperationOptions struct { - Top *int64 -} - -func DefaultListBySubscriptionOperationOptions() ListBySubscriptionOperationOptions { - return ListBySubscriptionOperationOptions{} -} - -func (o ListBySubscriptionOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListBySubscriptionOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListBySubscription ... -func (c VaultsClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions) (resp ListBySubscriptionOperationResponse, err error) { - req, err := c.preparerForListBySubscription(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListBySubscription", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListBySubscription", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListBySubscription(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListBySubscription", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListBySubscription prepares the ListBySubscription request. -func (c VaultsClient) preparerForListBySubscription(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.KeyVault/vaults", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListBySubscriptionWithNextLink prepares the ListBySubscription request with the given nextLink token. -func (c VaultsClient) preparerForListBySubscriptionWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListBySubscription handles the response to the ListBySubscription request. The method always -// closes the http.Response Body. -func (c VaultsClient) responderForListBySubscription(resp *http.Response) (result ListBySubscriptionOperationResponse, err error) { - type page struct { - Values []Vault `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListBySubscriptionOperationResponse, err error) { - req, err := c.preparerForListBySubscriptionWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListBySubscription", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListBySubscription", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListBySubscription(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListBySubscription", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListBySubscriptionComplete retrieves all of the results into a single object -func (c VaultsClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions) (ListBySubscriptionCompleteResult, error) { - return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, options, VaultOperationPredicate{}) -} - -// ListBySubscriptionCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c VaultsClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions, predicate VaultOperationPredicate) (resp ListBySubscriptionCompleteResult, err error) { - items := make([]Vault, 0) - - page, err := c.ListBySubscription(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListBySubscriptionCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/keyvault/2023-07-01/vaults/method_listdeleted.go b/resource-manager/keyvault/2023-07-01/vaults/method_listdeleted.go new file mode 100644 index 00000000000..9b5afe66345 --- /dev/null +++ b/resource-manager/keyvault/2023-07-01/vaults/method_listdeleted.go @@ -0,0 +1,92 @@ +package vaults + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListDeletedOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DeletedVault +} + +type ListDeletedCompleteResult struct { + LatestHttpResponse *http.Response + Items []DeletedVault +} + +// ListDeleted ... +func (c VaultsClient) ListDeleted(ctx context.Context, id commonids.SubscriptionId) (result ListDeletedOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.KeyVault/deletedVaults", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DeletedVault `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListDeletedComplete retrieves all the results into a single object +func (c VaultsClient) ListDeletedComplete(ctx context.Context, id commonids.SubscriptionId) (ListDeletedCompleteResult, error) { + return c.ListDeletedCompleteMatchingPredicate(ctx, id, DeletedVaultOperationPredicate{}) +} + +// ListDeletedCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VaultsClient) ListDeletedCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate DeletedVaultOperationPredicate) (result ListDeletedCompleteResult, err error) { + items := make([]DeletedVault, 0) + + resp, err := c.ListDeleted(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListDeletedCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/keyvault/2023-07-01/vaults/method_listdeleted_autorest.go b/resource-manager/keyvault/2023-07-01/vaults/method_listdeleted_autorest.go deleted file mode 100644 index 7f1b889661b..00000000000 --- a/resource-manager/keyvault/2023-07-01/vaults/method_listdeleted_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package vaults - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListDeletedOperationResponse struct { - HttpResponse *http.Response - Model *[]DeletedVault - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListDeletedOperationResponse, error) -} - -type ListDeletedCompleteResult struct { - Items []DeletedVault -} - -func (r ListDeletedOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListDeletedOperationResponse) LoadMore(ctx context.Context) (resp ListDeletedOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListDeleted ... -func (c VaultsClient) ListDeleted(ctx context.Context, id commonids.SubscriptionId) (resp ListDeletedOperationResponse, err error) { - req, err := c.preparerForListDeleted(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListDeleted", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListDeleted", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListDeleted(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListDeleted", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListDeleted prepares the ListDeleted request. -func (c VaultsClient) preparerForListDeleted(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.KeyVault/deletedVaults", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListDeletedWithNextLink prepares the ListDeleted request with the given nextLink token. -func (c VaultsClient) preparerForListDeletedWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListDeleted handles the response to the ListDeleted request. The method always -// closes the http.Response Body. -func (c VaultsClient) responderForListDeleted(resp *http.Response) (result ListDeletedOperationResponse, err error) { - type page struct { - Values []DeletedVault `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListDeletedOperationResponse, err error) { - req, err := c.preparerForListDeletedWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListDeleted", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListDeleted", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListDeleted(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "ListDeleted", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListDeletedComplete retrieves all of the results into a single object -func (c VaultsClient) ListDeletedComplete(ctx context.Context, id commonids.SubscriptionId) (ListDeletedCompleteResult, error) { - return c.ListDeletedCompleteMatchingPredicate(ctx, id, DeletedVaultOperationPredicate{}) -} - -// ListDeletedCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c VaultsClient) ListDeletedCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate DeletedVaultOperationPredicate) (resp ListDeletedCompleteResult, err error) { - items := make([]DeletedVault, 0) - - page, err := c.ListDeleted(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListDeletedCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/keyvault/2023-07-01/vaults/method_purgedeleted.go b/resource-manager/keyvault/2023-07-01/vaults/method_purgedeleted.go new file mode 100644 index 00000000000..11fc0e8e4e8 --- /dev/null +++ b/resource-manager/keyvault/2023-07-01/vaults/method_purgedeleted.go @@ -0,0 +1,70 @@ +package vaults + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PurgeDeletedOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// PurgeDeleted ... +func (c VaultsClient) PurgeDeleted(ctx context.Context, id DeletedVaultId) (result PurgeDeletedOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/purge", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// PurgeDeletedThenPoll performs PurgeDeleted then polls until it's completed +func (c VaultsClient) PurgeDeletedThenPoll(ctx context.Context, id DeletedVaultId) error { + result, err := c.PurgeDeleted(ctx, id) + if err != nil { + return fmt.Errorf("performing PurgeDeleted: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after PurgeDeleted: %+v", err) + } + + return nil +} diff --git a/resource-manager/keyvault/2023-07-01/vaults/method_purgedeleted_autorest.go b/resource-manager/keyvault/2023-07-01/vaults/method_purgedeleted_autorest.go deleted file mode 100644 index 17606022668..00000000000 --- a/resource-manager/keyvault/2023-07-01/vaults/method_purgedeleted_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package vaults - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PurgeDeletedOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// PurgeDeleted ... -func (c VaultsClient) PurgeDeleted(ctx context.Context, id DeletedVaultId) (result PurgeDeletedOperationResponse, err error) { - req, err := c.preparerForPurgeDeleted(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "PurgeDeleted", nil, "Failure preparing request") - return - } - - result, err = c.senderForPurgeDeleted(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "PurgeDeleted", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// PurgeDeletedThenPoll performs PurgeDeleted then polls until it's completed -func (c VaultsClient) PurgeDeletedThenPoll(ctx context.Context, id DeletedVaultId) error { - result, err := c.PurgeDeleted(ctx, id) - if err != nil { - return fmt.Errorf("performing PurgeDeleted: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after PurgeDeleted: %+v", err) - } - - return nil -} - -// preparerForPurgeDeleted prepares the PurgeDeleted request. -func (c VaultsClient) preparerForPurgeDeleted(ctx context.Context, id DeletedVaultId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/purge", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForPurgeDeleted sends the PurgeDeleted request. The method will close the -// http.Response Body if it receives an error. -func (c VaultsClient) senderForPurgeDeleted(ctx context.Context, req *http.Request) (future PurgeDeletedOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/keyvault/2023-07-01/vaults/method_update.go b/resource-manager/keyvault/2023-07-01/vaults/method_update.go new file mode 100644 index 00000000000..dc4925e210c --- /dev/null +++ b/resource-manager/keyvault/2023-07-01/vaults/method_update.go @@ -0,0 +1,57 @@ +package vaults + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Vault +} + +// Update ... +func (c VaultsClient) Update(ctx context.Context, id commonids.KeyVaultId, input VaultPatchParameters) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/keyvault/2023-07-01/vaults/method_update_autorest.go b/resource-manager/keyvault/2023-07-01/vaults/method_update_autorest.go deleted file mode 100644 index b1145cfe089..00000000000 --- a/resource-manager/keyvault/2023-07-01/vaults/method_update_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package vaults - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateOperationResponse struct { - HttpResponse *http.Response - Model *Vault -} - -// Update ... -func (c VaultsClient) Update(ctx context.Context, id commonids.KeyVaultId, input VaultPatchParameters) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c VaultsClient) preparerForUpdate(ctx context.Context, id commonids.KeyVaultId, input VaultPatchParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdate handles the response to the Update request. The method always -// closes the http.Response Body. -func (c VaultsClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/keyvault/2023-07-01/vaults/method_updateaccesspolicy.go b/resource-manager/keyvault/2023-07-01/vaults/method_updateaccesspolicy.go new file mode 100644 index 00000000000..5d353359faf --- /dev/null +++ b/resource-manager/keyvault/2023-07-01/vaults/method_updateaccesspolicy.go @@ -0,0 +1,56 @@ +package vaults + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateAccessPolicyOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VaultAccessPolicyParameters +} + +// UpdateAccessPolicy ... +func (c VaultsClient) UpdateAccessPolicy(ctx context.Context, id OperationKindId, input VaultAccessPolicyParameters) (result UpdateAccessPolicyOperationResponse, 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 + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/keyvault/2023-07-01/vaults/method_updateaccesspolicy_autorest.go b/resource-manager/keyvault/2023-07-01/vaults/method_updateaccesspolicy_autorest.go deleted file mode 100644 index f76830d71d8..00000000000 --- a/resource-manager/keyvault/2023-07-01/vaults/method_updateaccesspolicy_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package vaults - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateAccessPolicyOperationResponse struct { - HttpResponse *http.Response - Model *VaultAccessPolicyParameters -} - -// UpdateAccessPolicy ... -func (c VaultsClient) UpdateAccessPolicy(ctx context.Context, id OperationKindId, input VaultAccessPolicyParameters) (result UpdateAccessPolicyOperationResponse, err error) { - req, err := c.preparerForUpdateAccessPolicy(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "UpdateAccessPolicy", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "UpdateAccessPolicy", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateAccessPolicy(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "vaults.VaultsClient", "UpdateAccessPolicy", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateAccessPolicy prepares the UpdateAccessPolicy request. -func (c VaultsClient) preparerForUpdateAccessPolicy(ctx context.Context, id OperationKindId, input VaultAccessPolicyParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateAccessPolicy handles the response to the UpdateAccessPolicy request. The method always -// closes the http.Response Body. -func (c VaultsClient) responderForUpdateAccessPolicy(resp *http.Response) (result UpdateAccessPolicyOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -}