From 634334a47922de23cafc5a9021d17b19202e0cfd Mon Sep 17 00:00:00 2001 From: hc-github-team-tf-azure <> Date: Fri, 26 Jan 2024 10:35:50 +0000 Subject: [PATCH] Updating based on 7fb1cd525 --- .../2021-05-01/application/client.go | 22 ++- .../2021-05-01/application/constants.go | 32 ++- .../application/method_createorupdate.go | 75 +++++++ .../method_createorupdate_autorest.go | 80 -------- .../2021-05-01/application/method_delete.go | 71 +++++++ .../application/method_delete_autorest.go | 78 -------- .../2021-05-01/application/method_get.go | 51 +++++ .../application/method_get_autorest.go | 68 ------- .../2021-05-01/application/method_list.go | 91 +++++++++ .../application/method_list_autorest.go | 186 ----------------- .../2021-05-01/application/method_update.go | 55 ++++++ .../application/method_update_autorest.go | 69 ------- .../2021-05-01/applicationtype/client.go | 22 ++- .../applicationtype/method_createorupdate.go | 55 ++++++ .../method_createorupdate_autorest.go | 69 ------- .../applicationtype/method_delete.go | 71 +++++++ .../applicationtype/method_delete_autorest.go | 78 -------- .../2021-05-01/applicationtype/method_get.go | 51 +++++ .../applicationtype/method_get_autorest.go | 68 ------- .../2021-05-01/applicationtype/method_list.go | 91 +++++++++ .../applicationtype/method_list_autorest.go | 186 ----------------- .../applicationtype/method_update.go | 55 ++++++ .../applicationtype/method_update_autorest.go | 69 ------- .../applicationtypeversion/client.go | 22 ++- .../method_createorupdate.go | 75 +++++++ .../method_createorupdate_autorest.go | 80 -------- .../applicationtypeversion/method_delete.go | 71 +++++++ .../method_delete_autorest.go | 78 -------- .../applicationtypeversion/method_get.go | 51 +++++ .../method_get_autorest.go | 68 ------- .../method_listbyapplicationtypes.go | 91 +++++++++ .../method_listbyapplicationtypes_autorest.go | 186 ----------------- .../applicationtypeversion/method_update.go | 55 ++++++ .../method_update_autorest.go | 69 ------- .../2021-05-01/client.go | 84 +++++--- .../2021-05-01/managedcluster/client.go | 22 ++- .../2021-05-01/managedcluster/constants.go | 149 +++++++++++++- .../managedcluster/method_createorupdate.go | 75 +++++++ .../method_createorupdate_autorest.go | 80 -------- .../managedcluster/method_delete.go | 71 +++++++ .../managedcluster/method_delete_autorest.go | 78 -------- .../2021-05-01/managedcluster/method_get.go | 51 +++++ .../managedcluster/method_get_autorest.go | 68 ------- .../method_listbyresourcegroup.go | 92 +++++++++ .../method_listbyresourcegroup_autorest.go | 187 ------------------ .../method_listbysubscription.go | 92 +++++++++ .../method_listbysubscription_autorest.go | 187 ------------------ .../managedcluster/method_update.go | 55 ++++++ .../managedcluster/method_update_autorest.go | 69 ------- .../managedclusterversion/client.go | 22 ++- .../managedclusterversion/constants.go | 19 +- .../managedclusterversion/method_get.go | 51 +++++ .../method_get_autorest.go | 68 ------- .../method_getbyenvironment.go | 51 +++++ .../method_getbyenvironment_autorest.go | 68 ------- .../managedclusterversion/method_list.go | 52 +++++ .../method_list_autorest.go | 69 ------- .../method_listbyenvironment.go | 52 +++++ .../method_listbyenvironment_autorest.go | 69 ------- .../2021-05-01/nodetype/client.go | 22 ++- .../2021-05-01/nodetype/constants.go | 32 ++- .../nodetype/method_createorupdate.go | 75 +++++++ .../method_createorupdate_autorest.go | 80 -------- .../2021-05-01/nodetype/method_delete.go | 71 +++++++ .../nodetype/method_delete_autorest.go | 78 -------- .../2021-05-01/nodetype/method_deletenode.go | 74 +++++++ .../nodetype/method_deletenode_autorest.go | 79 -------- .../2021-05-01/nodetype/method_get.go | 51 +++++ .../nodetype/method_get_autorest.go | 68 ------- .../nodetype/method_listbymanagedclusters.go | 91 +++++++++ .../method_listbymanagedclusters_autorest.go | 186 ----------------- .../2021-05-01/nodetype/method_reimage.go | 74 +++++++ .../nodetype/method_reimage_autorest.go | 79 -------- .../2021-05-01/nodetype/method_restart.go | 74 +++++++ .../nodetype/method_restart_autorest.go | 79 -------- .../2021-05-01/nodetype/method_update.go | 55 ++++++ .../nodetype/method_update_autorest.go | 69 ------- .../2021-05-01/service/client.go | 22 ++- .../2021-05-01/service/constants.go | 123 +++++++++++- .../service/method_createorupdate.go | 75 +++++++ .../service/method_createorupdate_autorest.go | 80 -------- .../2021-05-01/service/method_delete.go | 71 +++++++ .../service/method_delete_autorest.go | 78 -------- .../2021-05-01/service/method_get.go | 51 +++++ .../2021-05-01/service/method_get_autorest.go | 68 ------- .../service/method_listbyapplications.go | 91 +++++++++ .../method_listbyapplications_autorest.go | 186 ----------------- .../2021-05-01/services/client.go | 22 ++- .../2021-05-01/services/constants.go | 123 +++++++++++- .../2021-05-01/services/method_update.go | 55 ++++++ .../services/method_update_autorest.go | 69 ------- .../2022-01-01/application/client.go | 22 ++- .../2022-01-01/application/constants.go | 32 ++- .../application/method_createorupdate.go | 75 +++++++ .../method_createorupdate_autorest.go | 80 -------- .../2022-01-01/application/method_delete.go | 71 +++++++ .../application/method_delete_autorest.go | 78 -------- .../2022-01-01/application/method_get.go | 51 +++++ .../application/method_get_autorest.go | 68 ------- .../2022-01-01/application/method_list.go | 91 +++++++++ .../application/method_list_autorest.go | 186 ----------------- .../2022-01-01/application/method_update.go | 55 ++++++ .../application/method_update_autorest.go | 69 ------- .../2022-01-01/applicationtype/client.go | 22 ++- .../applicationtype/method_createorupdate.go | 55 ++++++ .../method_createorupdate_autorest.go | 69 ------- .../applicationtype/method_delete.go | 71 +++++++ .../applicationtype/method_delete_autorest.go | 78 -------- .../2022-01-01/applicationtype/method_get.go | 51 +++++ .../applicationtype/method_get_autorest.go | 68 ------- .../2022-01-01/applicationtype/method_list.go | 91 +++++++++ .../applicationtype/method_list_autorest.go | 186 ----------------- .../applicationtype/method_update.go | 55 ++++++ .../applicationtype/method_update_autorest.go | 69 ------- .../applicationtypeversion/client.go | 22 ++- .../method_createorupdate.go | 75 +++++++ .../method_createorupdate_autorest.go | 80 -------- .../applicationtypeversion/method_delete.go | 71 +++++++ .../method_delete_autorest.go | 78 -------- .../applicationtypeversion/method_get.go | 51 +++++ .../method_get_autorest.go | 68 ------- .../method_listbyapplicationtypes.go | 91 +++++++++ .../method_listbyapplicationtypes_autorest.go | 186 ----------------- .../applicationtypeversion/method_update.go | 55 ++++++ .../method_update_autorest.go | 69 ------- .../2022-01-01/client.go | 93 ++++++--- .../2022-01-01/managedcluster/client.go | 22 ++- .../2022-01-01/managedcluster/constants.go | 175 +++++++++++++++- .../managedcluster/method_createorupdate.go | 75 +++++++ .../method_createorupdate_autorest.go | 80 -------- .../managedcluster/method_delete.go | 71 +++++++ .../managedcluster/method_delete_autorest.go | 78 -------- .../2022-01-01/managedcluster/method_get.go | 51 +++++ .../managedcluster/method_get_autorest.go | 68 ------- .../method_listbyresourcegroup.go | 92 +++++++++ .../method_listbyresourcegroup_autorest.go | 187 ------------------ .../method_listbysubscription.go | 92 +++++++++ .../method_listbysubscription_autorest.go | 187 ------------------ .../managedcluster/method_update.go | 55 ++++++ .../managedcluster/method_update_autorest.go | 69 ------- .../managedclusterversion/client.go | 22 ++- .../managedclusterversion/constants.go | 19 +- .../managedclusterversion/method_get.go | 51 +++++ .../method_get_autorest.go | 68 ------- .../method_getbyenvironment.go | 51 +++++ .../method_getbyenvironment_autorest.go | 68 ------- .../managedclusterversion/method_list.go | 52 +++++ .../method_list_autorest.go | 69 ------- .../method_listbyenvironment.go | 52 +++++ .../method_listbyenvironment_autorest.go | 69 ------- .../2022-01-01/managedvmsizes/client.go | 22 ++- .../method_managedunsupportedvmsizesget.go | 51 +++++ ...d_managedunsupportedvmsizesget_autorest.go | 68 ------- .../method_managedunsupportedvmsizeslist.go | 91 +++++++++ ..._managedunsupportedvmsizeslist_autorest.go | 186 ----------------- .../2022-01-01/nodetype/client.go | 22 ++- .../2022-01-01/nodetype/constants.go | 97 ++++++++- .../nodetype/method_createorupdate.go | 75 +++++++ .../method_createorupdate_autorest.go | 80 -------- .../2022-01-01/nodetype/method_delete.go | 71 +++++++ .../nodetype/method_delete_autorest.go | 78 -------- .../2022-01-01/nodetype/method_deletenode.go | 74 +++++++ .../nodetype/method_deletenode_autorest.go | 79 -------- .../2022-01-01/nodetype/method_get.go | 51 +++++ .../nodetype/method_get_autorest.go | 68 ------- .../nodetype/method_listbymanagedclusters.go | 91 +++++++++ .../method_listbymanagedclusters_autorest.go | 186 ----------------- .../2022-01-01/nodetype/method_reimage.go | 74 +++++++ .../nodetype/method_reimage_autorest.go | 79 -------- .../2022-01-01/nodetype/method_restart.go | 74 +++++++ .../nodetype/method_restart_autorest.go | 79 -------- .../2022-01-01/nodetype/method_skuslist.go | 91 +++++++++ .../nodetype/method_skuslist_autorest.go | 186 ----------------- .../2022-01-01/nodetype/method_update.go | 55 ++++++ .../nodetype/method_update_autorest.go | 69 ------- .../2022-01-01/service/client.go | 22 ++- .../2022-01-01/service/constants.go | 123 +++++++++++- .../service/method_createorupdate.go | 75 +++++++ .../service/method_createorupdate_autorest.go | 80 -------- .../2022-01-01/service/method_delete.go | 71 +++++++ .../service/method_delete_autorest.go | 78 -------- .../2022-01-01/service/method_get.go | 51 +++++ .../2022-01-01/service/method_get_autorest.go | 68 ------- .../service/method_listbyapplications.go | 91 +++++++++ .../method_listbyapplications_autorest.go | 186 ----------------- .../2022-01-01/services/client.go | 22 ++- .../2022-01-01/services/constants.go | 123 +++++++++++- .../2022-01-01/services/method_update.go | 55 ++++++ .../services/method_update_autorest.go | 69 ------- 189 files changed, 6757 insertions(+), 7780 deletions(-) create mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/application/method_createorupdate.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/application/method_createorupdate_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/application/method_delete.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/application/method_delete_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/application/method_get.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/application/method_get_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/application/method_list.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/application/method_list_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/application/method_update.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/application/method_update_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtype/method_createorupdate.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtype/method_createorupdate_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtype/method_delete.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtype/method_delete_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtype/method_get.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtype/method_get_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtype/method_list.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtype/method_list_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtype/method_update.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtype/method_update_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtypeversion/method_createorupdate.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtypeversion/method_createorupdate_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtypeversion/method_delete.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtypeversion/method_delete_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtypeversion/method_get.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtypeversion/method_get_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtypeversion/method_listbyapplicationtypes.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtypeversion/method_listbyapplicationtypes_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtypeversion/method_update.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtypeversion/method_update_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/method_createorupdate.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/method_createorupdate_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/method_delete.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/method_delete_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/method_get.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/method_get_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/method_listbyresourcegroup.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/method_listbyresourcegroup_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/method_listbysubscription.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/method_listbysubscription_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/method_update.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/method_update_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/managedclusterversion/method_get.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/managedclusterversion/method_get_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/managedclusterversion/method_getbyenvironment.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/managedclusterversion/method_getbyenvironment_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/managedclusterversion/method_list.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/managedclusterversion/method_list_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/managedclusterversion/method_listbyenvironment.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/managedclusterversion/method_listbyenvironment_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_createorupdate.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_createorupdate_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_delete.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_delete_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_deletenode.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_deletenode_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_get.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_get_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_listbymanagedclusters.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_listbymanagedclusters_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_reimage.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_reimage_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_restart.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_restart_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_update.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_update_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/service/method_createorupdate.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/service/method_createorupdate_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/service/method_delete.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/service/method_delete_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/service/method_get.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/service/method_get_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/service/method_listbyapplications.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/service/method_listbyapplications_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/services/method_update.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2021-05-01/services/method_update_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/application/method_createorupdate.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/application/method_createorupdate_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/application/method_delete.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/application/method_delete_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/application/method_get.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/application/method_get_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/application/method_list.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/application/method_list_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/application/method_update.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/application/method_update_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtype/method_createorupdate.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtype/method_createorupdate_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtype/method_delete.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtype/method_delete_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtype/method_get.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtype/method_get_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtype/method_list.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtype/method_list_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtype/method_update.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtype/method_update_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtypeversion/method_createorupdate.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtypeversion/method_createorupdate_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtypeversion/method_delete.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtypeversion/method_delete_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtypeversion/method_get.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtypeversion/method_get_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtypeversion/method_listbyapplicationtypes.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtypeversion/method_listbyapplicationtypes_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtypeversion/method_update.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtypeversion/method_update_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/method_createorupdate.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/method_createorupdate_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/method_delete.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/method_delete_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/method_get.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/method_get_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/method_listbyresourcegroup.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/method_listbyresourcegroup_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/method_listbysubscription.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/method_listbysubscription_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/method_update.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/method_update_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/managedclusterversion/method_get.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/managedclusterversion/method_get_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/managedclusterversion/method_getbyenvironment.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/managedclusterversion/method_getbyenvironment_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/managedclusterversion/method_list.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/managedclusterversion/method_list_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/managedclusterversion/method_listbyenvironment.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/managedclusterversion/method_listbyenvironment_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/managedvmsizes/method_managedunsupportedvmsizesget.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/managedvmsizes/method_managedunsupportedvmsizesget_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/managedvmsizes/method_managedunsupportedvmsizeslist.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/managedvmsizes/method_managedunsupportedvmsizeslist_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_createorupdate.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_createorupdate_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_delete.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_delete_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_deletenode.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_deletenode_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_get.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_get_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_listbymanagedclusters.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_listbymanagedclusters_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_reimage.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_reimage_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_restart.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_restart_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_skuslist.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_skuslist_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_update.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_update_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/service/method_createorupdate.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/service/method_createorupdate_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/service/method_delete.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/service/method_delete_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/service/method_get.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/service/method_get_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/service/method_listbyapplications.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/service/method_listbyapplications_autorest.go create mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/services/method_update.go delete mode 100644 resource-manager/servicefabricmanagedcluster/2022-01-01/services/method_update_autorest.go diff --git a/resource-manager/servicefabricmanagedcluster/2021-05-01/application/client.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/application/client.go index 56913082b95..c87320630e0 100644 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/application/client.go +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/application/client.go @@ -1,18 +1,26 @@ package application -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 ApplicationClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewApplicationClientWithBaseURI(endpoint string) ApplicationClient { - return ApplicationClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewApplicationClientWithBaseURI(sdkApi sdkEnv.Api) (*ApplicationClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "application", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApplicationClient: %+v", err) } + + return &ApplicationClient{ + Client: client, + }, nil } diff --git a/resource-manager/servicefabricmanagedcluster/2021-05-01/application/constants.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/application/constants.go index 73c2c5597ed..5456526a734 100644 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/application/constants.go +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/application/constants.go @@ -1,6 +1,10 @@ package application -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. @@ -19,6 +23,19 @@ func PossibleValuesForFailureAction() []string { } } +func (s *FailureAction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFailureAction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseFailureAction(input string) (*FailureAction, error) { vals := map[string]FailureAction{ "manual": FailureActionManual, @@ -47,6 +64,19 @@ func PossibleValuesForRollingUpgradeMode() []string { } } +func (s *RollingUpgradeMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRollingUpgradeMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseRollingUpgradeMode(input string) (*RollingUpgradeMode, error) { vals := map[string]RollingUpgradeMode{ "monitored": RollingUpgradeModeMonitored, diff --git a/resource-manager/servicefabricmanagedcluster/2021-05-01/application/method_createorupdate.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/application/method_createorupdate.go new file mode 100644 index 00000000000..a6c822e721e --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/application/method_createorupdate.go @@ -0,0 +1,75 @@ +package application + +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 *ApplicationResource +} + +// CreateOrUpdate ... +func (c ApplicationClient) CreateOrUpdate(ctx context.Context, id ApplicationId, input ApplicationResource) (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 + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c ApplicationClient) CreateOrUpdateThenPoll(ctx context.Context, id ApplicationId, input ApplicationResource) 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/servicefabricmanagedcluster/2021-05-01/application/method_createorupdate_autorest.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/application/method_createorupdate_autorest.go deleted file mode 100644 index cbf5aa747a2..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/application/method_createorupdate_autorest.go +++ /dev/null @@ -1,80 +0,0 @@ -package application - -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 *ApplicationResource -} - -// CreateOrUpdate ... -func (c ApplicationClient) CreateOrUpdate(ctx context.Context, id ApplicationId, input ApplicationResource) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "application.ApplicationClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "application.ApplicationClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c ApplicationClient) CreateOrUpdateThenPoll(ctx context.Context, id ApplicationId, input ApplicationResource) 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 ApplicationClient) preparerForCreateOrUpdate(ctx context.Context, id ApplicationId, input ApplicationResource) (*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 ApplicationClient) 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/servicefabricmanagedcluster/2021-05-01/application/method_delete.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/application/method_delete.go new file mode 100644 index 00000000000..3770a2d10be --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/application/method_delete.go @@ -0,0 +1,71 @@ +package application + +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 ApplicationClient) Delete(ctx context.Context, id ApplicationId) (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 ApplicationClient) DeleteThenPoll(ctx context.Context, id ApplicationId) 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/servicefabricmanagedcluster/2021-05-01/application/method_delete_autorest.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/application/method_delete_autorest.go deleted file mode 100644 index 1e0ea7f29be..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/application/method_delete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package application - -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 ApplicationClient) Delete(ctx context.Context, id ApplicationId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "application.ApplicationClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "application.ApplicationClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c ApplicationClient) DeleteThenPoll(ctx context.Context, id ApplicationId) 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 ApplicationClient) preparerForDelete(ctx context.Context, id ApplicationId) (*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 ApplicationClient) 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/servicefabricmanagedcluster/2021-05-01/application/method_get.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/application/method_get.go new file mode 100644 index 00000000000..fb8a5955769 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/application/method_get.go @@ -0,0 +1,51 @@ +package application + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApplicationResource +} + +// Get ... +func (c ApplicationClient) Get(ctx context.Context, id ApplicationId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2021-05-01/application/method_get_autorest.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/application/method_get_autorest.go deleted file mode 100644 index 6485d032d8b..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/application/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package application - -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 *ApplicationResource -} - -// Get ... -func (c ApplicationClient) Get(ctx context.Context, id ApplicationId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "application.ApplicationClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "application.ApplicationClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "application.ApplicationClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ApplicationClient) preparerForGet(ctx context.Context, id ApplicationId) (*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 ApplicationClient) 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/servicefabricmanagedcluster/2021-05-01/application/method_list.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/application/method_list.go new file mode 100644 index 00000000000..6749eb898a8 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/application/method_list.go @@ -0,0 +1,91 @@ +package application + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApplicationResource +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ApplicationResource +} + +// List ... +func (c ApplicationClient) List(ctx context.Context, id ManagedClusterId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/applications", id.ID()), + } + + 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 *[]ApplicationResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ApplicationClient) ListComplete(ctx context.Context, id ManagedClusterId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ApplicationResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApplicationClient) ListCompleteMatchingPredicate(ctx context.Context, id ManagedClusterId, predicate ApplicationResourceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ApplicationResource, 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/servicefabricmanagedcluster/2021-05-01/application/method_list_autorest.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/application/method_list_autorest.go deleted file mode 100644 index 27dbde8fd7f..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/application/method_list_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package application - -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 *[]ApplicationResource - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []ApplicationResource -} - -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 ApplicationClient) List(ctx context.Context, id ManagedClusterId) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "application.ApplicationClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "application.ApplicationClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "application.ApplicationClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c ApplicationClient) preparerForList(ctx context.Context, id ManagedClusterId) (*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/applications", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c ApplicationClient) 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 ApplicationClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []ApplicationResource `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, "application.ApplicationClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "application.ApplicationClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "application.ApplicationClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c ApplicationClient) ListComplete(ctx context.Context, id ManagedClusterId) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, ApplicationResourceOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ApplicationClient) ListCompleteMatchingPredicate(ctx context.Context, id ManagedClusterId, predicate ApplicationResourceOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]ApplicationResource, 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/servicefabricmanagedcluster/2021-05-01/application/method_update.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/application/method_update.go new file mode 100644 index 00000000000..ee5837951a9 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/application/method_update.go @@ -0,0 +1,55 @@ +package application + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApplicationResource +} + +// Update ... +func (c ApplicationClient) Update(ctx context.Context, id ApplicationId, input ApplicationUpdateParameters) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2021-05-01/application/method_update_autorest.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/application/method_update_autorest.go deleted file mode 100644 index 6b3955fa828..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/application/method_update_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package application - -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 *ApplicationResource -} - -// Update ... -func (c ApplicationClient) Update(ctx context.Context, id ApplicationId, input ApplicationUpdateParameters) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "application.ApplicationClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "application.ApplicationClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "application.ApplicationClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c ApplicationClient) preparerForUpdate(ctx context.Context, id ApplicationId, input ApplicationUpdateParameters) (*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 ApplicationClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, 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/servicefabricmanagedcluster/2021-05-01/applicationtype/client.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtype/client.go index 0cbef204452..08cc08e353a 100644 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtype/client.go +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtype/client.go @@ -1,18 +1,26 @@ package applicationtype -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 ApplicationTypeClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewApplicationTypeClientWithBaseURI(endpoint string) ApplicationTypeClient { - return ApplicationTypeClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewApplicationTypeClientWithBaseURI(sdkApi sdkEnv.Api) (*ApplicationTypeClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "applicationtype", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApplicationTypeClient: %+v", err) } + + return &ApplicationTypeClient{ + Client: client, + }, nil } diff --git a/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtype/method_createorupdate.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtype/method_createorupdate.go new file mode 100644 index 00000000000..74d5d878bb7 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtype/method_createorupdate.go @@ -0,0 +1,55 @@ +package applicationtype + +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 *ApplicationTypeResource +} + +// CreateOrUpdate ... +func (c ApplicationTypeClient) CreateOrUpdate(ctx context.Context, id ApplicationTypeId, input ApplicationTypeResource) (result CreateOrUpdateOperationResponse, 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/servicefabricmanagedcluster/2021-05-01/applicationtype/method_createorupdate_autorest.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtype/method_createorupdate_autorest.go deleted file mode 100644 index 875e390e5c9..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtype/method_createorupdate_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package applicationtype - -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 *ApplicationTypeResource -} - -// CreateOrUpdate ... -func (c ApplicationTypeClient) CreateOrUpdate(ctx context.Context, id ApplicationTypeId, input ApplicationTypeResource) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtype.ApplicationTypeClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtype.ApplicationTypeClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtype.ApplicationTypeClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c ApplicationTypeClient) preparerForCreateOrUpdate(ctx context.Context, id ApplicationTypeId, input ApplicationTypeResource) (*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 ApplicationTypeClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, 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/servicefabricmanagedcluster/2021-05-01/applicationtype/method_delete.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtype/method_delete.go new file mode 100644 index 00000000000..6842c7382a7 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtype/method_delete.go @@ -0,0 +1,71 @@ +package applicationtype + +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 ApplicationTypeClient) Delete(ctx context.Context, id ApplicationTypeId) (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 ApplicationTypeClient) DeleteThenPoll(ctx context.Context, id ApplicationTypeId) 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/servicefabricmanagedcluster/2021-05-01/applicationtype/method_delete_autorest.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtype/method_delete_autorest.go deleted file mode 100644 index 7105b4caa53..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtype/method_delete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package applicationtype - -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 ApplicationTypeClient) Delete(ctx context.Context, id ApplicationTypeId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtype.ApplicationTypeClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtype.ApplicationTypeClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c ApplicationTypeClient) DeleteThenPoll(ctx context.Context, id ApplicationTypeId) 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 ApplicationTypeClient) preparerForDelete(ctx context.Context, id ApplicationTypeId) (*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 ApplicationTypeClient) 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/servicefabricmanagedcluster/2021-05-01/applicationtype/method_get.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtype/method_get.go new file mode 100644 index 00000000000..22d9d2d9413 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtype/method_get.go @@ -0,0 +1,51 @@ +package applicationtype + +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 *ApplicationTypeResource +} + +// Get ... +func (c ApplicationTypeClient) Get(ctx context.Context, id ApplicationTypeId) (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/servicefabricmanagedcluster/2021-05-01/applicationtype/method_get_autorest.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtype/method_get_autorest.go deleted file mode 100644 index f676fb22170..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtype/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package applicationtype - -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 *ApplicationTypeResource -} - -// Get ... -func (c ApplicationTypeClient) Get(ctx context.Context, id ApplicationTypeId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtype.ApplicationTypeClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtype.ApplicationTypeClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtype.ApplicationTypeClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ApplicationTypeClient) preparerForGet(ctx context.Context, id ApplicationTypeId) (*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 ApplicationTypeClient) 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/servicefabricmanagedcluster/2021-05-01/applicationtype/method_list.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtype/method_list.go new file mode 100644 index 00000000000..57d64fde1a2 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtype/method_list.go @@ -0,0 +1,91 @@ +package applicationtype + +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 *[]ApplicationTypeResource +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ApplicationTypeResource +} + +// List ... +func (c ApplicationTypeClient) List(ctx context.Context, id ManagedClusterId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/applicationTypes", 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 *[]ApplicationTypeResource `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 ApplicationTypeClient) ListComplete(ctx context.Context, id ManagedClusterId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ApplicationTypeResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApplicationTypeClient) ListCompleteMatchingPredicate(ctx context.Context, id ManagedClusterId, predicate ApplicationTypeResourceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ApplicationTypeResource, 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/servicefabricmanagedcluster/2021-05-01/applicationtype/method_list_autorest.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtype/method_list_autorest.go deleted file mode 100644 index dda1c6a8ba2..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtype/method_list_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package applicationtype - -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 *[]ApplicationTypeResource - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []ApplicationTypeResource -} - -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 ApplicationTypeClient) List(ctx context.Context, id ManagedClusterId) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtype.ApplicationTypeClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtype.ApplicationTypeClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtype.ApplicationTypeClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c ApplicationTypeClient) preparerForList(ctx context.Context, id ManagedClusterId) (*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/applicationTypes", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c ApplicationTypeClient) 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 ApplicationTypeClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []ApplicationTypeResource `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, "applicationtype.ApplicationTypeClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtype.ApplicationTypeClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtype.ApplicationTypeClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c ApplicationTypeClient) ListComplete(ctx context.Context, id ManagedClusterId) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, ApplicationTypeResourceOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ApplicationTypeClient) ListCompleteMatchingPredicate(ctx context.Context, id ManagedClusterId, predicate ApplicationTypeResourceOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]ApplicationTypeResource, 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/servicefabricmanagedcluster/2021-05-01/applicationtype/method_update.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtype/method_update.go new file mode 100644 index 00000000000..74577757e20 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtype/method_update.go @@ -0,0 +1,55 @@ +package applicationtype + +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 *ApplicationTypeResource +} + +// Update ... +func (c ApplicationTypeClient) Update(ctx context.Context, id ApplicationTypeId, input ApplicationTypeUpdateParameters) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtype/method_update_autorest.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtype/method_update_autorest.go deleted file mode 100644 index 43b3533e842..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtype/method_update_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package applicationtype - -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 *ApplicationTypeResource -} - -// Update ... -func (c ApplicationTypeClient) Update(ctx context.Context, id ApplicationTypeId, input ApplicationTypeUpdateParameters) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtype.ApplicationTypeClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtype.ApplicationTypeClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtype.ApplicationTypeClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c ApplicationTypeClient) preparerForUpdate(ctx context.Context, id ApplicationTypeId, input ApplicationTypeUpdateParameters) (*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 ApplicationTypeClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, 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/servicefabricmanagedcluster/2021-05-01/applicationtypeversion/client.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtypeversion/client.go index 62ded9097a7..fbfd96f6ea3 100644 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtypeversion/client.go +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtypeversion/client.go @@ -1,18 +1,26 @@ package applicationtypeversion -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 ApplicationTypeVersionClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewApplicationTypeVersionClientWithBaseURI(endpoint string) ApplicationTypeVersionClient { - return ApplicationTypeVersionClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewApplicationTypeVersionClientWithBaseURI(sdkApi sdkEnv.Api) (*ApplicationTypeVersionClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "applicationtypeversion", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApplicationTypeVersionClient: %+v", err) } + + return &ApplicationTypeVersionClient{ + Client: client, + }, nil } diff --git a/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtypeversion/method_createorupdate.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtypeversion/method_createorupdate.go new file mode 100644 index 00000000000..4fbc5cb8b62 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtypeversion/method_createorupdate.go @@ -0,0 +1,75 @@ +package applicationtypeversion + +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 *ApplicationTypeVersionResource +} + +// CreateOrUpdate ... +func (c ApplicationTypeVersionClient) CreateOrUpdate(ctx context.Context, id VersionId, input ApplicationTypeVersionResource) (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 + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c ApplicationTypeVersionClient) CreateOrUpdateThenPoll(ctx context.Context, id VersionId, input ApplicationTypeVersionResource) 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/servicefabricmanagedcluster/2021-05-01/applicationtypeversion/method_createorupdate_autorest.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtypeversion/method_createorupdate_autorest.go deleted file mode 100644 index 50875ff36e1..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtypeversion/method_createorupdate_autorest.go +++ /dev/null @@ -1,80 +0,0 @@ -package applicationtypeversion - -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 *ApplicationTypeVersionResource -} - -// CreateOrUpdate ... -func (c ApplicationTypeVersionClient) CreateOrUpdate(ctx context.Context, id VersionId, input ApplicationTypeVersionResource) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtypeversion.ApplicationTypeVersionClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtypeversion.ApplicationTypeVersionClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c ApplicationTypeVersionClient) CreateOrUpdateThenPoll(ctx context.Context, id VersionId, input ApplicationTypeVersionResource) 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 ApplicationTypeVersionClient) preparerForCreateOrUpdate(ctx context.Context, id VersionId, input ApplicationTypeVersionResource) (*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 ApplicationTypeVersionClient) 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/servicefabricmanagedcluster/2021-05-01/applicationtypeversion/method_delete.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtypeversion/method_delete.go new file mode 100644 index 00000000000..7ed42106836 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtypeversion/method_delete.go @@ -0,0 +1,71 @@ +package applicationtypeversion + +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 ApplicationTypeVersionClient) Delete(ctx context.Context, id VersionId) (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 ApplicationTypeVersionClient) DeleteThenPoll(ctx context.Context, id VersionId) 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/servicefabricmanagedcluster/2021-05-01/applicationtypeversion/method_delete_autorest.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtypeversion/method_delete_autorest.go deleted file mode 100644 index 7d54184a693..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtypeversion/method_delete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package applicationtypeversion - -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 ApplicationTypeVersionClient) Delete(ctx context.Context, id VersionId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtypeversion.ApplicationTypeVersionClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtypeversion.ApplicationTypeVersionClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c ApplicationTypeVersionClient) DeleteThenPoll(ctx context.Context, id VersionId) 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 ApplicationTypeVersionClient) preparerForDelete(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.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 ApplicationTypeVersionClient) 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/servicefabricmanagedcluster/2021-05-01/applicationtypeversion/method_get.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtypeversion/method_get.go new file mode 100644 index 00000000000..13ab0519fbb --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtypeversion/method_get.go @@ -0,0 +1,51 @@ +package applicationtypeversion + +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 *ApplicationTypeVersionResource +} + +// Get ... +func (c ApplicationTypeVersionClient) Get(ctx context.Context, id VersionId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtypeversion/method_get_autorest.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtypeversion/method_get_autorest.go deleted file mode 100644 index e35b8f8eee4..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtypeversion/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package applicationtypeversion - -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 *ApplicationTypeVersionResource -} - -// Get ... -func (c ApplicationTypeVersionClient) Get(ctx context.Context, id VersionId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtypeversion.ApplicationTypeVersionClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtypeversion.ApplicationTypeVersionClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtypeversion.ApplicationTypeVersionClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ApplicationTypeVersionClient) preparerForGet(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)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c ApplicationTypeVersionClient) 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/servicefabricmanagedcluster/2021-05-01/applicationtypeversion/method_listbyapplicationtypes.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtypeversion/method_listbyapplicationtypes.go new file mode 100644 index 00000000000..d6cec2a7c45 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtypeversion/method_listbyapplicationtypes.go @@ -0,0 +1,91 @@ +package applicationtypeversion + +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 ListByApplicationTypesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApplicationTypeVersionResource +} + +type ListByApplicationTypesCompleteResult struct { + LatestHttpResponse *http.Response + Items []ApplicationTypeVersionResource +} + +// ListByApplicationTypes ... +func (c ApplicationTypeVersionClient) ListByApplicationTypes(ctx context.Context, id ApplicationTypeId) (result ListByApplicationTypesOperationResponse, 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 *[]ApplicationTypeVersionResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByApplicationTypesComplete retrieves all the results into a single object +func (c ApplicationTypeVersionClient) ListByApplicationTypesComplete(ctx context.Context, id ApplicationTypeId) (ListByApplicationTypesCompleteResult, error) { + return c.ListByApplicationTypesCompleteMatchingPredicate(ctx, id, ApplicationTypeVersionResourceOperationPredicate{}) +} + +// ListByApplicationTypesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApplicationTypeVersionClient) ListByApplicationTypesCompleteMatchingPredicate(ctx context.Context, id ApplicationTypeId, predicate ApplicationTypeVersionResourceOperationPredicate) (result ListByApplicationTypesCompleteResult, err error) { + items := make([]ApplicationTypeVersionResource, 0) + + resp, err := c.ListByApplicationTypes(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 = ListByApplicationTypesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtypeversion/method_listbyapplicationtypes_autorest.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtypeversion/method_listbyapplicationtypes_autorest.go deleted file mode 100644 index 93d0fc0685f..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtypeversion/method_listbyapplicationtypes_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package applicationtypeversion - -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 ListByApplicationTypesOperationResponse struct { - HttpResponse *http.Response - Model *[]ApplicationTypeVersionResource - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByApplicationTypesOperationResponse, error) -} - -type ListByApplicationTypesCompleteResult struct { - Items []ApplicationTypeVersionResource -} - -func (r ListByApplicationTypesOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByApplicationTypesOperationResponse) LoadMore(ctx context.Context) (resp ListByApplicationTypesOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByApplicationTypes ... -func (c ApplicationTypeVersionClient) ListByApplicationTypes(ctx context.Context, id ApplicationTypeId) (resp ListByApplicationTypesOperationResponse, err error) { - req, err := c.preparerForListByApplicationTypes(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtypeversion.ApplicationTypeVersionClient", "ListByApplicationTypes", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtypeversion.ApplicationTypeVersionClient", "ListByApplicationTypes", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByApplicationTypes(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtypeversion.ApplicationTypeVersionClient", "ListByApplicationTypes", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByApplicationTypes prepares the ListByApplicationTypes request. -func (c ApplicationTypeVersionClient) preparerForListByApplicationTypes(ctx context.Context, id ApplicationTypeId) (*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)) -} - -// preparerForListByApplicationTypesWithNextLink prepares the ListByApplicationTypes request with the given nextLink token. -func (c ApplicationTypeVersionClient) preparerForListByApplicationTypesWithNextLink(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)) -} - -// responderForListByApplicationTypes handles the response to the ListByApplicationTypes request. The method always -// closes the http.Response Body. -func (c ApplicationTypeVersionClient) responderForListByApplicationTypes(resp *http.Response) (result ListByApplicationTypesOperationResponse, err error) { - type page struct { - Values []ApplicationTypeVersionResource `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 ListByApplicationTypesOperationResponse, err error) { - req, err := c.preparerForListByApplicationTypesWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtypeversion.ApplicationTypeVersionClient", "ListByApplicationTypes", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtypeversion.ApplicationTypeVersionClient", "ListByApplicationTypes", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByApplicationTypes(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtypeversion.ApplicationTypeVersionClient", "ListByApplicationTypes", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByApplicationTypesComplete retrieves all of the results into a single object -func (c ApplicationTypeVersionClient) ListByApplicationTypesComplete(ctx context.Context, id ApplicationTypeId) (ListByApplicationTypesCompleteResult, error) { - return c.ListByApplicationTypesCompleteMatchingPredicate(ctx, id, ApplicationTypeVersionResourceOperationPredicate{}) -} - -// ListByApplicationTypesCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ApplicationTypeVersionClient) ListByApplicationTypesCompleteMatchingPredicate(ctx context.Context, id ApplicationTypeId, predicate ApplicationTypeVersionResourceOperationPredicate) (resp ListByApplicationTypesCompleteResult, err error) { - items := make([]ApplicationTypeVersionResource, 0) - - page, err := c.ListByApplicationTypes(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 := ListByApplicationTypesCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtypeversion/method_update.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtypeversion/method_update.go new file mode 100644 index 00000000000..d8642230902 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtypeversion/method_update.go @@ -0,0 +1,55 @@ +package applicationtypeversion + +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 *ApplicationTypeVersionResource +} + +// Update ... +func (c ApplicationTypeVersionClient) Update(ctx context.Context, id VersionId, input ApplicationTypeVersionUpdateParameters) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtypeversion/method_update_autorest.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtypeversion/method_update_autorest.go deleted file mode 100644 index 2a579e6ee92..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtypeversion/method_update_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package applicationtypeversion - -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 *ApplicationTypeVersionResource -} - -// Update ... -func (c ApplicationTypeVersionClient) Update(ctx context.Context, id VersionId, input ApplicationTypeVersionUpdateParameters) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtypeversion.ApplicationTypeVersionClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtypeversion.ApplicationTypeVersionClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtypeversion.ApplicationTypeVersionClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c ApplicationTypeVersionClient) preparerForUpdate(ctx context.Context, id VersionId, input ApplicationTypeVersionUpdateParameters) (*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 ApplicationTypeVersionClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, 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/servicefabricmanagedcluster/2021-05-01/client.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/client.go index e77a3632d96..2c1894ea90e 100644 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/client.go +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/client.go @@ -4,7 +4,8 @@ package v2021_05_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/servicefabricmanagedcluster/2021-05-01/application" "github.com/hashicorp/go-azure-sdk/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtype" "github.com/hashicorp/go-azure-sdk/resource-manager/servicefabricmanagedcluster/2021-05-01/applicationtypeversion" @@ -13,6 +14,8 @@ import ( "github.com/hashicorp/go-azure-sdk/resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype" "github.com/hashicorp/go-azure-sdk/resource-manager/servicefabricmanagedcluster/2021-05-01/service" "github.com/hashicorp/go-azure-sdk/resource-manager/servicefabricmanagedcluster/2021-05-01/services" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" ) type Client struct { @@ -26,40 +29,63 @@ type Client struct { Services *services.ServicesClient } -func NewClientWithBaseURI(endpoint string, configureAuthFunc func(c *autorest.Client)) Client { - - applicationClient := application.NewApplicationClientWithBaseURI(endpoint) - configureAuthFunc(&applicationClient.Client) - - applicationTypeClient := applicationtype.NewApplicationTypeClientWithBaseURI(endpoint) - configureAuthFunc(&applicationTypeClient.Client) +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + applicationClient, err := application.NewApplicationClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Application client: %+v", err) + } + configureFunc(applicationClient.Client) - applicationTypeVersionClient := applicationtypeversion.NewApplicationTypeVersionClientWithBaseURI(endpoint) - configureAuthFunc(&applicationTypeVersionClient.Client) + applicationTypeClient, err := applicationtype.NewApplicationTypeClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ApplicationType client: %+v", err) + } + configureFunc(applicationTypeClient.Client) - managedClusterClient := managedcluster.NewManagedClusterClientWithBaseURI(endpoint) - configureAuthFunc(&managedClusterClient.Client) + applicationTypeVersionClient, err := applicationtypeversion.NewApplicationTypeVersionClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ApplicationTypeVersion client: %+v", err) + } + configureFunc(applicationTypeVersionClient.Client) - managedClusterVersionClient := managedclusterversion.NewManagedClusterVersionClientWithBaseURI(endpoint) - configureAuthFunc(&managedClusterVersionClient.Client) + managedClusterClient, err := managedcluster.NewManagedClusterClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ManagedCluster client: %+v", err) + } + configureFunc(managedClusterClient.Client) - nodeTypeClient := nodetype.NewNodeTypeClientWithBaseURI(endpoint) - configureAuthFunc(&nodeTypeClient.Client) + managedClusterVersionClient, err := managedclusterversion.NewManagedClusterVersionClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ManagedClusterVersion client: %+v", err) + } + configureFunc(managedClusterVersionClient.Client) - serviceClient := service.NewServiceClientWithBaseURI(endpoint) - configureAuthFunc(&serviceClient.Client) + nodeTypeClient, err := nodetype.NewNodeTypeClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building NodeType client: %+v", err) + } + configureFunc(nodeTypeClient.Client) - servicesClient := services.NewServicesClientWithBaseURI(endpoint) - configureAuthFunc(&servicesClient.Client) + serviceClient, err := service.NewServiceClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Service client: %+v", err) + } + configureFunc(serviceClient.Client) - return Client{ - Application: &applicationClient, - ApplicationType: &applicationTypeClient, - ApplicationTypeVersion: &applicationTypeVersionClient, - ManagedCluster: &managedClusterClient, - ManagedClusterVersion: &managedClusterVersionClient, - NodeType: &nodeTypeClient, - Service: &serviceClient, - Services: &servicesClient, + servicesClient, err := services.NewServicesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Services client: %+v", err) } + configureFunc(servicesClient.Client) + + return &Client{ + Application: applicationClient, + ApplicationType: applicationTypeClient, + ApplicationTypeVersion: applicationTypeVersionClient, + ManagedCluster: managedClusterClient, + ManagedClusterVersion: managedClusterVersionClient, + NodeType: nodeTypeClient, + Service: serviceClient, + Services: servicesClient, + }, nil } diff --git a/resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/client.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/client.go index 52b5b623754..14c21d22764 100644 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/client.go +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/client.go @@ -1,18 +1,26 @@ package managedcluster -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 ManagedClusterClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewManagedClusterClientWithBaseURI(endpoint string) ManagedClusterClient { - return ManagedClusterClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewManagedClusterClientWithBaseURI(sdkApi sdkEnv.Api) (*ManagedClusterClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "managedcluster", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ManagedClusterClient: %+v", err) } + + return &ManagedClusterClient{ + Client: client, + }, nil } diff --git a/resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/constants.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/constants.go index 5214ab8bde4..7ac1ed57fb2 100644 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/constants.go +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/constants.go @@ -1,6 +1,10 @@ package managedcluster -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. @@ -19,6 +23,19 @@ func PossibleValuesForAccess() []string { } } +func (s *Access) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAccess(input string) (*Access, error) { vals := map[string]Access{ "allow": AccessAllow, @@ -49,6 +66,19 @@ func PossibleValuesForAddonFeatures() []string { } } +func (s *AddonFeatures) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAddonFeatures(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAddonFeatures(input string) (*AddonFeatures, error) { vals := map[string]AddonFeatures{ "backuprestoreservice": AddonFeaturesBackupRestoreService, @@ -86,6 +116,19 @@ func PossibleValuesForClusterState() []string { } } +func (s *ClusterState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClusterState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseClusterState(input string) (*ClusterState, error) { vals := map[string]ClusterState{ "baselineupgrade": ClusterStateBaselineUpgrade, @@ -120,6 +163,19 @@ func PossibleValuesForClusterUpgradeCadence() []string { } } +func (s *ClusterUpgradeCadence) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClusterUpgradeCadence(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseClusterUpgradeCadence(input string) (*ClusterUpgradeCadence, error) { vals := map[string]ClusterUpgradeCadence{ "wave1": ClusterUpgradeCadenceWaveOne, @@ -149,6 +205,19 @@ func PossibleValuesForClusterUpgradeMode() []string { } } +func (s *ClusterUpgradeMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClusterUpgradeMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseClusterUpgradeMode(input string) (*ClusterUpgradeMode, error) { vals := map[string]ClusterUpgradeMode{ "automatic": ClusterUpgradeModeAutomatic, @@ -177,6 +246,19 @@ func PossibleValuesForDirection() []string { } } +func (s *Direction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDirection(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseDirection(input string) (*Direction, error) { vals := map[string]Direction{ "inbound": DirectionInbound, @@ -221,6 +303,19 @@ func PossibleValuesForManagedResourceProvisioningState() []string { } } +func (s *ManagedResourceProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedResourceProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseManagedResourceProvisioningState(input string) (*ManagedResourceProvisioningState, error) { vals := map[string]ManagedResourceProvisioningState{ "canceled": ManagedResourceProvisioningStateCanceled, @@ -267,6 +362,19 @@ func PossibleValuesForNsgProtocol() []string { } } +func (s *NsgProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNsgProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseNsgProtocol(input string) (*NsgProtocol, error) { vals := map[string]NsgProtocol{ "ah": NsgProtocolAh, @@ -302,6 +410,19 @@ func PossibleValuesForProbeProtocol() []string { } } +func (s *ProbeProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProbeProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseProbeProtocol(input string) (*ProbeProtocol, error) { vals := map[string]ProbeProtocol{ "http": ProbeProtocolHTTP, @@ -331,6 +452,19 @@ func PossibleValuesForProtocol() []string { } } +func (s *Protocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseProtocol(input string) (*Protocol, error) { vals := map[string]Protocol{ "tcp": ProtocolTcp, @@ -359,6 +493,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{ "basic": SkuNameBasic, diff --git a/resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/method_createorupdate.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/method_createorupdate.go new file mode 100644 index 00000000000..95e9f5ad9fc --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/method_createorupdate.go @@ -0,0 +1,75 @@ +package managedcluster + +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 *ManagedCluster +} + +// CreateOrUpdate ... +func (c ManagedClusterClient) CreateOrUpdate(ctx context.Context, id ManagedClusterId, input ManagedCluster) (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 + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c ManagedClusterClient) CreateOrUpdateThenPoll(ctx context.Context, id ManagedClusterId, input ManagedCluster) 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/servicefabricmanagedcluster/2021-05-01/managedcluster/method_createorupdate_autorest.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/method_createorupdate_autorest.go deleted file mode 100644 index 86b18349142..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/method_createorupdate_autorest.go +++ /dev/null @@ -1,80 +0,0 @@ -package managedcluster - -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 *ManagedCluster -} - -// CreateOrUpdate ... -func (c ManagedClusterClient) CreateOrUpdate(ctx context.Context, id ManagedClusterId, input ManagedCluster) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "managedcluster.ManagedClusterClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "managedcluster.ManagedClusterClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c ManagedClusterClient) CreateOrUpdateThenPoll(ctx context.Context, id ManagedClusterId, input ManagedCluster) 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 ManagedClusterClient) preparerForCreateOrUpdate(ctx context.Context, id ManagedClusterId, input ManagedCluster) (*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 ManagedClusterClient) 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/servicefabricmanagedcluster/2021-05-01/managedcluster/method_delete.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/method_delete.go new file mode 100644 index 00000000000..dbcea342a30 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/method_delete.go @@ -0,0 +1,71 @@ +package managedcluster + +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 ManagedClusterClient) Delete(ctx context.Context, id ManagedClusterId) (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 ManagedClusterClient) DeleteThenPoll(ctx context.Context, id ManagedClusterId) 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/servicefabricmanagedcluster/2021-05-01/managedcluster/method_delete_autorest.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/method_delete_autorest.go deleted file mode 100644 index 68b47184164..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/method_delete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package managedcluster - -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 ManagedClusterClient) Delete(ctx context.Context, id ManagedClusterId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "managedcluster.ManagedClusterClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "managedcluster.ManagedClusterClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c ManagedClusterClient) DeleteThenPoll(ctx context.Context, id ManagedClusterId) 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 ManagedClusterClient) preparerForDelete(ctx context.Context, id ManagedClusterId) (*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 ManagedClusterClient) 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/servicefabricmanagedcluster/2021-05-01/managedcluster/method_get.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/method_get.go new file mode 100644 index 00000000000..069bb644f25 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/method_get.go @@ -0,0 +1,51 @@ +package managedcluster + +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 *ManagedCluster +} + +// Get ... +func (c ManagedClusterClient) Get(ctx context.Context, id ManagedClusterId) (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/servicefabricmanagedcluster/2021-05-01/managedcluster/method_get_autorest.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/method_get_autorest.go deleted file mode 100644 index e81b8d3b20b..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package managedcluster - -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 *ManagedCluster -} - -// Get ... -func (c ManagedClusterClient) Get(ctx context.Context, id ManagedClusterId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "managedcluster.ManagedClusterClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedcluster.ManagedClusterClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedcluster.ManagedClusterClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ManagedClusterClient) preparerForGet(ctx context.Context, id ManagedClusterId) (*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 ManagedClusterClient) 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/servicefabricmanagedcluster/2021-05-01/managedcluster/method_listbyresourcegroup.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/method_listbyresourcegroup.go new file mode 100644 index 00000000000..6fc2ff33bb8 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/method_listbyresourcegroup.go @@ -0,0 +1,92 @@ +package managedcluster + +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 *[]ManagedCluster +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []ManagedCluster +} + +// ListByResourceGroup ... +func (c ManagedClusterClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.ServiceFabric/managedClusters", 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 *[]ManagedCluster `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 ManagedClusterClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ManagedClusterOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagedClusterClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ManagedClusterOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]ManagedCluster, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/method_listbyresourcegroup_autorest.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/method_listbyresourcegroup_autorest.go deleted file mode 100644 index aa3e398b648..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/method_listbyresourcegroup_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package managedcluster - -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 *[]ManagedCluster - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByResourceGroupOperationResponse, error) -} - -type ListByResourceGroupCompleteResult struct { - Items []ManagedCluster -} - -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) -} - -// ListByResourceGroup ... -func (c ManagedClusterClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (resp ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroup(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "managedcluster.ManagedClusterClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedcluster.ManagedClusterClient", "ListByResourceGroup", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByResourceGroup(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedcluster.ManagedClusterClient", "ListByResourceGroup", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByResourceGroup prepares the ListByResourceGroup request. -func (c ManagedClusterClient) preparerForListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (*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.ServiceFabric/managedClusters", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByResourceGroupWithNextLink prepares the ListByResourceGroup request with the given nextLink token. -func (c ManagedClusterClient) 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 ManagedClusterClient) responderForListByResourceGroup(resp *http.Response) (result ListByResourceGroupOperationResponse, err error) { - type page struct { - Values []ManagedCluster `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, "managedcluster.ManagedClusterClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedcluster.ManagedClusterClient", "ListByResourceGroup", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByResourceGroup(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedcluster.ManagedClusterClient", "ListByResourceGroup", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByResourceGroupComplete retrieves all of the results into a single object -func (c ManagedClusterClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { - return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ManagedClusterOperationPredicate{}) -} - -// ListByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ManagedClusterClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ManagedClusterOperationPredicate) (resp ListByResourceGroupCompleteResult, err error) { - items := make([]ManagedCluster, 0) - - page, err := c.ListByResourceGroup(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 := ListByResourceGroupCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/method_listbysubscription.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/method_listbysubscription.go new file mode 100644 index 00000000000..dff76cbe716 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/method_listbysubscription.go @@ -0,0 +1,92 @@ +package managedcluster + +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 *[]ManagedCluster +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []ManagedCluster +} + +// ListBySubscription ... +func (c ManagedClusterClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.ServiceFabric/managedClusters", 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 *[]ManagedCluster `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 ManagedClusterClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, ManagedClusterOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagedClusterClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ManagedClusterOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]ManagedCluster, 0) + + resp, err := c.ListBySubscription(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 = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/method_listbysubscription_autorest.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/method_listbysubscription_autorest.go deleted file mode 100644 index 42722389796..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/method_listbysubscription_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package managedcluster - -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 *[]ManagedCluster - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListBySubscriptionOperationResponse, error) -} - -type ListBySubscriptionCompleteResult struct { - Items []ManagedCluster -} - -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) -} - -// ListBySubscription ... -func (c ManagedClusterClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (resp ListBySubscriptionOperationResponse, err error) { - req, err := c.preparerForListBySubscription(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "managedcluster.ManagedClusterClient", "ListBySubscription", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedcluster.ManagedClusterClient", "ListBySubscription", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListBySubscription(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedcluster.ManagedClusterClient", "ListBySubscription", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListBySubscription prepares the ListBySubscription request. -func (c ManagedClusterClient) preparerForListBySubscription(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.ServiceFabric/managedClusters", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListBySubscriptionWithNextLink prepares the ListBySubscription request with the given nextLink token. -func (c ManagedClusterClient) 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 ManagedClusterClient) responderForListBySubscription(resp *http.Response) (result ListBySubscriptionOperationResponse, err error) { - type page struct { - Values []ManagedCluster `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, "managedcluster.ManagedClusterClient", "ListBySubscription", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedcluster.ManagedClusterClient", "ListBySubscription", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListBySubscription(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedcluster.ManagedClusterClient", "ListBySubscription", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListBySubscriptionComplete retrieves all of the results into a single object -func (c ManagedClusterClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { - return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, ManagedClusterOperationPredicate{}) -} - -// ListBySubscriptionCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ManagedClusterClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ManagedClusterOperationPredicate) (resp ListBySubscriptionCompleteResult, err error) { - items := make([]ManagedCluster, 0) - - page, err := c.ListBySubscription(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 := ListBySubscriptionCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/method_update.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/method_update.go new file mode 100644 index 00000000000..bc6e02baad9 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/method_update.go @@ -0,0 +1,55 @@ +package managedcluster + +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 *ManagedCluster +} + +// Update ... +func (c ManagedClusterClient) Update(ctx context.Context, id ManagedClusterId, input ManagedClusterUpdateParameters) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/method_update_autorest.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/method_update_autorest.go deleted file mode 100644 index c11f0beae5b..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster/method_update_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package managedcluster - -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 *ManagedCluster -} - -// Update ... -func (c ManagedClusterClient) Update(ctx context.Context, id ManagedClusterId, input ManagedClusterUpdateParameters) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "managedcluster.ManagedClusterClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedcluster.ManagedClusterClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedcluster.ManagedClusterClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c ManagedClusterClient) preparerForUpdate(ctx context.Context, id ManagedClusterId, input ManagedClusterUpdateParameters) (*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 ManagedClusterClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, 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/servicefabricmanagedcluster/2021-05-01/managedclusterversion/client.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/managedclusterversion/client.go index 588c6e6c83f..4221e0cb422 100644 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/managedclusterversion/client.go +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/managedclusterversion/client.go @@ -1,18 +1,26 @@ package managedclusterversion -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 ManagedClusterVersionClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewManagedClusterVersionClientWithBaseURI(endpoint string) ManagedClusterVersionClient { - return ManagedClusterVersionClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewManagedClusterVersionClientWithBaseURI(sdkApi sdkEnv.Api) (*ManagedClusterVersionClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "managedclusterversion", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ManagedClusterVersionClient: %+v", err) } + + return &ManagedClusterVersionClient{ + Client: client, + }, nil } diff --git a/resource-manager/servicefabricmanagedcluster/2021-05-01/managedclusterversion/constants.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/managedclusterversion/constants.go index 3f51fb9fc75..63f05d5112a 100644 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/managedclusterversion/constants.go +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/managedclusterversion/constants.go @@ -1,6 +1,10 @@ package managedclusterversion -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 PossibleValuesForOsType() []string { } } +func (s *OsType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOsType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseOsType(input string) (*OsType, error) { vals := map[string]OsType{ "windows": OsTypeWindows, diff --git a/resource-manager/servicefabricmanagedcluster/2021-05-01/managedclusterversion/method_get.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/managedclusterversion/method_get.go new file mode 100644 index 00000000000..5d7cbe8f7eb --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/managedclusterversion/method_get.go @@ -0,0 +1,51 @@ +package managedclusterversion + +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 *ManagedClusterCodeVersionResult +} + +// Get ... +func (c ManagedClusterVersionClient) Get(ctx context.Context, id ManagedClusterVersionId) (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/servicefabricmanagedcluster/2021-05-01/managedclusterversion/method_get_autorest.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/managedclusterversion/method_get_autorest.go deleted file mode 100644 index 0ab5a0a03a3..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/managedclusterversion/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package managedclusterversion - -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 *ManagedClusterCodeVersionResult -} - -// Get ... -func (c ManagedClusterVersionClient) Get(ctx context.Context, id ManagedClusterVersionId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "managedclusterversion.ManagedClusterVersionClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedclusterversion.ManagedClusterVersionClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedclusterversion.ManagedClusterVersionClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ManagedClusterVersionClient) preparerForGet(ctx context.Context, id ManagedClusterVersionId) (*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 ManagedClusterVersionClient) 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/servicefabricmanagedcluster/2021-05-01/managedclusterversion/method_getbyenvironment.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/managedclusterversion/method_getbyenvironment.go new file mode 100644 index 00000000000..82512ee14ea --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/managedclusterversion/method_getbyenvironment.go @@ -0,0 +1,51 @@ +package managedclusterversion + +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 GetByEnvironmentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ManagedClusterCodeVersionResult +} + +// GetByEnvironment ... +func (c ManagedClusterVersionClient) GetByEnvironment(ctx context.Context, id EnvironmentManagedClusterVersionId) (result GetByEnvironmentOperationResponse, 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/servicefabricmanagedcluster/2021-05-01/managedclusterversion/method_getbyenvironment_autorest.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/managedclusterversion/method_getbyenvironment_autorest.go deleted file mode 100644 index cb8bf5c72c0..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/managedclusterversion/method_getbyenvironment_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package managedclusterversion - -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 GetByEnvironmentOperationResponse struct { - HttpResponse *http.Response - Model *ManagedClusterCodeVersionResult -} - -// GetByEnvironment ... -func (c ManagedClusterVersionClient) GetByEnvironment(ctx context.Context, id EnvironmentManagedClusterVersionId) (result GetByEnvironmentOperationResponse, err error) { - req, err := c.preparerForGetByEnvironment(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "managedclusterversion.ManagedClusterVersionClient", "GetByEnvironment", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedclusterversion.ManagedClusterVersionClient", "GetByEnvironment", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetByEnvironment(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedclusterversion.ManagedClusterVersionClient", "GetByEnvironment", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetByEnvironment prepares the GetByEnvironment request. -func (c ManagedClusterVersionClient) preparerForGetByEnvironment(ctx context.Context, id EnvironmentManagedClusterVersionId) (*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)) -} - -// responderForGetByEnvironment handles the response to the GetByEnvironment request. The method always -// closes the http.Response Body. -func (c ManagedClusterVersionClient) responderForGetByEnvironment(resp *http.Response) (result GetByEnvironmentOperationResponse, 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/servicefabricmanagedcluster/2021-05-01/managedclusterversion/method_list.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/managedclusterversion/method_list.go new file mode 100644 index 00000000000..6de29d2f9ed --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/managedclusterversion/method_list.go @@ -0,0 +1,52 @@ +package managedclusterversion + +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 *[]ManagedClusterCodeVersionResult +} + +// List ... +func (c ManagedClusterVersionClient) List(ctx context.Context, id LocationId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/managedClusterVersions", 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/servicefabricmanagedcluster/2021-05-01/managedclusterversion/method_list_autorest.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/managedclusterversion/method_list_autorest.go deleted file mode 100644 index ab4f2569aec..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/managedclusterversion/method_list_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package managedclusterversion - -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 ListOperationResponse struct { - HttpResponse *http.Response - Model *[]ManagedClusterCodeVersionResult -} - -// List ... -func (c ManagedClusterVersionClient) List(ctx context.Context, id LocationId) (result ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "managedclusterversion.ManagedClusterVersionClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedclusterversion.ManagedClusterVersionClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedclusterversion.ManagedClusterVersionClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForList prepares the List request. -func (c ManagedClusterVersionClient) preparerForList(ctx context.Context, id LocationId) (*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/managedClusterVersions", id.ID())), - 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 ManagedClusterVersionClient) responderForList(resp *http.Response) (result ListOperationResponse, 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/servicefabricmanagedcluster/2021-05-01/managedclusterversion/method_listbyenvironment.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/managedclusterversion/method_listbyenvironment.go new file mode 100644 index 00000000000..8650aa75c59 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/managedclusterversion/method_listbyenvironment.go @@ -0,0 +1,52 @@ +package managedclusterversion + +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 ListByEnvironmentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ManagedClusterCodeVersionResult +} + +// ListByEnvironment ... +func (c ManagedClusterVersionClient) ListByEnvironment(ctx context.Context, id LocationId) (result ListByEnvironmentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/environments/Windows/managedClusterVersions", 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/servicefabricmanagedcluster/2021-05-01/managedclusterversion/method_listbyenvironment_autorest.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/managedclusterversion/method_listbyenvironment_autorest.go deleted file mode 100644 index 0bba3740976..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/managedclusterversion/method_listbyenvironment_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package managedclusterversion - -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 ListByEnvironmentOperationResponse struct { - HttpResponse *http.Response - Model *[]ManagedClusterCodeVersionResult -} - -// ListByEnvironment ... -func (c ManagedClusterVersionClient) ListByEnvironment(ctx context.Context, id LocationId) (result ListByEnvironmentOperationResponse, err error) { - req, err := c.preparerForListByEnvironment(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "managedclusterversion.ManagedClusterVersionClient", "ListByEnvironment", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedclusterversion.ManagedClusterVersionClient", "ListByEnvironment", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByEnvironment(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedclusterversion.ManagedClusterVersionClient", "ListByEnvironment", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByEnvironment prepares the ListByEnvironment request. -func (c ManagedClusterVersionClient) preparerForListByEnvironment(ctx context.Context, id LocationId) (*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/environments/Windows/managedClusterVersions", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByEnvironment handles the response to the ListByEnvironment request. The method always -// closes the http.Response Body. -func (c ManagedClusterVersionClient) responderForListByEnvironment(resp *http.Response) (result ListByEnvironmentOperationResponse, 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/servicefabricmanagedcluster/2021-05-01/nodetype/client.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/client.go index ed9d423c3ce..ae6880601d4 100644 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/client.go +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/client.go @@ -1,18 +1,26 @@ package nodetype -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 NodeTypeClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewNodeTypeClientWithBaseURI(endpoint string) NodeTypeClient { - return NodeTypeClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewNodeTypeClientWithBaseURI(sdkApi sdkEnv.Api) (*NodeTypeClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "nodetype", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NodeTypeClient: %+v", err) } + + return &NodeTypeClient{ + Client: client, + }, nil } diff --git a/resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/constants.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/constants.go index 4f842369e30..a9c06fb6e56 100644 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/constants.go +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/constants.go @@ -1,6 +1,10 @@ package nodetype -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 PossibleValuesForDiskType() []string { } } +func (s *DiskType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDiskType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseDiskType(input string) (*DiskType, error) { vals := map[string]DiskType{ "premium_lrs": DiskTypePremiumLRS, @@ -66,6 +83,19 @@ func PossibleValuesForManagedResourceProvisioningState() []string { } } +func (s *ManagedResourceProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedResourceProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseManagedResourceProvisioningState(input string) (*ManagedResourceProvisioningState, error) { vals := map[string]ManagedResourceProvisioningState{ "canceled": ManagedResourceProvisioningStateCanceled, diff --git a/resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_createorupdate.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_createorupdate.go new file mode 100644 index 00000000000..fa299533273 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_createorupdate.go @@ -0,0 +1,75 @@ +package nodetype + +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 *NodeType +} + +// CreateOrUpdate ... +func (c NodeTypeClient) CreateOrUpdate(ctx context.Context, id NodeTypeId, input NodeType) (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 + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c NodeTypeClient) CreateOrUpdateThenPoll(ctx context.Context, id NodeTypeId, input NodeType) 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/servicefabricmanagedcluster/2021-05-01/nodetype/method_createorupdate_autorest.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_createorupdate_autorest.go deleted file mode 100644 index f4304fb3e74..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_createorupdate_autorest.go +++ /dev/null @@ -1,80 +0,0 @@ -package nodetype - -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 *NodeType -} - -// CreateOrUpdate ... -func (c NodeTypeClient) CreateOrUpdate(ctx context.Context, id NodeTypeId, input NodeType) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c NodeTypeClient) CreateOrUpdateThenPoll(ctx context.Context, id NodeTypeId, input NodeType) 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 NodeTypeClient) preparerForCreateOrUpdate(ctx context.Context, id NodeTypeId, input NodeType) (*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 NodeTypeClient) 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/servicefabricmanagedcluster/2021-05-01/nodetype/method_delete.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_delete.go new file mode 100644 index 00000000000..028e962d71f --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_delete.go @@ -0,0 +1,71 @@ +package nodetype + +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 NodeTypeClient) Delete(ctx context.Context, id NodeTypeId) (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 NodeTypeClient) DeleteThenPoll(ctx context.Context, id NodeTypeId) 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/servicefabricmanagedcluster/2021-05-01/nodetype/method_delete_autorest.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_delete_autorest.go deleted file mode 100644 index 557f0a902b0..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_delete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package nodetype - -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 NodeTypeClient) Delete(ctx context.Context, id NodeTypeId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c NodeTypeClient) DeleteThenPoll(ctx context.Context, id NodeTypeId) 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 NodeTypeClient) preparerForDelete(ctx context.Context, id NodeTypeId) (*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 NodeTypeClient) 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/servicefabricmanagedcluster/2021-05-01/nodetype/method_deletenode.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_deletenode.go new file mode 100644 index 00000000000..803466d737e --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_deletenode.go @@ -0,0 +1,74 @@ +package nodetype + +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 DeleteNodeOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteNode ... +func (c NodeTypeClient) DeleteNode(ctx context.Context, id NodeTypeId, input NodeTypeActionParameters) (result DeleteNodeOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/deleteNode", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteNodeThenPoll performs DeleteNode then polls until it's completed +func (c NodeTypeClient) DeleteNodeThenPoll(ctx context.Context, id NodeTypeId, input NodeTypeActionParameters) error { + result, err := c.DeleteNode(ctx, id, input) + if err != nil { + return fmt.Errorf("performing DeleteNode: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DeleteNode: %+v", err) + } + + return nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_deletenode_autorest.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_deletenode_autorest.go deleted file mode 100644 index b49d2f9e6d7..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_deletenode_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package nodetype - -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 DeleteNodeOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// DeleteNode ... -func (c NodeTypeClient) DeleteNode(ctx context.Context, id NodeTypeId, input NodeTypeActionParameters) (result DeleteNodeOperationResponse, err error) { - req, err := c.preparerForDeleteNode(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "DeleteNode", nil, "Failure preparing request") - return - } - - result, err = c.senderForDeleteNode(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "DeleteNode", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteNodeThenPoll performs DeleteNode then polls until it's completed -func (c NodeTypeClient) DeleteNodeThenPoll(ctx context.Context, id NodeTypeId, input NodeTypeActionParameters) error { - result, err := c.DeleteNode(ctx, id, input) - if err != nil { - return fmt.Errorf("performing DeleteNode: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after DeleteNode: %+v", err) - } - - return nil -} - -// preparerForDeleteNode prepares the DeleteNode request. -func (c NodeTypeClient) preparerForDeleteNode(ctx context.Context, id NodeTypeId, input NodeTypeActionParameters) (*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/deleteNode", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDeleteNode sends the DeleteNode request. The method will close the -// http.Response Body if it receives an error. -func (c NodeTypeClient) senderForDeleteNode(ctx context.Context, req *http.Request) (future DeleteNodeOperationResponse, 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/servicefabricmanagedcluster/2021-05-01/nodetype/method_get.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_get.go new file mode 100644 index 00000000000..62795c33904 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_get.go @@ -0,0 +1,51 @@ +package nodetype + +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 *NodeType +} + +// Get ... +func (c NodeTypeClient) Get(ctx context.Context, id NodeTypeId) (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/servicefabricmanagedcluster/2021-05-01/nodetype/method_get_autorest.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_get_autorest.go deleted file mode 100644 index f862c9383f8..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package nodetype - -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 *NodeType -} - -// Get ... -func (c NodeTypeClient) Get(ctx context.Context, id NodeTypeId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c NodeTypeClient) preparerForGet(ctx context.Context, id NodeTypeId) (*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 NodeTypeClient) 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/servicefabricmanagedcluster/2021-05-01/nodetype/method_listbymanagedclusters.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_listbymanagedclusters.go new file mode 100644 index 00000000000..1fb6fa2611f --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_listbymanagedclusters.go @@ -0,0 +1,91 @@ +package nodetype + +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 ListByManagedClustersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NodeType +} + +type ListByManagedClustersCompleteResult struct { + LatestHttpResponse *http.Response + Items []NodeType +} + +// ListByManagedClusters ... +func (c NodeTypeClient) ListByManagedClusters(ctx context.Context, id ManagedClusterId) (result ListByManagedClustersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/nodeTypes", 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 *[]NodeType `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByManagedClustersComplete retrieves all the results into a single object +func (c NodeTypeClient) ListByManagedClustersComplete(ctx context.Context, id ManagedClusterId) (ListByManagedClustersCompleteResult, error) { + return c.ListByManagedClustersCompleteMatchingPredicate(ctx, id, NodeTypeOperationPredicate{}) +} + +// ListByManagedClustersCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NodeTypeClient) ListByManagedClustersCompleteMatchingPredicate(ctx context.Context, id ManagedClusterId, predicate NodeTypeOperationPredicate) (result ListByManagedClustersCompleteResult, err error) { + items := make([]NodeType, 0) + + resp, err := c.ListByManagedClusters(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 = ListByManagedClustersCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_listbymanagedclusters_autorest.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_listbymanagedclusters_autorest.go deleted file mode 100644 index 6c118c65367..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_listbymanagedclusters_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package nodetype - -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 ListByManagedClustersOperationResponse struct { - HttpResponse *http.Response - Model *[]NodeType - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByManagedClustersOperationResponse, error) -} - -type ListByManagedClustersCompleteResult struct { - Items []NodeType -} - -func (r ListByManagedClustersOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByManagedClustersOperationResponse) LoadMore(ctx context.Context) (resp ListByManagedClustersOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByManagedClusters ... -func (c NodeTypeClient) ListByManagedClusters(ctx context.Context, id ManagedClusterId) (resp ListByManagedClustersOperationResponse, err error) { - req, err := c.preparerForListByManagedClusters(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "ListByManagedClusters", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "ListByManagedClusters", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByManagedClusters(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "ListByManagedClusters", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByManagedClusters prepares the ListByManagedClusters request. -func (c NodeTypeClient) preparerForListByManagedClusters(ctx context.Context, id ManagedClusterId) (*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/nodeTypes", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByManagedClustersWithNextLink prepares the ListByManagedClusters request with the given nextLink token. -func (c NodeTypeClient) preparerForListByManagedClustersWithNextLink(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)) -} - -// responderForListByManagedClusters handles the response to the ListByManagedClusters request. The method always -// closes the http.Response Body. -func (c NodeTypeClient) responderForListByManagedClusters(resp *http.Response) (result ListByManagedClustersOperationResponse, err error) { - type page struct { - Values []NodeType `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 ListByManagedClustersOperationResponse, err error) { - req, err := c.preparerForListByManagedClustersWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "ListByManagedClusters", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "ListByManagedClusters", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByManagedClusters(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "ListByManagedClusters", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByManagedClustersComplete retrieves all of the results into a single object -func (c NodeTypeClient) ListByManagedClustersComplete(ctx context.Context, id ManagedClusterId) (ListByManagedClustersCompleteResult, error) { - return c.ListByManagedClustersCompleteMatchingPredicate(ctx, id, NodeTypeOperationPredicate{}) -} - -// ListByManagedClustersCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c NodeTypeClient) ListByManagedClustersCompleteMatchingPredicate(ctx context.Context, id ManagedClusterId, predicate NodeTypeOperationPredicate) (resp ListByManagedClustersCompleteResult, err error) { - items := make([]NodeType, 0) - - page, err := c.ListByManagedClusters(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 := ListByManagedClustersCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_reimage.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_reimage.go new file mode 100644 index 00000000000..00358aaa9f5 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_reimage.go @@ -0,0 +1,74 @@ +package nodetype + +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 ReimageOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Reimage ... +func (c NodeTypeClient) Reimage(ctx context.Context, id NodeTypeId, input NodeTypeActionParameters) (result ReimageOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/reimage", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ReimageThenPoll performs Reimage then polls until it's completed +func (c NodeTypeClient) ReimageThenPoll(ctx context.Context, id NodeTypeId, input NodeTypeActionParameters) error { + result, err := c.Reimage(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Reimage: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Reimage: %+v", err) + } + + return nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_reimage_autorest.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_reimage_autorest.go deleted file mode 100644 index 63939de7f6b..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_reimage_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package nodetype - -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 ReimageOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Reimage ... -func (c NodeTypeClient) Reimage(ctx context.Context, id NodeTypeId, input NodeTypeActionParameters) (result ReimageOperationResponse, err error) { - req, err := c.preparerForReimage(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "Reimage", nil, "Failure preparing request") - return - } - - result, err = c.senderForReimage(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "Reimage", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// ReimageThenPoll performs Reimage then polls until it's completed -func (c NodeTypeClient) ReimageThenPoll(ctx context.Context, id NodeTypeId, input NodeTypeActionParameters) error { - result, err := c.Reimage(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Reimage: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Reimage: %+v", err) - } - - return nil -} - -// preparerForReimage prepares the Reimage request. -func (c NodeTypeClient) preparerForReimage(ctx context.Context, id NodeTypeId, input NodeTypeActionParameters) (*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/reimage", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForReimage sends the Reimage request. The method will close the -// http.Response Body if it receives an error. -func (c NodeTypeClient) senderForReimage(ctx context.Context, req *http.Request) (future ReimageOperationResponse, 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/servicefabricmanagedcluster/2021-05-01/nodetype/method_restart.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_restart.go new file mode 100644 index 00000000000..69322966ede --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_restart.go @@ -0,0 +1,74 @@ +package nodetype + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestartOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Restart ... +func (c NodeTypeClient) Restart(ctx context.Context, id NodeTypeId, input NodeTypeActionParameters) (result RestartOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restart", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RestartThenPoll performs Restart then polls until it's completed +func (c NodeTypeClient) RestartThenPoll(ctx context.Context, id NodeTypeId, input NodeTypeActionParameters) error { + result, err := c.Restart(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Restart: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Restart: %+v", err) + } + + return nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_restart_autorest.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_restart_autorest.go deleted file mode 100644 index 1eb428135ea..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_restart_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package nodetype - -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 RestartOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Restart ... -func (c NodeTypeClient) Restart(ctx context.Context, id NodeTypeId, input NodeTypeActionParameters) (result RestartOperationResponse, err error) { - req, err := c.preparerForRestart(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "Restart", nil, "Failure preparing request") - return - } - - result, err = c.senderForRestart(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "Restart", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// RestartThenPoll performs Restart then polls until it's completed -func (c NodeTypeClient) RestartThenPoll(ctx context.Context, id NodeTypeId, input NodeTypeActionParameters) error { - result, err := c.Restart(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Restart: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Restart: %+v", err) - } - - return nil -} - -// preparerForRestart prepares the Restart request. -func (c NodeTypeClient) preparerForRestart(ctx context.Context, id NodeTypeId, input NodeTypeActionParameters) (*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/restart", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForRestart sends the Restart request. The method will close the -// http.Response Body if it receives an error. -func (c NodeTypeClient) senderForRestart(ctx context.Context, req *http.Request) (future RestartOperationResponse, 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/servicefabricmanagedcluster/2021-05-01/nodetype/method_update.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_update.go new file mode 100644 index 00000000000..775598419e6 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_update.go @@ -0,0 +1,55 @@ +package nodetype + +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 *NodeType +} + +// Update ... +func (c NodeTypeClient) Update(ctx context.Context, id NodeTypeId, input NodeTypeUpdateParameters) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_update_autorest.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_update_autorest.go deleted file mode 100644 index a0f77c73908..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype/method_update_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package nodetype - -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 *NodeType -} - -// Update ... -func (c NodeTypeClient) Update(ctx context.Context, id NodeTypeId, input NodeTypeUpdateParameters) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c NodeTypeClient) preparerForUpdate(ctx context.Context, id NodeTypeId, input NodeTypeUpdateParameters) (*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 NodeTypeClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, 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/servicefabricmanagedcluster/2021-05-01/service/client.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/service/client.go index c0efa2f4308..d0e66ae6f3f 100644 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/service/client.go +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/service/client.go @@ -1,18 +1,26 @@ package service -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 ServiceClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewServiceClientWithBaseURI(endpoint string) ServiceClient { - return ServiceClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewServiceClientWithBaseURI(sdkApi sdkEnv.Api) (*ServiceClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "service", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ServiceClient: %+v", err) } + + return &ServiceClient{ + Client: client, + }, nil } diff --git a/resource-manager/servicefabricmanagedcluster/2021-05-01/service/constants.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/service/constants.go index acce11bd23b..d11316457d1 100644 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/service/constants.go +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/service/constants.go @@ -1,6 +1,10 @@ package service -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 PossibleValuesForMoveCost() []string { } } +func (s *MoveCost) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMoveCost(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseMoveCost(input string) (*MoveCost, error) { vals := map[string]MoveCost{ "high": MoveCostHigh, @@ -55,6 +72,19 @@ func PossibleValuesForPartitionScheme() []string { } } +func (s *PartitionScheme) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePartitionScheme(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePartitionScheme(input string) (*PartitionScheme, error) { vals := map[string]PartitionScheme{ "named": PartitionSchemeNamed, @@ -84,6 +114,19 @@ func PossibleValuesForServiceCorrelationScheme() []string { } } +func (s *ServiceCorrelationScheme) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceCorrelationScheme(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseServiceCorrelationScheme(input string) (*ServiceCorrelationScheme, error) { vals := map[string]ServiceCorrelationScheme{ "alignedaffinity": ServiceCorrelationSchemeAlignedAffinity, @@ -112,6 +155,19 @@ func PossibleValuesForServiceKind() []string { } } +func (s *ServiceKind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseServiceKind(input string) (*ServiceKind, error) { vals := map[string]ServiceKind{ "stateful": ServiceKindStateful, @@ -144,6 +200,19 @@ func PossibleValuesForServiceLoadMetricWeight() []string { } } +func (s *ServiceLoadMetricWeight) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceLoadMetricWeight(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseServiceLoadMetricWeight(input string) (*ServiceLoadMetricWeight, error) { vals := map[string]ServiceLoadMetricWeight{ "high": ServiceLoadMetricWeightHigh, @@ -174,6 +243,19 @@ func PossibleValuesForServicePackageActivationMode() []string { } } +func (s *ServicePackageActivationMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServicePackageActivationMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseServicePackageActivationMode(input string) (*ServicePackageActivationMode, error) { vals := map[string]ServicePackageActivationMode{ "exclusiveprocess": ServicePackageActivationModeExclusiveProcess, @@ -208,6 +290,19 @@ func PossibleValuesForServicePlacementPolicyType() []string { } } +func (s *ServicePlacementPolicyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServicePlacementPolicyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseServicePlacementPolicyType(input string) (*ServicePlacementPolicyType, error) { vals := map[string]ServicePlacementPolicyType{ "invaliddomain": ServicePlacementPolicyTypeInvalidDomain, @@ -239,6 +334,19 @@ func PossibleValuesForServiceScalingMechanismKind() []string { } } +func (s *ServiceScalingMechanismKind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceScalingMechanismKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseServiceScalingMechanismKind(input string) (*ServiceScalingMechanismKind, error) { vals := map[string]ServiceScalingMechanismKind{ "addremoveincrementalnamedpartition": ServiceScalingMechanismKindAddRemoveIncrementalNamedPartition, @@ -267,6 +375,19 @@ func PossibleValuesForServiceScalingTriggerKind() []string { } } +func (s *ServiceScalingTriggerKind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceScalingTriggerKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseServiceScalingTriggerKind(input string) (*ServiceScalingTriggerKind, error) { vals := map[string]ServiceScalingTriggerKind{ "averagepartitionload": ServiceScalingTriggerKindAveragePartitionLoad, diff --git a/resource-manager/servicefabricmanagedcluster/2021-05-01/service/method_createorupdate.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/service/method_createorupdate.go new file mode 100644 index 00000000000..1c2db415434 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/service/method_createorupdate.go @@ -0,0 +1,75 @@ +package service + +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 *ServiceResource +} + +// CreateOrUpdate ... +func (c ServiceClient) CreateOrUpdate(ctx context.Context, id ServiceId, input ServiceResource) (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 + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c ServiceClient) CreateOrUpdateThenPoll(ctx context.Context, id ServiceId, input ServiceResource) 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/servicefabricmanagedcluster/2021-05-01/service/method_createorupdate_autorest.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/service/method_createorupdate_autorest.go deleted file mode 100644 index aa68ed59851..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/service/method_createorupdate_autorest.go +++ /dev/null @@ -1,80 +0,0 @@ -package service - -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 *ServiceResource -} - -// CreateOrUpdate ... -func (c ServiceClient) CreateOrUpdate(ctx context.Context, id ServiceId, input ServiceResource) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "service.ServiceClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "service.ServiceClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c ServiceClient) CreateOrUpdateThenPoll(ctx context.Context, id ServiceId, input ServiceResource) 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 ServiceClient) preparerForCreateOrUpdate(ctx context.Context, id ServiceId, input ServiceResource) (*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 ServiceClient) 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/servicefabricmanagedcluster/2021-05-01/service/method_delete.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/service/method_delete.go new file mode 100644 index 00000000000..92913350903 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/service/method_delete.go @@ -0,0 +1,71 @@ +package service + +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 ServiceClient) Delete(ctx context.Context, id ServiceId) (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 ServiceClient) DeleteThenPoll(ctx context.Context, id ServiceId) 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/servicefabricmanagedcluster/2021-05-01/service/method_delete_autorest.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/service/method_delete_autorest.go deleted file mode 100644 index d7941cd7187..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/service/method_delete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package service - -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 ServiceClient) Delete(ctx context.Context, id ServiceId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "service.ServiceClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "service.ServiceClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c ServiceClient) DeleteThenPoll(ctx context.Context, id ServiceId) 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 ServiceClient) preparerForDelete(ctx context.Context, id ServiceId) (*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 ServiceClient) 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/servicefabricmanagedcluster/2021-05-01/service/method_get.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/service/method_get.go new file mode 100644 index 00000000000..84c16fc430d --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/service/method_get.go @@ -0,0 +1,51 @@ +package service + +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 *ServiceResource +} + +// Get ... +func (c ServiceClient) Get(ctx context.Context, id ServiceId) (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/servicefabricmanagedcluster/2021-05-01/service/method_get_autorest.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/service/method_get_autorest.go deleted file mode 100644 index ab97a39a19f..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/service/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package service - -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 *ServiceResource -} - -// Get ... -func (c ServiceClient) Get(ctx context.Context, id ServiceId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "service.ServiceClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "service.ServiceClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "service.ServiceClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ServiceClient) preparerForGet(ctx context.Context, id ServiceId) (*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 ServiceClient) 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/servicefabricmanagedcluster/2021-05-01/service/method_listbyapplications.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/service/method_listbyapplications.go new file mode 100644 index 00000000000..18aab2aedc2 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/service/method_listbyapplications.go @@ -0,0 +1,91 @@ +package service + +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 ListByApplicationsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ServiceResource +} + +type ListByApplicationsCompleteResult struct { + LatestHttpResponse *http.Response + Items []ServiceResource +} + +// ListByApplications ... +func (c ServiceClient) ListByApplications(ctx context.Context, id ApplicationId) (result ListByApplicationsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/services", 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 *[]ServiceResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByApplicationsComplete retrieves all the results into a single object +func (c ServiceClient) ListByApplicationsComplete(ctx context.Context, id ApplicationId) (ListByApplicationsCompleteResult, error) { + return c.ListByApplicationsCompleteMatchingPredicate(ctx, id, ServiceResourceOperationPredicate{}) +} + +// ListByApplicationsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ServiceClient) ListByApplicationsCompleteMatchingPredicate(ctx context.Context, id ApplicationId, predicate ServiceResourceOperationPredicate) (result ListByApplicationsCompleteResult, err error) { + items := make([]ServiceResource, 0) + + resp, err := c.ListByApplications(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 = ListByApplicationsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2021-05-01/service/method_listbyapplications_autorest.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/service/method_listbyapplications_autorest.go deleted file mode 100644 index b002ae733cd..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/service/method_listbyapplications_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package service - -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 ListByApplicationsOperationResponse struct { - HttpResponse *http.Response - Model *[]ServiceResource - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByApplicationsOperationResponse, error) -} - -type ListByApplicationsCompleteResult struct { - Items []ServiceResource -} - -func (r ListByApplicationsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByApplicationsOperationResponse) LoadMore(ctx context.Context) (resp ListByApplicationsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByApplications ... -func (c ServiceClient) ListByApplications(ctx context.Context, id ApplicationId) (resp ListByApplicationsOperationResponse, err error) { - req, err := c.preparerForListByApplications(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "service.ServiceClient", "ListByApplications", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "service.ServiceClient", "ListByApplications", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByApplications(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "service.ServiceClient", "ListByApplications", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByApplications prepares the ListByApplications request. -func (c ServiceClient) preparerForListByApplications(ctx context.Context, id ApplicationId) (*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/services", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByApplicationsWithNextLink prepares the ListByApplications request with the given nextLink token. -func (c ServiceClient) preparerForListByApplicationsWithNextLink(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)) -} - -// responderForListByApplications handles the response to the ListByApplications request. The method always -// closes the http.Response Body. -func (c ServiceClient) responderForListByApplications(resp *http.Response) (result ListByApplicationsOperationResponse, err error) { - type page struct { - Values []ServiceResource `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 ListByApplicationsOperationResponse, err error) { - req, err := c.preparerForListByApplicationsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "service.ServiceClient", "ListByApplications", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "service.ServiceClient", "ListByApplications", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByApplications(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "service.ServiceClient", "ListByApplications", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByApplicationsComplete retrieves all of the results into a single object -func (c ServiceClient) ListByApplicationsComplete(ctx context.Context, id ApplicationId) (ListByApplicationsCompleteResult, error) { - return c.ListByApplicationsCompleteMatchingPredicate(ctx, id, ServiceResourceOperationPredicate{}) -} - -// ListByApplicationsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ServiceClient) ListByApplicationsCompleteMatchingPredicate(ctx context.Context, id ApplicationId, predicate ServiceResourceOperationPredicate) (resp ListByApplicationsCompleteResult, err error) { - items := make([]ServiceResource, 0) - - page, err := c.ListByApplications(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 := ListByApplicationsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/servicefabricmanagedcluster/2021-05-01/services/client.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/services/client.go index 7195c075b5b..dc4a72c1ff4 100644 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/services/client.go +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/services/client.go @@ -1,18 +1,26 @@ package services -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 ServicesClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewServicesClientWithBaseURI(endpoint string) ServicesClient { - return ServicesClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewServicesClientWithBaseURI(sdkApi sdkEnv.Api) (*ServicesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "services", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ServicesClient: %+v", err) } + + return &ServicesClient{ + Client: client, + }, nil } diff --git a/resource-manager/servicefabricmanagedcluster/2021-05-01/services/constants.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/services/constants.go index 9b475353156..87263432c62 100644 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/services/constants.go +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/services/constants.go @@ -1,6 +1,10 @@ package services -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 PossibleValuesForMoveCost() []string { } } +func (s *MoveCost) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMoveCost(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseMoveCost(input string) (*MoveCost, error) { vals := map[string]MoveCost{ "high": MoveCostHigh, @@ -55,6 +72,19 @@ func PossibleValuesForPartitionScheme() []string { } } +func (s *PartitionScheme) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePartitionScheme(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePartitionScheme(input string) (*PartitionScheme, error) { vals := map[string]PartitionScheme{ "named": PartitionSchemeNamed, @@ -84,6 +114,19 @@ func PossibleValuesForServiceCorrelationScheme() []string { } } +func (s *ServiceCorrelationScheme) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceCorrelationScheme(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseServiceCorrelationScheme(input string) (*ServiceCorrelationScheme, error) { vals := map[string]ServiceCorrelationScheme{ "alignedaffinity": ServiceCorrelationSchemeAlignedAffinity, @@ -112,6 +155,19 @@ func PossibleValuesForServiceKind() []string { } } +func (s *ServiceKind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseServiceKind(input string) (*ServiceKind, error) { vals := map[string]ServiceKind{ "stateful": ServiceKindStateful, @@ -144,6 +200,19 @@ func PossibleValuesForServiceLoadMetricWeight() []string { } } +func (s *ServiceLoadMetricWeight) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceLoadMetricWeight(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseServiceLoadMetricWeight(input string) (*ServiceLoadMetricWeight, error) { vals := map[string]ServiceLoadMetricWeight{ "high": ServiceLoadMetricWeightHigh, @@ -174,6 +243,19 @@ func PossibleValuesForServicePackageActivationMode() []string { } } +func (s *ServicePackageActivationMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServicePackageActivationMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseServicePackageActivationMode(input string) (*ServicePackageActivationMode, error) { vals := map[string]ServicePackageActivationMode{ "exclusiveprocess": ServicePackageActivationModeExclusiveProcess, @@ -208,6 +290,19 @@ func PossibleValuesForServicePlacementPolicyType() []string { } } +func (s *ServicePlacementPolicyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServicePlacementPolicyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseServicePlacementPolicyType(input string) (*ServicePlacementPolicyType, error) { vals := map[string]ServicePlacementPolicyType{ "invaliddomain": ServicePlacementPolicyTypeInvalidDomain, @@ -239,6 +334,19 @@ func PossibleValuesForServiceScalingMechanismKind() []string { } } +func (s *ServiceScalingMechanismKind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceScalingMechanismKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseServiceScalingMechanismKind(input string) (*ServiceScalingMechanismKind, error) { vals := map[string]ServiceScalingMechanismKind{ "addremoveincrementalnamedpartition": ServiceScalingMechanismKindAddRemoveIncrementalNamedPartition, @@ -267,6 +375,19 @@ func PossibleValuesForServiceScalingTriggerKind() []string { } } +func (s *ServiceScalingTriggerKind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceScalingTriggerKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseServiceScalingTriggerKind(input string) (*ServiceScalingTriggerKind, error) { vals := map[string]ServiceScalingTriggerKind{ "averagepartitionload": ServiceScalingTriggerKindAveragePartitionLoad, diff --git a/resource-manager/servicefabricmanagedcluster/2021-05-01/services/method_update.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/services/method_update.go new file mode 100644 index 00000000000..abd5b17eaf8 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2021-05-01/services/method_update.go @@ -0,0 +1,55 @@ +package services + +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 *ServiceResource +} + +// Update ... +func (c ServicesClient) Update(ctx context.Context, id ServiceId, input ServiceUpdateParameters) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2021-05-01/services/method_update_autorest.go b/resource-manager/servicefabricmanagedcluster/2021-05-01/services/method_update_autorest.go deleted file mode 100644 index ee3b44fcd19..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2021-05-01/services/method_update_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package services - -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 *ServiceResource -} - -// Update ... -func (c ServicesClient) Update(ctx context.Context, id ServiceId, input ServiceUpdateParameters) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "services.ServicesClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "services.ServicesClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "services.ServicesClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c ServicesClient) preparerForUpdate(ctx context.Context, id ServiceId, input ServiceUpdateParameters) (*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 ServicesClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, 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/servicefabricmanagedcluster/2022-01-01/application/client.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/application/client.go index 56913082b95..c87320630e0 100644 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/application/client.go +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/application/client.go @@ -1,18 +1,26 @@ package application -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 ApplicationClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewApplicationClientWithBaseURI(endpoint string) ApplicationClient { - return ApplicationClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewApplicationClientWithBaseURI(sdkApi sdkEnv.Api) (*ApplicationClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "application", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApplicationClient: %+v", err) } + + return &ApplicationClient{ + Client: client, + }, nil } diff --git a/resource-manager/servicefabricmanagedcluster/2022-01-01/application/constants.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/application/constants.go index 73c2c5597ed..5456526a734 100644 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/application/constants.go +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/application/constants.go @@ -1,6 +1,10 @@ package application -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. @@ -19,6 +23,19 @@ func PossibleValuesForFailureAction() []string { } } +func (s *FailureAction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFailureAction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseFailureAction(input string) (*FailureAction, error) { vals := map[string]FailureAction{ "manual": FailureActionManual, @@ -47,6 +64,19 @@ func PossibleValuesForRollingUpgradeMode() []string { } } +func (s *RollingUpgradeMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRollingUpgradeMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseRollingUpgradeMode(input string) (*RollingUpgradeMode, error) { vals := map[string]RollingUpgradeMode{ "monitored": RollingUpgradeModeMonitored, diff --git a/resource-manager/servicefabricmanagedcluster/2022-01-01/application/method_createorupdate.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/application/method_createorupdate.go new file mode 100644 index 00000000000..a6c822e721e --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/application/method_createorupdate.go @@ -0,0 +1,75 @@ +package application + +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 *ApplicationResource +} + +// CreateOrUpdate ... +func (c ApplicationClient) CreateOrUpdate(ctx context.Context, id ApplicationId, input ApplicationResource) (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 + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c ApplicationClient) CreateOrUpdateThenPoll(ctx context.Context, id ApplicationId, input ApplicationResource) 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/servicefabricmanagedcluster/2022-01-01/application/method_createorupdate_autorest.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/application/method_createorupdate_autorest.go deleted file mode 100644 index cbf5aa747a2..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/application/method_createorupdate_autorest.go +++ /dev/null @@ -1,80 +0,0 @@ -package application - -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 *ApplicationResource -} - -// CreateOrUpdate ... -func (c ApplicationClient) CreateOrUpdate(ctx context.Context, id ApplicationId, input ApplicationResource) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "application.ApplicationClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "application.ApplicationClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c ApplicationClient) CreateOrUpdateThenPoll(ctx context.Context, id ApplicationId, input ApplicationResource) 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 ApplicationClient) preparerForCreateOrUpdate(ctx context.Context, id ApplicationId, input ApplicationResource) (*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 ApplicationClient) 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/servicefabricmanagedcluster/2022-01-01/application/method_delete.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/application/method_delete.go new file mode 100644 index 00000000000..3770a2d10be --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/application/method_delete.go @@ -0,0 +1,71 @@ +package application + +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 ApplicationClient) Delete(ctx context.Context, id ApplicationId) (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 ApplicationClient) DeleteThenPoll(ctx context.Context, id ApplicationId) 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/servicefabricmanagedcluster/2022-01-01/application/method_delete_autorest.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/application/method_delete_autorest.go deleted file mode 100644 index 1e0ea7f29be..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/application/method_delete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package application - -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 ApplicationClient) Delete(ctx context.Context, id ApplicationId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "application.ApplicationClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "application.ApplicationClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c ApplicationClient) DeleteThenPoll(ctx context.Context, id ApplicationId) 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 ApplicationClient) preparerForDelete(ctx context.Context, id ApplicationId) (*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 ApplicationClient) 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/servicefabricmanagedcluster/2022-01-01/application/method_get.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/application/method_get.go new file mode 100644 index 00000000000..fb8a5955769 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/application/method_get.go @@ -0,0 +1,51 @@ +package application + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApplicationResource +} + +// Get ... +func (c ApplicationClient) Get(ctx context.Context, id ApplicationId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2022-01-01/application/method_get_autorest.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/application/method_get_autorest.go deleted file mode 100644 index 6485d032d8b..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/application/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package application - -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 *ApplicationResource -} - -// Get ... -func (c ApplicationClient) Get(ctx context.Context, id ApplicationId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "application.ApplicationClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "application.ApplicationClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "application.ApplicationClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ApplicationClient) preparerForGet(ctx context.Context, id ApplicationId) (*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 ApplicationClient) 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/servicefabricmanagedcluster/2022-01-01/application/method_list.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/application/method_list.go new file mode 100644 index 00000000000..6749eb898a8 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/application/method_list.go @@ -0,0 +1,91 @@ +package application + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApplicationResource +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ApplicationResource +} + +// List ... +func (c ApplicationClient) List(ctx context.Context, id ManagedClusterId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/applications", id.ID()), + } + + 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 *[]ApplicationResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ApplicationClient) ListComplete(ctx context.Context, id ManagedClusterId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ApplicationResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApplicationClient) ListCompleteMatchingPredicate(ctx context.Context, id ManagedClusterId, predicate ApplicationResourceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ApplicationResource, 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/servicefabricmanagedcluster/2022-01-01/application/method_list_autorest.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/application/method_list_autorest.go deleted file mode 100644 index 27dbde8fd7f..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/application/method_list_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package application - -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 *[]ApplicationResource - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []ApplicationResource -} - -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 ApplicationClient) List(ctx context.Context, id ManagedClusterId) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "application.ApplicationClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "application.ApplicationClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "application.ApplicationClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c ApplicationClient) preparerForList(ctx context.Context, id ManagedClusterId) (*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/applications", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c ApplicationClient) 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 ApplicationClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []ApplicationResource `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, "application.ApplicationClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "application.ApplicationClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "application.ApplicationClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c ApplicationClient) ListComplete(ctx context.Context, id ManagedClusterId) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, ApplicationResourceOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ApplicationClient) ListCompleteMatchingPredicate(ctx context.Context, id ManagedClusterId, predicate ApplicationResourceOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]ApplicationResource, 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/servicefabricmanagedcluster/2022-01-01/application/method_update.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/application/method_update.go new file mode 100644 index 00000000000..ee5837951a9 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/application/method_update.go @@ -0,0 +1,55 @@ +package application + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApplicationResource +} + +// Update ... +func (c ApplicationClient) Update(ctx context.Context, id ApplicationId, input ApplicationUpdateParameters) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2022-01-01/application/method_update_autorest.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/application/method_update_autorest.go deleted file mode 100644 index 6b3955fa828..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/application/method_update_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package application - -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 *ApplicationResource -} - -// Update ... -func (c ApplicationClient) Update(ctx context.Context, id ApplicationId, input ApplicationUpdateParameters) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "application.ApplicationClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "application.ApplicationClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "application.ApplicationClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c ApplicationClient) preparerForUpdate(ctx context.Context, id ApplicationId, input ApplicationUpdateParameters) (*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 ApplicationClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, 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/servicefabricmanagedcluster/2022-01-01/applicationtype/client.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtype/client.go index 0cbef204452..08cc08e353a 100644 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtype/client.go +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtype/client.go @@ -1,18 +1,26 @@ package applicationtype -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 ApplicationTypeClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewApplicationTypeClientWithBaseURI(endpoint string) ApplicationTypeClient { - return ApplicationTypeClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewApplicationTypeClientWithBaseURI(sdkApi sdkEnv.Api) (*ApplicationTypeClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "applicationtype", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApplicationTypeClient: %+v", err) } + + return &ApplicationTypeClient{ + Client: client, + }, nil } diff --git a/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtype/method_createorupdate.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtype/method_createorupdate.go new file mode 100644 index 00000000000..74d5d878bb7 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtype/method_createorupdate.go @@ -0,0 +1,55 @@ +package applicationtype + +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 *ApplicationTypeResource +} + +// CreateOrUpdate ... +func (c ApplicationTypeClient) CreateOrUpdate(ctx context.Context, id ApplicationTypeId, input ApplicationTypeResource) (result CreateOrUpdateOperationResponse, 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/servicefabricmanagedcluster/2022-01-01/applicationtype/method_createorupdate_autorest.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtype/method_createorupdate_autorest.go deleted file mode 100644 index 875e390e5c9..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtype/method_createorupdate_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package applicationtype - -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 *ApplicationTypeResource -} - -// CreateOrUpdate ... -func (c ApplicationTypeClient) CreateOrUpdate(ctx context.Context, id ApplicationTypeId, input ApplicationTypeResource) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtype.ApplicationTypeClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtype.ApplicationTypeClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtype.ApplicationTypeClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c ApplicationTypeClient) preparerForCreateOrUpdate(ctx context.Context, id ApplicationTypeId, input ApplicationTypeResource) (*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 ApplicationTypeClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, 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/servicefabricmanagedcluster/2022-01-01/applicationtype/method_delete.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtype/method_delete.go new file mode 100644 index 00000000000..6842c7382a7 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtype/method_delete.go @@ -0,0 +1,71 @@ +package applicationtype + +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 ApplicationTypeClient) Delete(ctx context.Context, id ApplicationTypeId) (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 ApplicationTypeClient) DeleteThenPoll(ctx context.Context, id ApplicationTypeId) 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/servicefabricmanagedcluster/2022-01-01/applicationtype/method_delete_autorest.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtype/method_delete_autorest.go deleted file mode 100644 index 7105b4caa53..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtype/method_delete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package applicationtype - -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 ApplicationTypeClient) Delete(ctx context.Context, id ApplicationTypeId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtype.ApplicationTypeClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtype.ApplicationTypeClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c ApplicationTypeClient) DeleteThenPoll(ctx context.Context, id ApplicationTypeId) 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 ApplicationTypeClient) preparerForDelete(ctx context.Context, id ApplicationTypeId) (*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 ApplicationTypeClient) 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/servicefabricmanagedcluster/2022-01-01/applicationtype/method_get.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtype/method_get.go new file mode 100644 index 00000000000..22d9d2d9413 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtype/method_get.go @@ -0,0 +1,51 @@ +package applicationtype + +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 *ApplicationTypeResource +} + +// Get ... +func (c ApplicationTypeClient) Get(ctx context.Context, id ApplicationTypeId) (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/servicefabricmanagedcluster/2022-01-01/applicationtype/method_get_autorest.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtype/method_get_autorest.go deleted file mode 100644 index f676fb22170..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtype/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package applicationtype - -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 *ApplicationTypeResource -} - -// Get ... -func (c ApplicationTypeClient) Get(ctx context.Context, id ApplicationTypeId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtype.ApplicationTypeClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtype.ApplicationTypeClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtype.ApplicationTypeClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ApplicationTypeClient) preparerForGet(ctx context.Context, id ApplicationTypeId) (*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 ApplicationTypeClient) 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/servicefabricmanagedcluster/2022-01-01/applicationtype/method_list.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtype/method_list.go new file mode 100644 index 00000000000..57d64fde1a2 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtype/method_list.go @@ -0,0 +1,91 @@ +package applicationtype + +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 *[]ApplicationTypeResource +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ApplicationTypeResource +} + +// List ... +func (c ApplicationTypeClient) List(ctx context.Context, id ManagedClusterId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/applicationTypes", 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 *[]ApplicationTypeResource `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 ApplicationTypeClient) ListComplete(ctx context.Context, id ManagedClusterId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ApplicationTypeResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApplicationTypeClient) ListCompleteMatchingPredicate(ctx context.Context, id ManagedClusterId, predicate ApplicationTypeResourceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ApplicationTypeResource, 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/servicefabricmanagedcluster/2022-01-01/applicationtype/method_list_autorest.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtype/method_list_autorest.go deleted file mode 100644 index dda1c6a8ba2..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtype/method_list_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package applicationtype - -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 *[]ApplicationTypeResource - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []ApplicationTypeResource -} - -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 ApplicationTypeClient) List(ctx context.Context, id ManagedClusterId) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtype.ApplicationTypeClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtype.ApplicationTypeClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtype.ApplicationTypeClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c ApplicationTypeClient) preparerForList(ctx context.Context, id ManagedClusterId) (*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/applicationTypes", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c ApplicationTypeClient) 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 ApplicationTypeClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []ApplicationTypeResource `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, "applicationtype.ApplicationTypeClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtype.ApplicationTypeClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtype.ApplicationTypeClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c ApplicationTypeClient) ListComplete(ctx context.Context, id ManagedClusterId) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, ApplicationTypeResourceOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ApplicationTypeClient) ListCompleteMatchingPredicate(ctx context.Context, id ManagedClusterId, predicate ApplicationTypeResourceOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]ApplicationTypeResource, 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/servicefabricmanagedcluster/2022-01-01/applicationtype/method_update.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtype/method_update.go new file mode 100644 index 00000000000..74577757e20 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtype/method_update.go @@ -0,0 +1,55 @@ +package applicationtype + +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 *ApplicationTypeResource +} + +// Update ... +func (c ApplicationTypeClient) Update(ctx context.Context, id ApplicationTypeId, input ApplicationTypeUpdateParameters) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtype/method_update_autorest.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtype/method_update_autorest.go deleted file mode 100644 index 43b3533e842..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtype/method_update_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package applicationtype - -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 *ApplicationTypeResource -} - -// Update ... -func (c ApplicationTypeClient) Update(ctx context.Context, id ApplicationTypeId, input ApplicationTypeUpdateParameters) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtype.ApplicationTypeClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtype.ApplicationTypeClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtype.ApplicationTypeClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c ApplicationTypeClient) preparerForUpdate(ctx context.Context, id ApplicationTypeId, input ApplicationTypeUpdateParameters) (*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 ApplicationTypeClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, 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/servicefabricmanagedcluster/2022-01-01/applicationtypeversion/client.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtypeversion/client.go index 62ded9097a7..fbfd96f6ea3 100644 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtypeversion/client.go +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtypeversion/client.go @@ -1,18 +1,26 @@ package applicationtypeversion -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 ApplicationTypeVersionClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewApplicationTypeVersionClientWithBaseURI(endpoint string) ApplicationTypeVersionClient { - return ApplicationTypeVersionClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewApplicationTypeVersionClientWithBaseURI(sdkApi sdkEnv.Api) (*ApplicationTypeVersionClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "applicationtypeversion", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApplicationTypeVersionClient: %+v", err) } + + return &ApplicationTypeVersionClient{ + Client: client, + }, nil } diff --git a/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtypeversion/method_createorupdate.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtypeversion/method_createorupdate.go new file mode 100644 index 00000000000..4fbc5cb8b62 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtypeversion/method_createorupdate.go @@ -0,0 +1,75 @@ +package applicationtypeversion + +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 *ApplicationTypeVersionResource +} + +// CreateOrUpdate ... +func (c ApplicationTypeVersionClient) CreateOrUpdate(ctx context.Context, id VersionId, input ApplicationTypeVersionResource) (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 + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c ApplicationTypeVersionClient) CreateOrUpdateThenPoll(ctx context.Context, id VersionId, input ApplicationTypeVersionResource) 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/servicefabricmanagedcluster/2022-01-01/applicationtypeversion/method_createorupdate_autorest.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtypeversion/method_createorupdate_autorest.go deleted file mode 100644 index 50875ff36e1..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtypeversion/method_createorupdate_autorest.go +++ /dev/null @@ -1,80 +0,0 @@ -package applicationtypeversion - -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 *ApplicationTypeVersionResource -} - -// CreateOrUpdate ... -func (c ApplicationTypeVersionClient) CreateOrUpdate(ctx context.Context, id VersionId, input ApplicationTypeVersionResource) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtypeversion.ApplicationTypeVersionClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtypeversion.ApplicationTypeVersionClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c ApplicationTypeVersionClient) CreateOrUpdateThenPoll(ctx context.Context, id VersionId, input ApplicationTypeVersionResource) 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 ApplicationTypeVersionClient) preparerForCreateOrUpdate(ctx context.Context, id VersionId, input ApplicationTypeVersionResource) (*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 ApplicationTypeVersionClient) 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/servicefabricmanagedcluster/2022-01-01/applicationtypeversion/method_delete.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtypeversion/method_delete.go new file mode 100644 index 00000000000..7ed42106836 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtypeversion/method_delete.go @@ -0,0 +1,71 @@ +package applicationtypeversion + +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 ApplicationTypeVersionClient) Delete(ctx context.Context, id VersionId) (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 ApplicationTypeVersionClient) DeleteThenPoll(ctx context.Context, id VersionId) 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/servicefabricmanagedcluster/2022-01-01/applicationtypeversion/method_delete_autorest.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtypeversion/method_delete_autorest.go deleted file mode 100644 index 7d54184a693..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtypeversion/method_delete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package applicationtypeversion - -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 ApplicationTypeVersionClient) Delete(ctx context.Context, id VersionId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtypeversion.ApplicationTypeVersionClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtypeversion.ApplicationTypeVersionClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c ApplicationTypeVersionClient) DeleteThenPoll(ctx context.Context, id VersionId) 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 ApplicationTypeVersionClient) preparerForDelete(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.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 ApplicationTypeVersionClient) 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/servicefabricmanagedcluster/2022-01-01/applicationtypeversion/method_get.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtypeversion/method_get.go new file mode 100644 index 00000000000..13ab0519fbb --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtypeversion/method_get.go @@ -0,0 +1,51 @@ +package applicationtypeversion + +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 *ApplicationTypeVersionResource +} + +// Get ... +func (c ApplicationTypeVersionClient) Get(ctx context.Context, id VersionId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtypeversion/method_get_autorest.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtypeversion/method_get_autorest.go deleted file mode 100644 index e35b8f8eee4..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtypeversion/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package applicationtypeversion - -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 *ApplicationTypeVersionResource -} - -// Get ... -func (c ApplicationTypeVersionClient) Get(ctx context.Context, id VersionId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtypeversion.ApplicationTypeVersionClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtypeversion.ApplicationTypeVersionClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtypeversion.ApplicationTypeVersionClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ApplicationTypeVersionClient) preparerForGet(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)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c ApplicationTypeVersionClient) 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/servicefabricmanagedcluster/2022-01-01/applicationtypeversion/method_listbyapplicationtypes.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtypeversion/method_listbyapplicationtypes.go new file mode 100644 index 00000000000..d6cec2a7c45 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtypeversion/method_listbyapplicationtypes.go @@ -0,0 +1,91 @@ +package applicationtypeversion + +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 ListByApplicationTypesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApplicationTypeVersionResource +} + +type ListByApplicationTypesCompleteResult struct { + LatestHttpResponse *http.Response + Items []ApplicationTypeVersionResource +} + +// ListByApplicationTypes ... +func (c ApplicationTypeVersionClient) ListByApplicationTypes(ctx context.Context, id ApplicationTypeId) (result ListByApplicationTypesOperationResponse, 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 *[]ApplicationTypeVersionResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByApplicationTypesComplete retrieves all the results into a single object +func (c ApplicationTypeVersionClient) ListByApplicationTypesComplete(ctx context.Context, id ApplicationTypeId) (ListByApplicationTypesCompleteResult, error) { + return c.ListByApplicationTypesCompleteMatchingPredicate(ctx, id, ApplicationTypeVersionResourceOperationPredicate{}) +} + +// ListByApplicationTypesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApplicationTypeVersionClient) ListByApplicationTypesCompleteMatchingPredicate(ctx context.Context, id ApplicationTypeId, predicate ApplicationTypeVersionResourceOperationPredicate) (result ListByApplicationTypesCompleteResult, err error) { + items := make([]ApplicationTypeVersionResource, 0) + + resp, err := c.ListByApplicationTypes(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 = ListByApplicationTypesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtypeversion/method_listbyapplicationtypes_autorest.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtypeversion/method_listbyapplicationtypes_autorest.go deleted file mode 100644 index 93d0fc0685f..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtypeversion/method_listbyapplicationtypes_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package applicationtypeversion - -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 ListByApplicationTypesOperationResponse struct { - HttpResponse *http.Response - Model *[]ApplicationTypeVersionResource - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByApplicationTypesOperationResponse, error) -} - -type ListByApplicationTypesCompleteResult struct { - Items []ApplicationTypeVersionResource -} - -func (r ListByApplicationTypesOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByApplicationTypesOperationResponse) LoadMore(ctx context.Context) (resp ListByApplicationTypesOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByApplicationTypes ... -func (c ApplicationTypeVersionClient) ListByApplicationTypes(ctx context.Context, id ApplicationTypeId) (resp ListByApplicationTypesOperationResponse, err error) { - req, err := c.preparerForListByApplicationTypes(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtypeversion.ApplicationTypeVersionClient", "ListByApplicationTypes", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtypeversion.ApplicationTypeVersionClient", "ListByApplicationTypes", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByApplicationTypes(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtypeversion.ApplicationTypeVersionClient", "ListByApplicationTypes", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByApplicationTypes prepares the ListByApplicationTypes request. -func (c ApplicationTypeVersionClient) preparerForListByApplicationTypes(ctx context.Context, id ApplicationTypeId) (*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)) -} - -// preparerForListByApplicationTypesWithNextLink prepares the ListByApplicationTypes request with the given nextLink token. -func (c ApplicationTypeVersionClient) preparerForListByApplicationTypesWithNextLink(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)) -} - -// responderForListByApplicationTypes handles the response to the ListByApplicationTypes request. The method always -// closes the http.Response Body. -func (c ApplicationTypeVersionClient) responderForListByApplicationTypes(resp *http.Response) (result ListByApplicationTypesOperationResponse, err error) { - type page struct { - Values []ApplicationTypeVersionResource `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 ListByApplicationTypesOperationResponse, err error) { - req, err := c.preparerForListByApplicationTypesWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtypeversion.ApplicationTypeVersionClient", "ListByApplicationTypes", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtypeversion.ApplicationTypeVersionClient", "ListByApplicationTypes", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByApplicationTypes(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtypeversion.ApplicationTypeVersionClient", "ListByApplicationTypes", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByApplicationTypesComplete retrieves all of the results into a single object -func (c ApplicationTypeVersionClient) ListByApplicationTypesComplete(ctx context.Context, id ApplicationTypeId) (ListByApplicationTypesCompleteResult, error) { - return c.ListByApplicationTypesCompleteMatchingPredicate(ctx, id, ApplicationTypeVersionResourceOperationPredicate{}) -} - -// ListByApplicationTypesCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ApplicationTypeVersionClient) ListByApplicationTypesCompleteMatchingPredicate(ctx context.Context, id ApplicationTypeId, predicate ApplicationTypeVersionResourceOperationPredicate) (resp ListByApplicationTypesCompleteResult, err error) { - items := make([]ApplicationTypeVersionResource, 0) - - page, err := c.ListByApplicationTypes(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 := ListByApplicationTypesCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtypeversion/method_update.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtypeversion/method_update.go new file mode 100644 index 00000000000..d8642230902 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtypeversion/method_update.go @@ -0,0 +1,55 @@ +package applicationtypeversion + +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 *ApplicationTypeVersionResource +} + +// Update ... +func (c ApplicationTypeVersionClient) Update(ctx context.Context, id VersionId, input ApplicationTypeVersionUpdateParameters) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtypeversion/method_update_autorest.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtypeversion/method_update_autorest.go deleted file mode 100644 index 2a579e6ee92..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtypeversion/method_update_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package applicationtypeversion - -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 *ApplicationTypeVersionResource -} - -// Update ... -func (c ApplicationTypeVersionClient) Update(ctx context.Context, id VersionId, input ApplicationTypeVersionUpdateParameters) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtypeversion.ApplicationTypeVersionClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtypeversion.ApplicationTypeVersionClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "applicationtypeversion.ApplicationTypeVersionClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c ApplicationTypeVersionClient) preparerForUpdate(ctx context.Context, id VersionId, input ApplicationTypeVersionUpdateParameters) (*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 ApplicationTypeVersionClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, 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/servicefabricmanagedcluster/2022-01-01/client.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/client.go index 9fb6a0a13e4..ac4d0953b65 100644 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/client.go +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/client.go @@ -4,7 +4,8 @@ package v2022_01_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/servicefabricmanagedcluster/2022-01-01/application" "github.com/hashicorp/go-azure-sdk/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtype" "github.com/hashicorp/go-azure-sdk/resource-manager/servicefabricmanagedcluster/2022-01-01/applicationtypeversion" @@ -14,6 +15,8 @@ import ( "github.com/hashicorp/go-azure-sdk/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype" "github.com/hashicorp/go-azure-sdk/resource-manager/servicefabricmanagedcluster/2022-01-01/service" "github.com/hashicorp/go-azure-sdk/resource-manager/servicefabricmanagedcluster/2022-01-01/services" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" ) type Client struct { @@ -28,44 +31,70 @@ type Client struct { Services *services.ServicesClient } -func NewClientWithBaseURI(endpoint string, configureAuthFunc func(c *autorest.Client)) Client { - - applicationClient := application.NewApplicationClientWithBaseURI(endpoint) - configureAuthFunc(&applicationClient.Client) - - applicationTypeClient := applicationtype.NewApplicationTypeClientWithBaseURI(endpoint) - configureAuthFunc(&applicationTypeClient.Client) +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + applicationClient, err := application.NewApplicationClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Application client: %+v", err) + } + configureFunc(applicationClient.Client) - applicationTypeVersionClient := applicationtypeversion.NewApplicationTypeVersionClientWithBaseURI(endpoint) - configureAuthFunc(&applicationTypeVersionClient.Client) + applicationTypeClient, err := applicationtype.NewApplicationTypeClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ApplicationType client: %+v", err) + } + configureFunc(applicationTypeClient.Client) - managedClusterClient := managedcluster.NewManagedClusterClientWithBaseURI(endpoint) - configureAuthFunc(&managedClusterClient.Client) + applicationTypeVersionClient, err := applicationtypeversion.NewApplicationTypeVersionClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ApplicationTypeVersion client: %+v", err) + } + configureFunc(applicationTypeVersionClient.Client) - managedClusterVersionClient := managedclusterversion.NewManagedClusterVersionClientWithBaseURI(endpoint) - configureAuthFunc(&managedClusterVersionClient.Client) + managedClusterClient, err := managedcluster.NewManagedClusterClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ManagedCluster client: %+v", err) + } + configureFunc(managedClusterClient.Client) - managedVMSizesClient := managedvmsizes.NewManagedVMSizesClientWithBaseURI(endpoint) - configureAuthFunc(&managedVMSizesClient.Client) + managedClusterVersionClient, err := managedclusterversion.NewManagedClusterVersionClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ManagedClusterVersion client: %+v", err) + } + configureFunc(managedClusterVersionClient.Client) - nodeTypeClient := nodetype.NewNodeTypeClientWithBaseURI(endpoint) - configureAuthFunc(&nodeTypeClient.Client) + managedVMSizesClient, err := managedvmsizes.NewManagedVMSizesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ManagedVMSizes client: %+v", err) + } + configureFunc(managedVMSizesClient.Client) - serviceClient := service.NewServiceClientWithBaseURI(endpoint) - configureAuthFunc(&serviceClient.Client) + nodeTypeClient, err := nodetype.NewNodeTypeClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building NodeType client: %+v", err) + } + configureFunc(nodeTypeClient.Client) - servicesClient := services.NewServicesClientWithBaseURI(endpoint) - configureAuthFunc(&servicesClient.Client) + serviceClient, err := service.NewServiceClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Service client: %+v", err) + } + configureFunc(serviceClient.Client) - return Client{ - Application: &applicationClient, - ApplicationType: &applicationTypeClient, - ApplicationTypeVersion: &applicationTypeVersionClient, - ManagedCluster: &managedClusterClient, - ManagedClusterVersion: &managedClusterVersionClient, - ManagedVMSizes: &managedVMSizesClient, - NodeType: &nodeTypeClient, - Service: &serviceClient, - Services: &servicesClient, + servicesClient, err := services.NewServicesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Services client: %+v", err) } + configureFunc(servicesClient.Client) + + return &Client{ + Application: applicationClient, + ApplicationType: applicationTypeClient, + ApplicationTypeVersion: applicationTypeVersionClient, + ManagedCluster: managedClusterClient, + ManagedClusterVersion: managedClusterVersionClient, + ManagedVMSizes: managedVMSizesClient, + NodeType: nodeTypeClient, + Service: serviceClient, + Services: servicesClient, + }, nil } diff --git a/resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/client.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/client.go index 52b5b623754..14c21d22764 100644 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/client.go +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/client.go @@ -1,18 +1,26 @@ package managedcluster -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 ManagedClusterClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewManagedClusterClientWithBaseURI(endpoint string) ManagedClusterClient { - return ManagedClusterClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewManagedClusterClientWithBaseURI(sdkApi sdkEnv.Api) (*ManagedClusterClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "managedcluster", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ManagedClusterClient: %+v", err) } + + return &ManagedClusterClient{ + Client: client, + }, nil } diff --git a/resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/constants.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/constants.go index d590ac667d9..8d57c5b58b1 100644 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/constants.go +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/constants.go @@ -1,6 +1,10 @@ package managedcluster -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. @@ -19,6 +23,19 @@ func PossibleValuesForAccess() []string { } } +func (s *Access) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAccess(input string) (*Access, error) { vals := map[string]Access{ "allow": AccessAllow, @@ -49,6 +66,19 @@ func PossibleValuesForAddonFeatures() []string { } } +func (s *AddonFeatures) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAddonFeatures(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAddonFeatures(input string) (*AddonFeatures, error) { vals := map[string]AddonFeatures{ "backuprestoreservice": AddonFeaturesBackupRestoreService, @@ -86,6 +116,19 @@ func PossibleValuesForClusterState() []string { } } +func (s *ClusterState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClusterState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseClusterState(input string) (*ClusterState, error) { vals := map[string]ClusterState{ "baselineupgrade": ClusterStateBaselineUpgrade, @@ -120,6 +163,19 @@ func PossibleValuesForClusterUpgradeCadence() []string { } } +func (s *ClusterUpgradeCadence) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClusterUpgradeCadence(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseClusterUpgradeCadence(input string) (*ClusterUpgradeCadence, error) { vals := map[string]ClusterUpgradeCadence{ "wave1": ClusterUpgradeCadenceWaveOne, @@ -149,6 +205,19 @@ func PossibleValuesForClusterUpgradeMode() []string { } } +func (s *ClusterUpgradeMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClusterUpgradeMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseClusterUpgradeMode(input string) (*ClusterUpgradeMode, error) { vals := map[string]ClusterUpgradeMode{ "automatic": ClusterUpgradeModeAutomatic, @@ -177,6 +246,19 @@ func PossibleValuesForDirection() []string { } } +func (s *Direction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDirection(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseDirection(input string) (*Direction, error) { vals := map[string]Direction{ "inbound": DirectionInbound, @@ -221,6 +303,19 @@ func PossibleValuesForManagedResourceProvisioningState() []string { } } +func (s *ManagedResourceProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedResourceProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseManagedResourceProvisioningState(input string) (*ManagedResourceProvisioningState, error) { vals := map[string]ManagedResourceProvisioningState{ "canceled": ManagedResourceProvisioningStateCanceled, @@ -267,6 +362,19 @@ func PossibleValuesForNsgProtocol() []string { } } +func (s *NsgProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNsgProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseNsgProtocol(input string) (*NsgProtocol, error) { vals := map[string]NsgProtocol{ "ah": NsgProtocolAh, @@ -300,6 +408,19 @@ func PossibleValuesForPrivateEndpointNetworkPolicies() []string { } } +func (s *PrivateEndpointNetworkPolicies) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointNetworkPolicies(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePrivateEndpointNetworkPolicies(input string) (*PrivateEndpointNetworkPolicies, error) { vals := map[string]PrivateEndpointNetworkPolicies{ "disabled": PrivateEndpointNetworkPoliciesDisabled, @@ -328,6 +449,19 @@ func PossibleValuesForPrivateLinkServiceNetworkPolicies() []string { } } +func (s *PrivateLinkServiceNetworkPolicies) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateLinkServiceNetworkPolicies(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePrivateLinkServiceNetworkPolicies(input string) (*PrivateLinkServiceNetworkPolicies, error) { vals := map[string]PrivateLinkServiceNetworkPolicies{ "disabled": PrivateLinkServiceNetworkPoliciesDisabled, @@ -358,6 +492,19 @@ func PossibleValuesForProbeProtocol() []string { } } +func (s *ProbeProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProbeProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseProbeProtocol(input string) (*ProbeProtocol, error) { vals := map[string]ProbeProtocol{ "http": ProbeProtocolHTTP, @@ -387,6 +534,19 @@ func PossibleValuesForProtocol() []string { } } +func (s *Protocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseProtocol(input string) (*Protocol, error) { vals := map[string]Protocol{ "tcp": ProtocolTcp, @@ -415,6 +575,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{ "basic": SkuNameBasic, diff --git a/resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/method_createorupdate.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/method_createorupdate.go new file mode 100644 index 00000000000..95e9f5ad9fc --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/method_createorupdate.go @@ -0,0 +1,75 @@ +package managedcluster + +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 *ManagedCluster +} + +// CreateOrUpdate ... +func (c ManagedClusterClient) CreateOrUpdate(ctx context.Context, id ManagedClusterId, input ManagedCluster) (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 + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c ManagedClusterClient) CreateOrUpdateThenPoll(ctx context.Context, id ManagedClusterId, input ManagedCluster) 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/servicefabricmanagedcluster/2022-01-01/managedcluster/method_createorupdate_autorest.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/method_createorupdate_autorest.go deleted file mode 100644 index 86b18349142..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/method_createorupdate_autorest.go +++ /dev/null @@ -1,80 +0,0 @@ -package managedcluster - -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 *ManagedCluster -} - -// CreateOrUpdate ... -func (c ManagedClusterClient) CreateOrUpdate(ctx context.Context, id ManagedClusterId, input ManagedCluster) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "managedcluster.ManagedClusterClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "managedcluster.ManagedClusterClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c ManagedClusterClient) CreateOrUpdateThenPoll(ctx context.Context, id ManagedClusterId, input ManagedCluster) 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 ManagedClusterClient) preparerForCreateOrUpdate(ctx context.Context, id ManagedClusterId, input ManagedCluster) (*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 ManagedClusterClient) 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/servicefabricmanagedcluster/2022-01-01/managedcluster/method_delete.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/method_delete.go new file mode 100644 index 00000000000..dbcea342a30 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/method_delete.go @@ -0,0 +1,71 @@ +package managedcluster + +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 ManagedClusterClient) Delete(ctx context.Context, id ManagedClusterId) (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 ManagedClusterClient) DeleteThenPoll(ctx context.Context, id ManagedClusterId) 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/servicefabricmanagedcluster/2022-01-01/managedcluster/method_delete_autorest.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/method_delete_autorest.go deleted file mode 100644 index 68b47184164..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/method_delete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package managedcluster - -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 ManagedClusterClient) Delete(ctx context.Context, id ManagedClusterId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "managedcluster.ManagedClusterClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "managedcluster.ManagedClusterClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c ManagedClusterClient) DeleteThenPoll(ctx context.Context, id ManagedClusterId) 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 ManagedClusterClient) preparerForDelete(ctx context.Context, id ManagedClusterId) (*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 ManagedClusterClient) 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/servicefabricmanagedcluster/2022-01-01/managedcluster/method_get.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/method_get.go new file mode 100644 index 00000000000..069bb644f25 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/method_get.go @@ -0,0 +1,51 @@ +package managedcluster + +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 *ManagedCluster +} + +// Get ... +func (c ManagedClusterClient) Get(ctx context.Context, id ManagedClusterId) (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/servicefabricmanagedcluster/2022-01-01/managedcluster/method_get_autorest.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/method_get_autorest.go deleted file mode 100644 index e81b8d3b20b..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package managedcluster - -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 *ManagedCluster -} - -// Get ... -func (c ManagedClusterClient) Get(ctx context.Context, id ManagedClusterId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "managedcluster.ManagedClusterClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedcluster.ManagedClusterClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedcluster.ManagedClusterClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ManagedClusterClient) preparerForGet(ctx context.Context, id ManagedClusterId) (*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 ManagedClusterClient) 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/servicefabricmanagedcluster/2022-01-01/managedcluster/method_listbyresourcegroup.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/method_listbyresourcegroup.go new file mode 100644 index 00000000000..6fc2ff33bb8 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/method_listbyresourcegroup.go @@ -0,0 +1,92 @@ +package managedcluster + +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 *[]ManagedCluster +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []ManagedCluster +} + +// ListByResourceGroup ... +func (c ManagedClusterClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.ServiceFabric/managedClusters", 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 *[]ManagedCluster `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 ManagedClusterClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ManagedClusterOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagedClusterClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ManagedClusterOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]ManagedCluster, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/method_listbyresourcegroup_autorest.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/method_listbyresourcegroup_autorest.go deleted file mode 100644 index aa3e398b648..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/method_listbyresourcegroup_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package managedcluster - -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 *[]ManagedCluster - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByResourceGroupOperationResponse, error) -} - -type ListByResourceGroupCompleteResult struct { - Items []ManagedCluster -} - -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) -} - -// ListByResourceGroup ... -func (c ManagedClusterClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (resp ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroup(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "managedcluster.ManagedClusterClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedcluster.ManagedClusterClient", "ListByResourceGroup", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByResourceGroup(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedcluster.ManagedClusterClient", "ListByResourceGroup", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByResourceGroup prepares the ListByResourceGroup request. -func (c ManagedClusterClient) preparerForListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (*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.ServiceFabric/managedClusters", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByResourceGroupWithNextLink prepares the ListByResourceGroup request with the given nextLink token. -func (c ManagedClusterClient) 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 ManagedClusterClient) responderForListByResourceGroup(resp *http.Response) (result ListByResourceGroupOperationResponse, err error) { - type page struct { - Values []ManagedCluster `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, "managedcluster.ManagedClusterClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedcluster.ManagedClusterClient", "ListByResourceGroup", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByResourceGroup(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedcluster.ManagedClusterClient", "ListByResourceGroup", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByResourceGroupComplete retrieves all of the results into a single object -func (c ManagedClusterClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { - return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ManagedClusterOperationPredicate{}) -} - -// ListByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ManagedClusterClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ManagedClusterOperationPredicate) (resp ListByResourceGroupCompleteResult, err error) { - items := make([]ManagedCluster, 0) - - page, err := c.ListByResourceGroup(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 := ListByResourceGroupCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/method_listbysubscription.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/method_listbysubscription.go new file mode 100644 index 00000000000..dff76cbe716 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/method_listbysubscription.go @@ -0,0 +1,92 @@ +package managedcluster + +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 *[]ManagedCluster +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []ManagedCluster +} + +// ListBySubscription ... +func (c ManagedClusterClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.ServiceFabric/managedClusters", 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 *[]ManagedCluster `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 ManagedClusterClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, ManagedClusterOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagedClusterClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ManagedClusterOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]ManagedCluster, 0) + + resp, err := c.ListBySubscription(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 = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/method_listbysubscription_autorest.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/method_listbysubscription_autorest.go deleted file mode 100644 index 42722389796..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/method_listbysubscription_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package managedcluster - -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 *[]ManagedCluster - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListBySubscriptionOperationResponse, error) -} - -type ListBySubscriptionCompleteResult struct { - Items []ManagedCluster -} - -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) -} - -// ListBySubscription ... -func (c ManagedClusterClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (resp ListBySubscriptionOperationResponse, err error) { - req, err := c.preparerForListBySubscription(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "managedcluster.ManagedClusterClient", "ListBySubscription", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedcluster.ManagedClusterClient", "ListBySubscription", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListBySubscription(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedcluster.ManagedClusterClient", "ListBySubscription", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListBySubscription prepares the ListBySubscription request. -func (c ManagedClusterClient) preparerForListBySubscription(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.ServiceFabric/managedClusters", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListBySubscriptionWithNextLink prepares the ListBySubscription request with the given nextLink token. -func (c ManagedClusterClient) 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 ManagedClusterClient) responderForListBySubscription(resp *http.Response) (result ListBySubscriptionOperationResponse, err error) { - type page struct { - Values []ManagedCluster `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, "managedcluster.ManagedClusterClient", "ListBySubscription", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedcluster.ManagedClusterClient", "ListBySubscription", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListBySubscription(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedcluster.ManagedClusterClient", "ListBySubscription", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListBySubscriptionComplete retrieves all of the results into a single object -func (c ManagedClusterClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { - return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, ManagedClusterOperationPredicate{}) -} - -// ListBySubscriptionCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ManagedClusterClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ManagedClusterOperationPredicate) (resp ListBySubscriptionCompleteResult, err error) { - items := make([]ManagedCluster, 0) - - page, err := c.ListBySubscription(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 := ListBySubscriptionCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/method_update.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/method_update.go new file mode 100644 index 00000000000..bc6e02baad9 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/method_update.go @@ -0,0 +1,55 @@ +package managedcluster + +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 *ManagedCluster +} + +// Update ... +func (c ManagedClusterClient) Update(ctx context.Context, id ManagedClusterId, input ManagedClusterUpdateParameters) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/method_update_autorest.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/method_update_autorest.go deleted file mode 100644 index c11f0beae5b..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/managedcluster/method_update_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package managedcluster - -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 *ManagedCluster -} - -// Update ... -func (c ManagedClusterClient) Update(ctx context.Context, id ManagedClusterId, input ManagedClusterUpdateParameters) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "managedcluster.ManagedClusterClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedcluster.ManagedClusterClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedcluster.ManagedClusterClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c ManagedClusterClient) preparerForUpdate(ctx context.Context, id ManagedClusterId, input ManagedClusterUpdateParameters) (*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 ManagedClusterClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, 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/servicefabricmanagedcluster/2022-01-01/managedclusterversion/client.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/managedclusterversion/client.go index 588c6e6c83f..4221e0cb422 100644 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/managedclusterversion/client.go +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/managedclusterversion/client.go @@ -1,18 +1,26 @@ package managedclusterversion -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 ManagedClusterVersionClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewManagedClusterVersionClientWithBaseURI(endpoint string) ManagedClusterVersionClient { - return ManagedClusterVersionClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewManagedClusterVersionClientWithBaseURI(sdkApi sdkEnv.Api) (*ManagedClusterVersionClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "managedclusterversion", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ManagedClusterVersionClient: %+v", err) } + + return &ManagedClusterVersionClient{ + Client: client, + }, nil } diff --git a/resource-manager/servicefabricmanagedcluster/2022-01-01/managedclusterversion/constants.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/managedclusterversion/constants.go index 3f51fb9fc75..63f05d5112a 100644 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/managedclusterversion/constants.go +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/managedclusterversion/constants.go @@ -1,6 +1,10 @@ package managedclusterversion -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 PossibleValuesForOsType() []string { } } +func (s *OsType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOsType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseOsType(input string) (*OsType, error) { vals := map[string]OsType{ "windows": OsTypeWindows, diff --git a/resource-manager/servicefabricmanagedcluster/2022-01-01/managedclusterversion/method_get.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/managedclusterversion/method_get.go new file mode 100644 index 00000000000..5d7cbe8f7eb --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/managedclusterversion/method_get.go @@ -0,0 +1,51 @@ +package managedclusterversion + +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 *ManagedClusterCodeVersionResult +} + +// Get ... +func (c ManagedClusterVersionClient) Get(ctx context.Context, id ManagedClusterVersionId) (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/servicefabricmanagedcluster/2022-01-01/managedclusterversion/method_get_autorest.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/managedclusterversion/method_get_autorest.go deleted file mode 100644 index 0ab5a0a03a3..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/managedclusterversion/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package managedclusterversion - -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 *ManagedClusterCodeVersionResult -} - -// Get ... -func (c ManagedClusterVersionClient) Get(ctx context.Context, id ManagedClusterVersionId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "managedclusterversion.ManagedClusterVersionClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedclusterversion.ManagedClusterVersionClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedclusterversion.ManagedClusterVersionClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ManagedClusterVersionClient) preparerForGet(ctx context.Context, id ManagedClusterVersionId) (*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 ManagedClusterVersionClient) 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/servicefabricmanagedcluster/2022-01-01/managedclusterversion/method_getbyenvironment.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/managedclusterversion/method_getbyenvironment.go new file mode 100644 index 00000000000..82512ee14ea --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/managedclusterversion/method_getbyenvironment.go @@ -0,0 +1,51 @@ +package managedclusterversion + +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 GetByEnvironmentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ManagedClusterCodeVersionResult +} + +// GetByEnvironment ... +func (c ManagedClusterVersionClient) GetByEnvironment(ctx context.Context, id EnvironmentManagedClusterVersionId) (result GetByEnvironmentOperationResponse, 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/servicefabricmanagedcluster/2022-01-01/managedclusterversion/method_getbyenvironment_autorest.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/managedclusterversion/method_getbyenvironment_autorest.go deleted file mode 100644 index cb8bf5c72c0..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/managedclusterversion/method_getbyenvironment_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package managedclusterversion - -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 GetByEnvironmentOperationResponse struct { - HttpResponse *http.Response - Model *ManagedClusterCodeVersionResult -} - -// GetByEnvironment ... -func (c ManagedClusterVersionClient) GetByEnvironment(ctx context.Context, id EnvironmentManagedClusterVersionId) (result GetByEnvironmentOperationResponse, err error) { - req, err := c.preparerForGetByEnvironment(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "managedclusterversion.ManagedClusterVersionClient", "GetByEnvironment", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedclusterversion.ManagedClusterVersionClient", "GetByEnvironment", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetByEnvironment(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedclusterversion.ManagedClusterVersionClient", "GetByEnvironment", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetByEnvironment prepares the GetByEnvironment request. -func (c ManagedClusterVersionClient) preparerForGetByEnvironment(ctx context.Context, id EnvironmentManagedClusterVersionId) (*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)) -} - -// responderForGetByEnvironment handles the response to the GetByEnvironment request. The method always -// closes the http.Response Body. -func (c ManagedClusterVersionClient) responderForGetByEnvironment(resp *http.Response) (result GetByEnvironmentOperationResponse, 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/servicefabricmanagedcluster/2022-01-01/managedclusterversion/method_list.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/managedclusterversion/method_list.go new file mode 100644 index 00000000000..6de29d2f9ed --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/managedclusterversion/method_list.go @@ -0,0 +1,52 @@ +package managedclusterversion + +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 *[]ManagedClusterCodeVersionResult +} + +// List ... +func (c ManagedClusterVersionClient) List(ctx context.Context, id LocationId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/managedClusterVersions", 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/servicefabricmanagedcluster/2022-01-01/managedclusterversion/method_list_autorest.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/managedclusterversion/method_list_autorest.go deleted file mode 100644 index ab4f2569aec..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/managedclusterversion/method_list_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package managedclusterversion - -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 ListOperationResponse struct { - HttpResponse *http.Response - Model *[]ManagedClusterCodeVersionResult -} - -// List ... -func (c ManagedClusterVersionClient) List(ctx context.Context, id LocationId) (result ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "managedclusterversion.ManagedClusterVersionClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedclusterversion.ManagedClusterVersionClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedclusterversion.ManagedClusterVersionClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForList prepares the List request. -func (c ManagedClusterVersionClient) preparerForList(ctx context.Context, id LocationId) (*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/managedClusterVersions", id.ID())), - 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 ManagedClusterVersionClient) responderForList(resp *http.Response) (result ListOperationResponse, 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/servicefabricmanagedcluster/2022-01-01/managedclusterversion/method_listbyenvironment.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/managedclusterversion/method_listbyenvironment.go new file mode 100644 index 00000000000..8650aa75c59 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/managedclusterversion/method_listbyenvironment.go @@ -0,0 +1,52 @@ +package managedclusterversion + +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 ListByEnvironmentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ManagedClusterCodeVersionResult +} + +// ListByEnvironment ... +func (c ManagedClusterVersionClient) ListByEnvironment(ctx context.Context, id LocationId) (result ListByEnvironmentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/environments/Windows/managedClusterVersions", 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/servicefabricmanagedcluster/2022-01-01/managedclusterversion/method_listbyenvironment_autorest.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/managedclusterversion/method_listbyenvironment_autorest.go deleted file mode 100644 index 0bba3740976..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/managedclusterversion/method_listbyenvironment_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package managedclusterversion - -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 ListByEnvironmentOperationResponse struct { - HttpResponse *http.Response - Model *[]ManagedClusterCodeVersionResult -} - -// ListByEnvironment ... -func (c ManagedClusterVersionClient) ListByEnvironment(ctx context.Context, id LocationId) (result ListByEnvironmentOperationResponse, err error) { - req, err := c.preparerForListByEnvironment(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "managedclusterversion.ManagedClusterVersionClient", "ListByEnvironment", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedclusterversion.ManagedClusterVersionClient", "ListByEnvironment", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByEnvironment(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedclusterversion.ManagedClusterVersionClient", "ListByEnvironment", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByEnvironment prepares the ListByEnvironment request. -func (c ManagedClusterVersionClient) preparerForListByEnvironment(ctx context.Context, id LocationId) (*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/environments/Windows/managedClusterVersions", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByEnvironment handles the response to the ListByEnvironment request. The method always -// closes the http.Response Body. -func (c ManagedClusterVersionClient) responderForListByEnvironment(resp *http.Response) (result ListByEnvironmentOperationResponse, 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/servicefabricmanagedcluster/2022-01-01/managedvmsizes/client.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/managedvmsizes/client.go index 3a38d0077ad..49278b9f927 100644 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/managedvmsizes/client.go +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/managedvmsizes/client.go @@ -1,18 +1,26 @@ package managedvmsizes -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 ManagedVMSizesClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewManagedVMSizesClientWithBaseURI(endpoint string) ManagedVMSizesClient { - return ManagedVMSizesClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewManagedVMSizesClientWithBaseURI(sdkApi sdkEnv.Api) (*ManagedVMSizesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "managedvmsizes", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ManagedVMSizesClient: %+v", err) } + + return &ManagedVMSizesClient{ + Client: client, + }, nil } diff --git a/resource-manager/servicefabricmanagedcluster/2022-01-01/managedvmsizes/method_managedunsupportedvmsizesget.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/managedvmsizes/method_managedunsupportedvmsizesget.go new file mode 100644 index 00000000000..a3a5afb3fec --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/managedvmsizes/method_managedunsupportedvmsizesget.go @@ -0,0 +1,51 @@ +package managedvmsizes + +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 ManagedUnsupportedVMSizesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ManagedVMSize +} + +// ManagedUnsupportedVMSizesGet ... +func (c ManagedVMSizesClient) ManagedUnsupportedVMSizesGet(ctx context.Context, id ManagedUnsupportedVMSizeId) (result ManagedUnsupportedVMSizesGetOperationResponse, 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/servicefabricmanagedcluster/2022-01-01/managedvmsizes/method_managedunsupportedvmsizesget_autorest.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/managedvmsizes/method_managedunsupportedvmsizesget_autorest.go deleted file mode 100644 index f2a9286a8f2..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/managedvmsizes/method_managedunsupportedvmsizesget_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package managedvmsizes - -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 ManagedUnsupportedVMSizesGetOperationResponse struct { - HttpResponse *http.Response - Model *ManagedVMSize -} - -// ManagedUnsupportedVMSizesGet ... -func (c ManagedVMSizesClient) ManagedUnsupportedVMSizesGet(ctx context.Context, id ManagedUnsupportedVMSizeId) (result ManagedUnsupportedVMSizesGetOperationResponse, err error) { - req, err := c.preparerForManagedUnsupportedVMSizesGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "managedvmsizes.ManagedVMSizesClient", "ManagedUnsupportedVMSizesGet", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedvmsizes.ManagedVMSizesClient", "ManagedUnsupportedVMSizesGet", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForManagedUnsupportedVMSizesGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedvmsizes.ManagedVMSizesClient", "ManagedUnsupportedVMSizesGet", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForManagedUnsupportedVMSizesGet prepares the ManagedUnsupportedVMSizesGet request. -func (c ManagedVMSizesClient) preparerForManagedUnsupportedVMSizesGet(ctx context.Context, id ManagedUnsupportedVMSizeId) (*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)) -} - -// responderForManagedUnsupportedVMSizesGet handles the response to the ManagedUnsupportedVMSizesGet request. The method always -// closes the http.Response Body. -func (c ManagedVMSizesClient) responderForManagedUnsupportedVMSizesGet(resp *http.Response) (result ManagedUnsupportedVMSizesGetOperationResponse, 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/servicefabricmanagedcluster/2022-01-01/managedvmsizes/method_managedunsupportedvmsizeslist.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/managedvmsizes/method_managedunsupportedvmsizeslist.go new file mode 100644 index 00000000000..3ce4a4d97c5 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/managedvmsizes/method_managedunsupportedvmsizeslist.go @@ -0,0 +1,91 @@ +package managedvmsizes + +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 ManagedUnsupportedVMSizesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ManagedVMSize +} + +type ManagedUnsupportedVMSizesListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ManagedVMSize +} + +// ManagedUnsupportedVMSizesList ... +func (c ManagedVMSizesClient) ManagedUnsupportedVMSizesList(ctx context.Context, id LocationId) (result ManagedUnsupportedVMSizesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/managedUnsupportedVMSizes", 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 *[]ManagedVMSize `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ManagedUnsupportedVMSizesListComplete retrieves all the results into a single object +func (c ManagedVMSizesClient) ManagedUnsupportedVMSizesListComplete(ctx context.Context, id LocationId) (ManagedUnsupportedVMSizesListCompleteResult, error) { + return c.ManagedUnsupportedVMSizesListCompleteMatchingPredicate(ctx, id, ManagedVMSizeOperationPredicate{}) +} + +// ManagedUnsupportedVMSizesListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagedVMSizesClient) ManagedUnsupportedVMSizesListCompleteMatchingPredicate(ctx context.Context, id LocationId, predicate ManagedVMSizeOperationPredicate) (result ManagedUnsupportedVMSizesListCompleteResult, err error) { + items := make([]ManagedVMSize, 0) + + resp, err := c.ManagedUnsupportedVMSizesList(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 = ManagedUnsupportedVMSizesListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2022-01-01/managedvmsizes/method_managedunsupportedvmsizeslist_autorest.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/managedvmsizes/method_managedunsupportedvmsizeslist_autorest.go deleted file mode 100644 index 1d40a50bc4f..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/managedvmsizes/method_managedunsupportedvmsizeslist_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package managedvmsizes - -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 ManagedUnsupportedVMSizesListOperationResponse struct { - HttpResponse *http.Response - Model *[]ManagedVMSize - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ManagedUnsupportedVMSizesListOperationResponse, error) -} - -type ManagedUnsupportedVMSizesListCompleteResult struct { - Items []ManagedVMSize -} - -func (r ManagedUnsupportedVMSizesListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ManagedUnsupportedVMSizesListOperationResponse) LoadMore(ctx context.Context) (resp ManagedUnsupportedVMSizesListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ManagedUnsupportedVMSizesList ... -func (c ManagedVMSizesClient) ManagedUnsupportedVMSizesList(ctx context.Context, id LocationId) (resp ManagedUnsupportedVMSizesListOperationResponse, err error) { - req, err := c.preparerForManagedUnsupportedVMSizesList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "managedvmsizes.ManagedVMSizesClient", "ManagedUnsupportedVMSizesList", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedvmsizes.ManagedVMSizesClient", "ManagedUnsupportedVMSizesList", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForManagedUnsupportedVMSizesList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedvmsizes.ManagedVMSizesClient", "ManagedUnsupportedVMSizesList", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForManagedUnsupportedVMSizesList prepares the ManagedUnsupportedVMSizesList request. -func (c ManagedVMSizesClient) preparerForManagedUnsupportedVMSizesList(ctx context.Context, id LocationId) (*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/managedUnsupportedVMSizes", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForManagedUnsupportedVMSizesListWithNextLink prepares the ManagedUnsupportedVMSizesList request with the given nextLink token. -func (c ManagedVMSizesClient) preparerForManagedUnsupportedVMSizesListWithNextLink(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)) -} - -// responderForManagedUnsupportedVMSizesList handles the response to the ManagedUnsupportedVMSizesList request. The method always -// closes the http.Response Body. -func (c ManagedVMSizesClient) responderForManagedUnsupportedVMSizesList(resp *http.Response) (result ManagedUnsupportedVMSizesListOperationResponse, err error) { - type page struct { - Values []ManagedVMSize `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 ManagedUnsupportedVMSizesListOperationResponse, err error) { - req, err := c.preparerForManagedUnsupportedVMSizesListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "managedvmsizes.ManagedVMSizesClient", "ManagedUnsupportedVMSizesList", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedvmsizes.ManagedVMSizesClient", "ManagedUnsupportedVMSizesList", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForManagedUnsupportedVMSizesList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedvmsizes.ManagedVMSizesClient", "ManagedUnsupportedVMSizesList", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ManagedUnsupportedVMSizesListComplete retrieves all of the results into a single object -func (c ManagedVMSizesClient) ManagedUnsupportedVMSizesListComplete(ctx context.Context, id LocationId) (ManagedUnsupportedVMSizesListCompleteResult, error) { - return c.ManagedUnsupportedVMSizesListCompleteMatchingPredicate(ctx, id, ManagedVMSizeOperationPredicate{}) -} - -// ManagedUnsupportedVMSizesListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ManagedVMSizesClient) ManagedUnsupportedVMSizesListCompleteMatchingPredicate(ctx context.Context, id LocationId, predicate ManagedVMSizeOperationPredicate) (resp ManagedUnsupportedVMSizesListCompleteResult, err error) { - items := make([]ManagedVMSize, 0) - - page, err := c.ManagedUnsupportedVMSizesList(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 := ManagedUnsupportedVMSizesListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/client.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/client.go index ed9d423c3ce..ae6880601d4 100644 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/client.go +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/client.go @@ -1,18 +1,26 @@ package nodetype -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 NodeTypeClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewNodeTypeClientWithBaseURI(endpoint string) NodeTypeClient { - return NodeTypeClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewNodeTypeClientWithBaseURI(sdkApi sdkEnv.Api) (*NodeTypeClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "nodetype", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NodeTypeClient: %+v", err) } + + return &NodeTypeClient{ + Client: client, + }, nil } diff --git a/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/constants.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/constants.go index 1fcab28977c..b397bbb5f86 100644 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/constants.go +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/constants.go @@ -1,6 +1,10 @@ package nodetype -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. @@ -19,6 +23,19 @@ func PossibleValuesForAccess() []string { } } +func (s *Access) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAccess(input string) (*Access, error) { vals := map[string]Access{ "allow": AccessAllow, @@ -47,6 +64,19 @@ func PossibleValuesForDirection() []string { } } +func (s *Direction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDirection(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseDirection(input string) (*Direction, error) { vals := map[string]Direction{ "inbound": DirectionInbound, @@ -77,6 +107,19 @@ func PossibleValuesForDiskType() []string { } } +func (s *DiskType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDiskType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseDiskType(input string) (*DiskType, error) { vals := map[string]DiskType{ "premium_lrs": DiskTypePremiumLRS, @@ -106,6 +149,19 @@ func PossibleValuesForIPAddressType() []string { } } +func (s *IPAddressType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPAddressType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseIPAddressType(input string) (*IPAddressType, error) { vals := map[string]IPAddressType{ "ipv4": IPAddressTypeIPvFour, @@ -150,6 +206,19 @@ func PossibleValuesForManagedResourceProvisioningState() []string { } } +func (s *ManagedResourceProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedResourceProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseManagedResourceProvisioningState(input string) (*ManagedResourceProvisioningState, error) { vals := map[string]ManagedResourceProvisioningState{ "canceled": ManagedResourceProvisioningStateCanceled, @@ -188,6 +257,19 @@ func PossibleValuesForNodeTypeSkuScaleType() []string { } } +func (s *NodeTypeSkuScaleType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNodeTypeSkuScaleType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseNodeTypeSkuScaleType(input string) (*NodeTypeSkuScaleType, error) { vals := map[string]NodeTypeSkuScaleType{ "automatic": NodeTypeSkuScaleTypeAutomatic, @@ -227,6 +309,19 @@ func PossibleValuesForNsgProtocol() []string { } } +func (s *NsgProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNsgProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseNsgProtocol(input string) (*NsgProtocol, error) { vals := map[string]NsgProtocol{ "ah": NsgProtocolAh, diff --git a/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_createorupdate.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_createorupdate.go new file mode 100644 index 00000000000..fa299533273 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_createorupdate.go @@ -0,0 +1,75 @@ +package nodetype + +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 *NodeType +} + +// CreateOrUpdate ... +func (c NodeTypeClient) CreateOrUpdate(ctx context.Context, id NodeTypeId, input NodeType) (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 + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c NodeTypeClient) CreateOrUpdateThenPoll(ctx context.Context, id NodeTypeId, input NodeType) 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/servicefabricmanagedcluster/2022-01-01/nodetype/method_createorupdate_autorest.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_createorupdate_autorest.go deleted file mode 100644 index f4304fb3e74..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_createorupdate_autorest.go +++ /dev/null @@ -1,80 +0,0 @@ -package nodetype - -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 *NodeType -} - -// CreateOrUpdate ... -func (c NodeTypeClient) CreateOrUpdate(ctx context.Context, id NodeTypeId, input NodeType) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c NodeTypeClient) CreateOrUpdateThenPoll(ctx context.Context, id NodeTypeId, input NodeType) 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 NodeTypeClient) preparerForCreateOrUpdate(ctx context.Context, id NodeTypeId, input NodeType) (*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 NodeTypeClient) 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/servicefabricmanagedcluster/2022-01-01/nodetype/method_delete.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_delete.go new file mode 100644 index 00000000000..028e962d71f --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_delete.go @@ -0,0 +1,71 @@ +package nodetype + +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 NodeTypeClient) Delete(ctx context.Context, id NodeTypeId) (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 NodeTypeClient) DeleteThenPoll(ctx context.Context, id NodeTypeId) 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/servicefabricmanagedcluster/2022-01-01/nodetype/method_delete_autorest.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_delete_autorest.go deleted file mode 100644 index 557f0a902b0..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_delete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package nodetype - -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 NodeTypeClient) Delete(ctx context.Context, id NodeTypeId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c NodeTypeClient) DeleteThenPoll(ctx context.Context, id NodeTypeId) 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 NodeTypeClient) preparerForDelete(ctx context.Context, id NodeTypeId) (*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 NodeTypeClient) 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/servicefabricmanagedcluster/2022-01-01/nodetype/method_deletenode.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_deletenode.go new file mode 100644 index 00000000000..803466d737e --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_deletenode.go @@ -0,0 +1,74 @@ +package nodetype + +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 DeleteNodeOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteNode ... +func (c NodeTypeClient) DeleteNode(ctx context.Context, id NodeTypeId, input NodeTypeActionParameters) (result DeleteNodeOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/deleteNode", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteNodeThenPoll performs DeleteNode then polls until it's completed +func (c NodeTypeClient) DeleteNodeThenPoll(ctx context.Context, id NodeTypeId, input NodeTypeActionParameters) error { + result, err := c.DeleteNode(ctx, id, input) + if err != nil { + return fmt.Errorf("performing DeleteNode: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DeleteNode: %+v", err) + } + + return nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_deletenode_autorest.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_deletenode_autorest.go deleted file mode 100644 index b49d2f9e6d7..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_deletenode_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package nodetype - -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 DeleteNodeOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// DeleteNode ... -func (c NodeTypeClient) DeleteNode(ctx context.Context, id NodeTypeId, input NodeTypeActionParameters) (result DeleteNodeOperationResponse, err error) { - req, err := c.preparerForDeleteNode(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "DeleteNode", nil, "Failure preparing request") - return - } - - result, err = c.senderForDeleteNode(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "DeleteNode", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteNodeThenPoll performs DeleteNode then polls until it's completed -func (c NodeTypeClient) DeleteNodeThenPoll(ctx context.Context, id NodeTypeId, input NodeTypeActionParameters) error { - result, err := c.DeleteNode(ctx, id, input) - if err != nil { - return fmt.Errorf("performing DeleteNode: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after DeleteNode: %+v", err) - } - - return nil -} - -// preparerForDeleteNode prepares the DeleteNode request. -func (c NodeTypeClient) preparerForDeleteNode(ctx context.Context, id NodeTypeId, input NodeTypeActionParameters) (*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/deleteNode", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDeleteNode sends the DeleteNode request. The method will close the -// http.Response Body if it receives an error. -func (c NodeTypeClient) senderForDeleteNode(ctx context.Context, req *http.Request) (future DeleteNodeOperationResponse, 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/servicefabricmanagedcluster/2022-01-01/nodetype/method_get.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_get.go new file mode 100644 index 00000000000..62795c33904 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_get.go @@ -0,0 +1,51 @@ +package nodetype + +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 *NodeType +} + +// Get ... +func (c NodeTypeClient) Get(ctx context.Context, id NodeTypeId) (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/servicefabricmanagedcluster/2022-01-01/nodetype/method_get_autorest.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_get_autorest.go deleted file mode 100644 index f862c9383f8..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package nodetype - -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 *NodeType -} - -// Get ... -func (c NodeTypeClient) Get(ctx context.Context, id NodeTypeId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c NodeTypeClient) preparerForGet(ctx context.Context, id NodeTypeId) (*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 NodeTypeClient) 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/servicefabricmanagedcluster/2022-01-01/nodetype/method_listbymanagedclusters.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_listbymanagedclusters.go new file mode 100644 index 00000000000..1fb6fa2611f --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_listbymanagedclusters.go @@ -0,0 +1,91 @@ +package nodetype + +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 ListByManagedClustersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NodeType +} + +type ListByManagedClustersCompleteResult struct { + LatestHttpResponse *http.Response + Items []NodeType +} + +// ListByManagedClusters ... +func (c NodeTypeClient) ListByManagedClusters(ctx context.Context, id ManagedClusterId) (result ListByManagedClustersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/nodeTypes", 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 *[]NodeType `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByManagedClustersComplete retrieves all the results into a single object +func (c NodeTypeClient) ListByManagedClustersComplete(ctx context.Context, id ManagedClusterId) (ListByManagedClustersCompleteResult, error) { + return c.ListByManagedClustersCompleteMatchingPredicate(ctx, id, NodeTypeOperationPredicate{}) +} + +// ListByManagedClustersCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NodeTypeClient) ListByManagedClustersCompleteMatchingPredicate(ctx context.Context, id ManagedClusterId, predicate NodeTypeOperationPredicate) (result ListByManagedClustersCompleteResult, err error) { + items := make([]NodeType, 0) + + resp, err := c.ListByManagedClusters(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 = ListByManagedClustersCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_listbymanagedclusters_autorest.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_listbymanagedclusters_autorest.go deleted file mode 100644 index 6c118c65367..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_listbymanagedclusters_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package nodetype - -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 ListByManagedClustersOperationResponse struct { - HttpResponse *http.Response - Model *[]NodeType - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByManagedClustersOperationResponse, error) -} - -type ListByManagedClustersCompleteResult struct { - Items []NodeType -} - -func (r ListByManagedClustersOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByManagedClustersOperationResponse) LoadMore(ctx context.Context) (resp ListByManagedClustersOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByManagedClusters ... -func (c NodeTypeClient) ListByManagedClusters(ctx context.Context, id ManagedClusterId) (resp ListByManagedClustersOperationResponse, err error) { - req, err := c.preparerForListByManagedClusters(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "ListByManagedClusters", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "ListByManagedClusters", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByManagedClusters(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "ListByManagedClusters", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByManagedClusters prepares the ListByManagedClusters request. -func (c NodeTypeClient) preparerForListByManagedClusters(ctx context.Context, id ManagedClusterId) (*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/nodeTypes", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByManagedClustersWithNextLink prepares the ListByManagedClusters request with the given nextLink token. -func (c NodeTypeClient) preparerForListByManagedClustersWithNextLink(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)) -} - -// responderForListByManagedClusters handles the response to the ListByManagedClusters request. The method always -// closes the http.Response Body. -func (c NodeTypeClient) responderForListByManagedClusters(resp *http.Response) (result ListByManagedClustersOperationResponse, err error) { - type page struct { - Values []NodeType `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 ListByManagedClustersOperationResponse, err error) { - req, err := c.preparerForListByManagedClustersWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "ListByManagedClusters", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "ListByManagedClusters", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByManagedClusters(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "ListByManagedClusters", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByManagedClustersComplete retrieves all of the results into a single object -func (c NodeTypeClient) ListByManagedClustersComplete(ctx context.Context, id ManagedClusterId) (ListByManagedClustersCompleteResult, error) { - return c.ListByManagedClustersCompleteMatchingPredicate(ctx, id, NodeTypeOperationPredicate{}) -} - -// ListByManagedClustersCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c NodeTypeClient) ListByManagedClustersCompleteMatchingPredicate(ctx context.Context, id ManagedClusterId, predicate NodeTypeOperationPredicate) (resp ListByManagedClustersCompleteResult, err error) { - items := make([]NodeType, 0) - - page, err := c.ListByManagedClusters(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 := ListByManagedClustersCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_reimage.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_reimage.go new file mode 100644 index 00000000000..00358aaa9f5 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_reimage.go @@ -0,0 +1,74 @@ +package nodetype + +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 ReimageOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Reimage ... +func (c NodeTypeClient) Reimage(ctx context.Context, id NodeTypeId, input NodeTypeActionParameters) (result ReimageOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/reimage", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ReimageThenPoll performs Reimage then polls until it's completed +func (c NodeTypeClient) ReimageThenPoll(ctx context.Context, id NodeTypeId, input NodeTypeActionParameters) error { + result, err := c.Reimage(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Reimage: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Reimage: %+v", err) + } + + return nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_reimage_autorest.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_reimage_autorest.go deleted file mode 100644 index 63939de7f6b..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_reimage_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package nodetype - -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 ReimageOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Reimage ... -func (c NodeTypeClient) Reimage(ctx context.Context, id NodeTypeId, input NodeTypeActionParameters) (result ReimageOperationResponse, err error) { - req, err := c.preparerForReimage(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "Reimage", nil, "Failure preparing request") - return - } - - result, err = c.senderForReimage(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "Reimage", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// ReimageThenPoll performs Reimage then polls until it's completed -func (c NodeTypeClient) ReimageThenPoll(ctx context.Context, id NodeTypeId, input NodeTypeActionParameters) error { - result, err := c.Reimage(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Reimage: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Reimage: %+v", err) - } - - return nil -} - -// preparerForReimage prepares the Reimage request. -func (c NodeTypeClient) preparerForReimage(ctx context.Context, id NodeTypeId, input NodeTypeActionParameters) (*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/reimage", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForReimage sends the Reimage request. The method will close the -// http.Response Body if it receives an error. -func (c NodeTypeClient) senderForReimage(ctx context.Context, req *http.Request) (future ReimageOperationResponse, 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/servicefabricmanagedcluster/2022-01-01/nodetype/method_restart.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_restart.go new file mode 100644 index 00000000000..69322966ede --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_restart.go @@ -0,0 +1,74 @@ +package nodetype + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestartOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Restart ... +func (c NodeTypeClient) Restart(ctx context.Context, id NodeTypeId, input NodeTypeActionParameters) (result RestartOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restart", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RestartThenPoll performs Restart then polls until it's completed +func (c NodeTypeClient) RestartThenPoll(ctx context.Context, id NodeTypeId, input NodeTypeActionParameters) error { + result, err := c.Restart(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Restart: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Restart: %+v", err) + } + + return nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_restart_autorest.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_restart_autorest.go deleted file mode 100644 index 1eb428135ea..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_restart_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package nodetype - -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 RestartOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Restart ... -func (c NodeTypeClient) Restart(ctx context.Context, id NodeTypeId, input NodeTypeActionParameters) (result RestartOperationResponse, err error) { - req, err := c.preparerForRestart(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "Restart", nil, "Failure preparing request") - return - } - - result, err = c.senderForRestart(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "Restart", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// RestartThenPoll performs Restart then polls until it's completed -func (c NodeTypeClient) RestartThenPoll(ctx context.Context, id NodeTypeId, input NodeTypeActionParameters) error { - result, err := c.Restart(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Restart: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Restart: %+v", err) - } - - return nil -} - -// preparerForRestart prepares the Restart request. -func (c NodeTypeClient) preparerForRestart(ctx context.Context, id NodeTypeId, input NodeTypeActionParameters) (*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/restart", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForRestart sends the Restart request. The method will close the -// http.Response Body if it receives an error. -func (c NodeTypeClient) senderForRestart(ctx context.Context, req *http.Request) (future RestartOperationResponse, 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/servicefabricmanagedcluster/2022-01-01/nodetype/method_skuslist.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_skuslist.go new file mode 100644 index 00000000000..5f59da9a6bc --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_skuslist.go @@ -0,0 +1,91 @@ +package nodetype + +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 SkusListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NodeTypeAvailableSku +} + +type SkusListCompleteResult struct { + LatestHttpResponse *http.Response + Items []NodeTypeAvailableSku +} + +// SkusList ... +func (c NodeTypeClient) SkusList(ctx context.Context, id NodeTypeId) (result SkusListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/skus", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NodeTypeAvailableSku `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// SkusListComplete retrieves all the results into a single object +func (c NodeTypeClient) SkusListComplete(ctx context.Context, id NodeTypeId) (SkusListCompleteResult, error) { + return c.SkusListCompleteMatchingPredicate(ctx, id, NodeTypeAvailableSkuOperationPredicate{}) +} + +// SkusListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NodeTypeClient) SkusListCompleteMatchingPredicate(ctx context.Context, id NodeTypeId, predicate NodeTypeAvailableSkuOperationPredicate) (result SkusListCompleteResult, err error) { + items := make([]NodeTypeAvailableSku, 0) + + resp, err := c.SkusList(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 = SkusListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_skuslist_autorest.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_skuslist_autorest.go deleted file mode 100644 index ba22e443831..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_skuslist_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package nodetype - -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 SkusListOperationResponse struct { - HttpResponse *http.Response - Model *[]NodeTypeAvailableSku - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (SkusListOperationResponse, error) -} - -type SkusListCompleteResult struct { - Items []NodeTypeAvailableSku -} - -func (r SkusListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r SkusListOperationResponse) LoadMore(ctx context.Context) (resp SkusListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// SkusList ... -func (c NodeTypeClient) SkusList(ctx context.Context, id NodeTypeId) (resp SkusListOperationResponse, err error) { - req, err := c.preparerForSkusList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "SkusList", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "SkusList", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForSkusList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "SkusList", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForSkusList prepares the SkusList request. -func (c NodeTypeClient) preparerForSkusList(ctx context.Context, id NodeTypeId) (*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/skus", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForSkusListWithNextLink prepares the SkusList request with the given nextLink token. -func (c NodeTypeClient) preparerForSkusListWithNextLink(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)) -} - -// responderForSkusList handles the response to the SkusList request. The method always -// closes the http.Response Body. -func (c NodeTypeClient) responderForSkusList(resp *http.Response) (result SkusListOperationResponse, err error) { - type page struct { - Values []NodeTypeAvailableSku `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 SkusListOperationResponse, err error) { - req, err := c.preparerForSkusListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "SkusList", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "SkusList", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForSkusList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "SkusList", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// SkusListComplete retrieves all of the results into a single object -func (c NodeTypeClient) SkusListComplete(ctx context.Context, id NodeTypeId) (SkusListCompleteResult, error) { - return c.SkusListCompleteMatchingPredicate(ctx, id, NodeTypeAvailableSkuOperationPredicate{}) -} - -// SkusListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c NodeTypeClient) SkusListCompleteMatchingPredicate(ctx context.Context, id NodeTypeId, predicate NodeTypeAvailableSkuOperationPredicate) (resp SkusListCompleteResult, err error) { - items := make([]NodeTypeAvailableSku, 0) - - page, err := c.SkusList(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 := SkusListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_update.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_update.go new file mode 100644 index 00000000000..775598419e6 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_update.go @@ -0,0 +1,55 @@ +package nodetype + +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 *NodeType +} + +// Update ... +func (c NodeTypeClient) Update(ctx context.Context, id NodeTypeId, input NodeTypeUpdateParameters) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_update_autorest.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_update_autorest.go deleted file mode 100644 index a0f77c73908..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/nodetype/method_update_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package nodetype - -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 *NodeType -} - -// Update ... -func (c NodeTypeClient) Update(ctx context.Context, id NodeTypeId, input NodeTypeUpdateParameters) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "nodetype.NodeTypeClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c NodeTypeClient) preparerForUpdate(ctx context.Context, id NodeTypeId, input NodeTypeUpdateParameters) (*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 NodeTypeClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, 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/servicefabricmanagedcluster/2022-01-01/service/client.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/service/client.go index c0efa2f4308..d0e66ae6f3f 100644 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/service/client.go +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/service/client.go @@ -1,18 +1,26 @@ package service -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 ServiceClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewServiceClientWithBaseURI(endpoint string) ServiceClient { - return ServiceClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewServiceClientWithBaseURI(sdkApi sdkEnv.Api) (*ServiceClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "service", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ServiceClient: %+v", err) } + + return &ServiceClient{ + Client: client, + }, nil } diff --git a/resource-manager/servicefabricmanagedcluster/2022-01-01/service/constants.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/service/constants.go index cf32978c55c..f07e70bf16a 100644 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/service/constants.go +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/service/constants.go @@ -1,6 +1,10 @@ package service -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 PossibleValuesForMoveCost() []string { } } +func (s *MoveCost) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMoveCost(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseMoveCost(input string) (*MoveCost, error) { vals := map[string]MoveCost{ "high": MoveCostHigh, @@ -55,6 +72,19 @@ func PossibleValuesForPartitionScheme() []string { } } +func (s *PartitionScheme) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePartitionScheme(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePartitionScheme(input string) (*PartitionScheme, error) { vals := map[string]PartitionScheme{ "named": PartitionSchemeNamed, @@ -84,6 +114,19 @@ func PossibleValuesForServiceCorrelationScheme() []string { } } +func (s *ServiceCorrelationScheme) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceCorrelationScheme(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseServiceCorrelationScheme(input string) (*ServiceCorrelationScheme, error) { vals := map[string]ServiceCorrelationScheme{ "alignedaffinity": ServiceCorrelationSchemeAlignedAffinity, @@ -112,6 +155,19 @@ func PossibleValuesForServiceKind() []string { } } +func (s *ServiceKind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseServiceKind(input string) (*ServiceKind, error) { vals := map[string]ServiceKind{ "stateful": ServiceKindStateful, @@ -144,6 +200,19 @@ func PossibleValuesForServiceLoadMetricWeight() []string { } } +func (s *ServiceLoadMetricWeight) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceLoadMetricWeight(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseServiceLoadMetricWeight(input string) (*ServiceLoadMetricWeight, error) { vals := map[string]ServiceLoadMetricWeight{ "high": ServiceLoadMetricWeightHigh, @@ -174,6 +243,19 @@ func PossibleValuesForServicePackageActivationMode() []string { } } +func (s *ServicePackageActivationMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServicePackageActivationMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseServicePackageActivationMode(input string) (*ServicePackageActivationMode, error) { vals := map[string]ServicePackageActivationMode{ "exclusiveprocess": ServicePackageActivationModeExclusiveProcess, @@ -208,6 +290,19 @@ func PossibleValuesForServicePlacementPolicyType() []string { } } +func (s *ServicePlacementPolicyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServicePlacementPolicyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseServicePlacementPolicyType(input string) (*ServicePlacementPolicyType, error) { vals := map[string]ServicePlacementPolicyType{ "invaliddomain": ServicePlacementPolicyTypeInvalidDomain, @@ -239,6 +334,19 @@ func PossibleValuesForServiceScalingMechanismKind() []string { } } +func (s *ServiceScalingMechanismKind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceScalingMechanismKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseServiceScalingMechanismKind(input string) (*ServiceScalingMechanismKind, error) { vals := map[string]ServiceScalingMechanismKind{ "addremoveincrementalnamedpartition": ServiceScalingMechanismKindAddRemoveIncrementalNamedPartition, @@ -267,6 +375,19 @@ func PossibleValuesForServiceScalingTriggerKind() []string { } } +func (s *ServiceScalingTriggerKind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceScalingTriggerKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseServiceScalingTriggerKind(input string) (*ServiceScalingTriggerKind, error) { vals := map[string]ServiceScalingTriggerKind{ "averagepartitionloadtrigger": ServiceScalingTriggerKindAveragePartitionLoadTrigger, diff --git a/resource-manager/servicefabricmanagedcluster/2022-01-01/service/method_createorupdate.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/service/method_createorupdate.go new file mode 100644 index 00000000000..1c2db415434 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/service/method_createorupdate.go @@ -0,0 +1,75 @@ +package service + +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 *ServiceResource +} + +// CreateOrUpdate ... +func (c ServiceClient) CreateOrUpdate(ctx context.Context, id ServiceId, input ServiceResource) (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 + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c ServiceClient) CreateOrUpdateThenPoll(ctx context.Context, id ServiceId, input ServiceResource) 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/servicefabricmanagedcluster/2022-01-01/service/method_createorupdate_autorest.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/service/method_createorupdate_autorest.go deleted file mode 100644 index aa68ed59851..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/service/method_createorupdate_autorest.go +++ /dev/null @@ -1,80 +0,0 @@ -package service - -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 *ServiceResource -} - -// CreateOrUpdate ... -func (c ServiceClient) CreateOrUpdate(ctx context.Context, id ServiceId, input ServiceResource) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "service.ServiceClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "service.ServiceClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c ServiceClient) CreateOrUpdateThenPoll(ctx context.Context, id ServiceId, input ServiceResource) 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 ServiceClient) preparerForCreateOrUpdate(ctx context.Context, id ServiceId, input ServiceResource) (*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 ServiceClient) 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/servicefabricmanagedcluster/2022-01-01/service/method_delete.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/service/method_delete.go new file mode 100644 index 00000000000..92913350903 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/service/method_delete.go @@ -0,0 +1,71 @@ +package service + +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 ServiceClient) Delete(ctx context.Context, id ServiceId) (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 ServiceClient) DeleteThenPoll(ctx context.Context, id ServiceId) 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/servicefabricmanagedcluster/2022-01-01/service/method_delete_autorest.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/service/method_delete_autorest.go deleted file mode 100644 index d7941cd7187..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/service/method_delete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package service - -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 ServiceClient) Delete(ctx context.Context, id ServiceId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "service.ServiceClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "service.ServiceClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c ServiceClient) DeleteThenPoll(ctx context.Context, id ServiceId) 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 ServiceClient) preparerForDelete(ctx context.Context, id ServiceId) (*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 ServiceClient) 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/servicefabricmanagedcluster/2022-01-01/service/method_get.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/service/method_get.go new file mode 100644 index 00000000000..84c16fc430d --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/service/method_get.go @@ -0,0 +1,51 @@ +package service + +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 *ServiceResource +} + +// Get ... +func (c ServiceClient) Get(ctx context.Context, id ServiceId) (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/servicefabricmanagedcluster/2022-01-01/service/method_get_autorest.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/service/method_get_autorest.go deleted file mode 100644 index ab97a39a19f..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/service/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package service - -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 *ServiceResource -} - -// Get ... -func (c ServiceClient) Get(ctx context.Context, id ServiceId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "service.ServiceClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "service.ServiceClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "service.ServiceClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ServiceClient) preparerForGet(ctx context.Context, id ServiceId) (*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 ServiceClient) 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/servicefabricmanagedcluster/2022-01-01/service/method_listbyapplications.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/service/method_listbyapplications.go new file mode 100644 index 00000000000..18aab2aedc2 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/service/method_listbyapplications.go @@ -0,0 +1,91 @@ +package service + +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 ListByApplicationsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ServiceResource +} + +type ListByApplicationsCompleteResult struct { + LatestHttpResponse *http.Response + Items []ServiceResource +} + +// ListByApplications ... +func (c ServiceClient) ListByApplications(ctx context.Context, id ApplicationId) (result ListByApplicationsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/services", 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 *[]ServiceResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByApplicationsComplete retrieves all the results into a single object +func (c ServiceClient) ListByApplicationsComplete(ctx context.Context, id ApplicationId) (ListByApplicationsCompleteResult, error) { + return c.ListByApplicationsCompleteMatchingPredicate(ctx, id, ServiceResourceOperationPredicate{}) +} + +// ListByApplicationsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ServiceClient) ListByApplicationsCompleteMatchingPredicate(ctx context.Context, id ApplicationId, predicate ServiceResourceOperationPredicate) (result ListByApplicationsCompleteResult, err error) { + items := make([]ServiceResource, 0) + + resp, err := c.ListByApplications(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 = ListByApplicationsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2022-01-01/service/method_listbyapplications_autorest.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/service/method_listbyapplications_autorest.go deleted file mode 100644 index b002ae733cd..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/service/method_listbyapplications_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package service - -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 ListByApplicationsOperationResponse struct { - HttpResponse *http.Response - Model *[]ServiceResource - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByApplicationsOperationResponse, error) -} - -type ListByApplicationsCompleteResult struct { - Items []ServiceResource -} - -func (r ListByApplicationsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByApplicationsOperationResponse) LoadMore(ctx context.Context) (resp ListByApplicationsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByApplications ... -func (c ServiceClient) ListByApplications(ctx context.Context, id ApplicationId) (resp ListByApplicationsOperationResponse, err error) { - req, err := c.preparerForListByApplications(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "service.ServiceClient", "ListByApplications", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "service.ServiceClient", "ListByApplications", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByApplications(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "service.ServiceClient", "ListByApplications", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByApplications prepares the ListByApplications request. -func (c ServiceClient) preparerForListByApplications(ctx context.Context, id ApplicationId) (*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/services", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByApplicationsWithNextLink prepares the ListByApplications request with the given nextLink token. -func (c ServiceClient) preparerForListByApplicationsWithNextLink(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)) -} - -// responderForListByApplications handles the response to the ListByApplications request. The method always -// closes the http.Response Body. -func (c ServiceClient) responderForListByApplications(resp *http.Response) (result ListByApplicationsOperationResponse, err error) { - type page struct { - Values []ServiceResource `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 ListByApplicationsOperationResponse, err error) { - req, err := c.preparerForListByApplicationsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "service.ServiceClient", "ListByApplications", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "service.ServiceClient", "ListByApplications", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByApplications(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "service.ServiceClient", "ListByApplications", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByApplicationsComplete retrieves all of the results into a single object -func (c ServiceClient) ListByApplicationsComplete(ctx context.Context, id ApplicationId) (ListByApplicationsCompleteResult, error) { - return c.ListByApplicationsCompleteMatchingPredicate(ctx, id, ServiceResourceOperationPredicate{}) -} - -// ListByApplicationsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ServiceClient) ListByApplicationsCompleteMatchingPredicate(ctx context.Context, id ApplicationId, predicate ServiceResourceOperationPredicate) (resp ListByApplicationsCompleteResult, err error) { - items := make([]ServiceResource, 0) - - page, err := c.ListByApplications(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 := ListByApplicationsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/servicefabricmanagedcluster/2022-01-01/services/client.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/services/client.go index 7195c075b5b..dc4a72c1ff4 100644 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/services/client.go +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/services/client.go @@ -1,18 +1,26 @@ package services -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 ServicesClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewServicesClientWithBaseURI(endpoint string) ServicesClient { - return ServicesClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewServicesClientWithBaseURI(sdkApi sdkEnv.Api) (*ServicesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "services", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ServicesClient: %+v", err) } + + return &ServicesClient{ + Client: client, + }, nil } diff --git a/resource-manager/servicefabricmanagedcluster/2022-01-01/services/constants.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/services/constants.go index 18157d1d4db..d63db0a55d5 100644 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/services/constants.go +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/services/constants.go @@ -1,6 +1,10 @@ package services -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 PossibleValuesForMoveCost() []string { } } +func (s *MoveCost) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMoveCost(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseMoveCost(input string) (*MoveCost, error) { vals := map[string]MoveCost{ "high": MoveCostHigh, @@ -55,6 +72,19 @@ func PossibleValuesForPartitionScheme() []string { } } +func (s *PartitionScheme) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePartitionScheme(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePartitionScheme(input string) (*PartitionScheme, error) { vals := map[string]PartitionScheme{ "named": PartitionSchemeNamed, @@ -84,6 +114,19 @@ func PossibleValuesForServiceCorrelationScheme() []string { } } +func (s *ServiceCorrelationScheme) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceCorrelationScheme(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseServiceCorrelationScheme(input string) (*ServiceCorrelationScheme, error) { vals := map[string]ServiceCorrelationScheme{ "alignedaffinity": ServiceCorrelationSchemeAlignedAffinity, @@ -112,6 +155,19 @@ func PossibleValuesForServiceKind() []string { } } +func (s *ServiceKind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseServiceKind(input string) (*ServiceKind, error) { vals := map[string]ServiceKind{ "stateful": ServiceKindStateful, @@ -144,6 +200,19 @@ func PossibleValuesForServiceLoadMetricWeight() []string { } } +func (s *ServiceLoadMetricWeight) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceLoadMetricWeight(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseServiceLoadMetricWeight(input string) (*ServiceLoadMetricWeight, error) { vals := map[string]ServiceLoadMetricWeight{ "high": ServiceLoadMetricWeightHigh, @@ -174,6 +243,19 @@ func PossibleValuesForServicePackageActivationMode() []string { } } +func (s *ServicePackageActivationMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServicePackageActivationMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseServicePackageActivationMode(input string) (*ServicePackageActivationMode, error) { vals := map[string]ServicePackageActivationMode{ "exclusiveprocess": ServicePackageActivationModeExclusiveProcess, @@ -208,6 +290,19 @@ func PossibleValuesForServicePlacementPolicyType() []string { } } +func (s *ServicePlacementPolicyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServicePlacementPolicyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseServicePlacementPolicyType(input string) (*ServicePlacementPolicyType, error) { vals := map[string]ServicePlacementPolicyType{ "invaliddomain": ServicePlacementPolicyTypeInvalidDomain, @@ -239,6 +334,19 @@ func PossibleValuesForServiceScalingMechanismKind() []string { } } +func (s *ServiceScalingMechanismKind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceScalingMechanismKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseServiceScalingMechanismKind(input string) (*ServiceScalingMechanismKind, error) { vals := map[string]ServiceScalingMechanismKind{ "addremoveincrementalnamedpartition": ServiceScalingMechanismKindAddRemoveIncrementalNamedPartition, @@ -267,6 +375,19 @@ func PossibleValuesForServiceScalingTriggerKind() []string { } } +func (s *ServiceScalingTriggerKind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceScalingTriggerKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseServiceScalingTriggerKind(input string) (*ServiceScalingTriggerKind, error) { vals := map[string]ServiceScalingTriggerKind{ "averagepartitionloadtrigger": ServiceScalingTriggerKindAveragePartitionLoadTrigger, diff --git a/resource-manager/servicefabricmanagedcluster/2022-01-01/services/method_update.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/services/method_update.go new file mode 100644 index 00000000000..abd5b17eaf8 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2022-01-01/services/method_update.go @@ -0,0 +1,55 @@ +package services + +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 *ServiceResource +} + +// Update ... +func (c ServicesClient) Update(ctx context.Context, id ServiceId, input ServiceUpdateParameters) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2022-01-01/services/method_update_autorest.go b/resource-manager/servicefabricmanagedcluster/2022-01-01/services/method_update_autorest.go deleted file mode 100644 index ee3b44fcd19..00000000000 --- a/resource-manager/servicefabricmanagedcluster/2022-01-01/services/method_update_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package services - -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 *ServiceResource -} - -// Update ... -func (c ServicesClient) Update(ctx context.Context, id ServiceId, input ServiceUpdateParameters) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "services.ServicesClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "services.ServicesClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "services.ServicesClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c ServicesClient) preparerForUpdate(ctx context.Context, id ServiceId, input ServiceUpdateParameters) (*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 ServicesClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -}